public SparkleInfobar(string icon_name, string title, string text) { Window window = new Window(WindowType.Popup) { Name = "gtk-tooltip" }; window.EnsureStyle(); Style = window.Style; Label label = new Label() { Markup = "<b>" + title + "</b>\n" + text }; HBox hbox = new HBox(false, 12) { BorderWidth = 12 }; hbox.PackStart(new Image(SparkleUIHelpers.GetIcon(icon_name, 24)), false, false, 0); hbox.PackStart(label, false, false, 0); Add(hbox); }
// The state when there's nothing going on private void SetNormalState(bool error) { Animation.Stop(); if (SparkleShare.Controller.Folders.Count == 0) { StateText = _("Welcome to SparkleShare!"); Application.Invoke(delegate { Pixbuf = AnimationFrames [0]; }); } else { if (error) { StateText = _("Not everything is synced"); Application.Invoke(delegate { Pixbuf = SparkleUIHelpers.GetIcon("sparkleshare-syncing-error", 24); }); } else { StateText = _("Up to date") + " (" + SparkleShare.Controller.FolderSize + ")"; Application.Invoke(delegate { Pixbuf = AnimationFrames [0]; }); } } }
private void CreateAnimationFrames() { this.animation_frames = new Gdk.Pixbuf [5]; Gdk.Pixbuf frames_pixbuf = SparkleUIHelpers.GetIcon("process-syncing-sparkleshare", 24); for (int i = 0; i < this.animation_frames.Length; i++) { animation_frames [i] = new Gdk.Pixbuf(frames_pixbuf, (i * 24), 0, 24, 24); } }
private void CreateAnimationFrames() { this.animation_frames = new Gdk.Pixbuf [] { SparkleUIHelpers.GetIcon("process-syncing-i", 24), SparkleUIHelpers.GetIcon("process-syncing-ii", 24), SparkleUIHelpers.GetIcon("process-syncing-iii", 24), SparkleUIHelpers.GetIcon("process-syncing-iiii", 24), SparkleUIHelpers.GetIcon("process-syncing-iiiii", 24) }; }
public SparkleSpinner(int size) : base() { int current_frame = 0; Gdk.Pixbuf spinner_gallery = SparkleUIHelpers.GetIcon("process-working", size); int frames_in_width = spinner_gallery.Width / size; int frames_in_height = spinner_gallery.Height / size; int frame_count = (frames_in_width * frames_in_height) - 1; Gdk.Pixbuf [] frames = new Gdk.Pixbuf [frame_count]; int i = 0; for (int y = 0; y < frames_in_height; y++) { for (int x = 0; x < frames_in_width; x++) { if (!(y == 0 && x == 0)) { frames [i] = new Gdk.Pixbuf(spinner_gallery, x * size, y * size, size, size); i++; } } } timer = new Timer() { Interval = 600 / frame_count }; timer.Elapsed += delegate { if (current_frame < frame_count - 1) { current_frame++; } else { current_frame = 0; } Application.Invoke(delegate { Pixbuf = frames [current_frame]; }); }; }
public SparkleSpinner(int size) : base() { Size = size; CycleDuration = 600; CurrentStep = 0; Gdk.Pixbuf spinner_gallery = SparkleUIHelpers.GetIcon("process-working", Size); int frames_in_width = spinner_gallery.Width / Size; int frames_in_height = spinner_gallery.Height / Size; NumSteps = frames_in_width * frames_in_height; Images = new Gdk.Pixbuf [NumSteps - 1]; int i = 0; for (int y = 0; y < frames_in_height; y++) { for (int x = 0; x < frames_in_width; x++) { if (!(y == 0 && x == 0)) { Images [i] = new Gdk.Pixbuf(spinner_gallery, x * Size, y * Size, Size, Size); i++; } } } Timer = new Timer() { Interval = CycleDuration / NumSteps }; Timer.Elapsed += delegate { NextImage(); }; Start(); }
public SparkleStatusIcon() { AnimationFrames = CreateAnimationFrames(); Animation = CreateAnimation(); #if HAVE_APP_INDICATOR this.indicator = new ApplicationIndicator("sparkleshare", "process-syncing-sparkleshare-i", Category.ApplicationStatus) { Status = Status.Attention }; #else this.status_icon = new StatusIcon(); this.status_icon.Activate += ShowMenu; // Primary mouse button click this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click this.status_icon.Pixbuf = AnimationFrames [0]; #endif if (Controller.Folders.Length == 0) { StateText = _("Welcome to SparkleShare!"); } else { StateText = _("Up to date") + " — " + Controller.FolderSize; } CreateMenu(); Controller.UpdateMenuEvent += delegate(IconState state) { Application.Invoke(delegate { switch (state) { case IconState.Idle: Animation.Stop(); if (Controller.Folders.Length == 0) { StateText = _("Welcome to SparkleShare!"); } else { StateText = _("Up to date") + " — " + Controller.FolderSize; } #if HAVE_APP_INDICATOR this.indicator.IconName = "process-syncing-sparkleshare-i"; #else this.status_icon.Pixbuf = AnimationFrames [0]; #endif UpdateStateText(); CreateMenu(); break; case IconState.Syncing: StateText = _("Syncing…"); UpdateStateText(); if (!Animation.Enabled) { Animation.Start(); } break; case IconState.Error: Animation.Stop(); StateText = _("Not everything is synced"); UpdateStateText(); CreateMenu(); #if HAVE_APP_INDICATOR this.indicator.IconName = "sparkleshare-syncing-error"; #else this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon("sparkleshare-syncing-error", 24); #endif break; } }); }; }
// Creates the menu that is popped up when the // user clicks the status icon public void CreateMenu() { Menu = new Menu(); // The menu item showing the status and size of the SparkleShare folder MenuItem status_menu_item = new MenuItem(StateText) { Sensitive = false }; Menu.Add(status_menu_item); Menu.Add(new SeparatorMenuItem()); ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare") { Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16)) }; folder_item.Activated += delegate { Program.Controller.OpenSparkleShareFolder(); }; Menu.Add(folder_item); if (Program.Controller.Folders.Count > 0) { // Creates a menu item for each repository with a link to their logs foreach (string folder_name in Program.Controller.Folders) { Gdk.Pixbuf folder_icon; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16, IconLookupFlags.GenericFallback); } else { folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); } ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name) { Image = new Image(folder_icon) }; subfolder_item.Activated += OpenFolderDelegate(folder_name); Menu.Add(subfolder_item); } } else { MenuItem no_folders_item = new MenuItem(_("No projects yet")) { Sensitive = false }; Menu.Add(no_folders_item); } Menu.Add(new SeparatorMenuItem()); // Opens the wizard to add a new remote folder MenuItem sync_item = new MenuItem(_("Add Hosted Project…")); if (Program.Controller.FirstRun) { sync_item.Sensitive = false; } sync_item.Activated += delegate { Application.Invoke(delegate { if (SparkleUI.Setup == null) { SparkleUI.Setup = new SparkleSetup(); SparkleUI.Setup.Controller.ShowAddPage(); } if (!SparkleUI.Setup.Visible) { SparkleUI.Setup.Controller.ShowAddPage(); } //SparkleUI.Intro.ShowAll (); //SparkleUI.Intro.Present (); }); }; Menu.Add(sync_item); Menu.Add(new SeparatorMenuItem()); MenuItem recent_events_item = new MenuItem(_("Open Recent Events")); recent_events_item.Sensitive = (Controller.Folders.Length > 0); recent_events_item.Activated += delegate { Application.Invoke(delegate { if (SparkleUI.EventLog == null) { SparkleUI.EventLog = new SparkleEventLog(); } SparkleUI.EventLog.ShowAll(); SparkleUI.EventLog.Present(); }); }; Menu.Add(recent_events_item); MenuItem notify_item; if (Program.Controller.NotificationsEnabled) { notify_item = new MenuItem(_("Turn Notifications Off")); } else { notify_item = new MenuItem(_("Turn Notifications On")); } notify_item.Activated += delegate { Program.Controller.ToggleNotifications(); CreateMenu(); }; Menu.Add(notify_item); Menu.Add(new SeparatorMenuItem()); // A menu item that takes the user to http://www.sparkleshare.org/ MenuItem about_item = new MenuItem(_("About SparkleShare")); about_item.Activated += delegate { Application.Invoke(delegate { if (SparkleUI.About == null) { SparkleUI.About = new SparkleAbout(); } SparkleUI.About.ShowAll(); SparkleUI.About.Present(); }); }; Menu.Add(about_item); Menu.Add(new SeparatorMenuItem()); // A menu item that quits the application MenuItem quit_item = new MenuItem(_("Quit")); quit_item.Activated += delegate { Program.Controller.Quit(); }; Menu.Add(quit_item); Menu.ShowAll(); #if HAVE_APP_INDICATOR this.indicator.Menu = Menu; #endif }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to SparkleShare!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; UnixUserInfo user_info = UnixUserInfo.GetRealUser(); if (user_info != null && user_info.RealName != null) { name_entry.Text = user_info.RealName.TrimEnd(",".ToCharArray()); } Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.SetupPageCompleted(name_entry.Text, email_entry.Text); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(name_entry.Text, email_entry.Text); break; } case PageType.Add: { Header = "Where's your project hosted?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow(); scrolled_window.AddWithViewport(tree); // Icon column tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0); tree.Columns [0].Cells [0].Xpad = 6; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 4 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues( new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree.AppendColumn(service_column); Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Entry path_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; // Select the first plugin by default TreeSelection default_selection = tree.Selection; TreePath default_path = new TreePath("0"); default_selection.SelectPath(default_path); Controller.SelectedPluginChanged(0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); // Update the address field text when the selection changes tree.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree.SelectedRow); // TODO: Scroll to selected row when using arrow keys }; tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } // TODO: Scroll to the selection return(true); } else { return(false); } })); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_address.PackStart(new Label() { Markup = "<b>" + "Address:" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path:" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add") { Sensitive = false }; add_button.Clicked += delegate { Controller.AddPageCompleted(address_entry.Text, path_entry.Text); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; CheckButton check_button = new CheckButton("Fetch prior history") { Active = false }; check_button.Toggled += delegate { Controller.HistoryItemChanged(check_button.Active); }; AddOption(check_button); AddButton(cancel_button); AddButton(add_button); Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add"); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may take a while for large projects.\nIsn't it coffee-o'clock?"; this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = "Finish" }; Button cancel_button = new Button() { Label = "Cancel" }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Do you have access rights to this remote project?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here's the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button("Try Again…") { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don't use elsewhere below:"; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = "Your shared project is ready!"; string subtext = "You can find the files in your SparkleShare folder."; Program.UI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = "Your shared project is ready!"; Description = "You can find it in your SparkleShare folder"; // A button that opens the synced folder Button show_files_button = new Button("Show Files…"); show_files_button.Clicked += delegate { Controller.ShowFilesClicked(); }; Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24)); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(show_files_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; Button skip_tutorial_button = new Button("Skip Tutorial"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = "Here's your unique link code"; Description = "You'll need it whenever you want to link this computer to a host" + " (we keep a copy in your SparkleShare folder)."; Button finish_button = new Button("Finish"); VBox layout_vertical = new VBox(false, 0) { BorderWidth = 48 }; HBox layout_horizontal = new HBox(false, 6); Entry link_code_entry = new Entry() { Text = Program.Controller.CurrentUser.PublicKey, Sensitive = false }; Button copy_button = new Button(" Copy "); CheckButton check_button = new CheckButton("Add SparkleShare to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; copy_button.Clicked += delegate { Clipboard clip_board = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)); clip_board.Text = link_code_entry.Text; }; finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; layout_horizontal.PackStart(link_code_entry, true, true, 0); layout_horizontal.PackStart(copy_button, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 0); layout_vertical.PackStart(layout_horizontal, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 18); Add(layout_vertical); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public SparkleUI() { // Initialize the application Application.Init(); // Create the statusicon StatusIcon = new SparkleStatusIcon(); // Keep track of which event logs are open OpenLogs = new List <SparkleLog> (); if (SparkleShare.Controller.FirstRun) { Intro = new SparkleIntro(); Intro.ShowAccountForm(); } SparkleShare.Controller.OnQuitWhileSyncing += delegate { // TODO: Pop up a warning when quitting whilst syncing }; SparkleShare.Controller.OnInvitation += delegate(string server, string folder, string token) { Application.Invoke(delegate { SparkleIntro intro = new SparkleIntro(); intro.ShowInvitationPage(server, folder, token); }); }; // Show a bubble when there are new changes SparkleShare.Controller.NotificationRaised += delegate(string user_name, string user_email, string message, string repository_path) { foreach (SparkleLog log in OpenLogs) { if (log.LocalPath.Equals(repository_path)) { Application.Invoke(delegate { log.UpdateEventLog(); }); } } // TODO: move to controller and do translation here if (!SparkleShare.Controller.NotificationsEnabled) { return; } Application.Invoke(delegate { SparkleBubble bubble = new SparkleBubble(user_name, message); string avatar_file_path = SparkleUIHelpers.GetAvatar(user_email, 32); if (avatar_file_path != null) { bubble.Icon = new Gdk.Pixbuf(avatar_file_path); } else { bubble.Icon = SparkleUIHelpers.GetIcon("avatar-default", 32); } bubble.AddAction("", "Show Events", delegate { AddEventLog(repository_path); }); bubble.Show(); }); }; // Show a bubble when there was a conflict SparkleShare.Controller.ConflictNotificationRaised += delegate { Application.Invoke(delegate { string title = _("Ouch! Mid-air collision!"); string subtext = _("Don't worry, SparkleShare made a copy of each conflicting file."); new SparkleBubble(title, subtext).Show(); }); }; SparkleShare.Controller.AvatarFetched += delegate { Application.Invoke(delegate { foreach (SparkleLog log in OpenLogs) { log.UpdateEventLog(); } }); }; SparkleShare.Controller.OnIdle += delegate { Application.Invoke(delegate { foreach (SparkleLog log in OpenLogs) { log.UpdateEventLog(); } }); }; }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to CmisSync!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(UnixUserInfo.GetRealUser().RealName) { Xalign = 0, ActivatesDefault = true }; Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; name_entry.Changed += delegate { Controller.CheckSetupPage(); }; email_entry.Changed += delegate { Controller.CheckSetupPage(); }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(); break; } case PageType.Add1: { Header = "Where is your organization's server?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label address_help_label = new Label() { Text = "Help: ", // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128)) }; /* TODO Run run = new Run("Where to find this address"); * Hyperlink link = new Hyperlink(run); * link.NavigateUri = new Uri("https://github.com/nicolas-raoul/CmisSync/wiki/What-address"); * address_help_label.Inlines.Add(link); * link.RequestNavigate += (sender, e) => * { * System.Diagnostics.Process.Start(e.Uri.ToString()); * };*/ Label address_error_label = new Label() { // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(255, 128, 128)), // TODO Visibility = Visibility.Hidden }; // User Entry user_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.User == null), ActivatesDefault = true }; Label user_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.UserExample + "</span>" }; // Password Entry password_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Password == null), ActivatesDefault = true }; Label password_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PasswordExample + "</span>" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangeUserFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { user_entry.Text = text; user_entry.Sensitive = (state == FieldState.Enabled); user_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePasswordFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { password_entry.Text = text; password_entry.Sensitive = (state == FieldState.Enabled); password_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text); }; // Address layout_address.PackStart(new Label() { Markup = "<b>" + "Address:" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); // User layout_user.PackStart(new Label() { Markup = "<b>" + "User:"******"</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); layout_user.PackStart(user_example, false, false, 0); // Password layout_password.PackStart(new Label() { Markup = "<b>" + "password:"******"</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_password.PackStart(password_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; // Continue button Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { // Show wait cursor // TODO System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; SparkleLogger.LogInfo("SparkleSetup", "address:" + address_entry.Text + " user:"******" password:"******"Sorry, CmisSync can not find a CMIS server at this address.\nPlease check again.\nIf you are sure about the address, open it in a browser and post\nthe resulting XML to the CmisSync forum."; // TODO address_error_label.Visibility = Visibility.Visible; } else { SparkleLogger.LogInfo("SparkleSetup", "repositories[0]:" + Controller.repositories[0]); // Continue to folder selection Controller.Add1PageCompleted( address_entry.Text, user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(continue_button); Controller.CheckAddPage(address_entry.Text); break; } case PageType.Add2: { Header = "Which remote folder do you want to sync?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_repository = new VBox(true, 0); VBox layout_path = new VBox(true, 0); // Repository Entry repository_entry = new Entry() { Text = Controller.repositories[0], // TODO put all elements in a tree Sensitive = (Controller.SelectedPlugin.Repository == null), ActivatesDefault = true }; Label repository_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.RepositoryExample + "</span>" }; // Path Entry path_entry = new Entry() { Text = "/", Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; Controller.ChangeRepositoryFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { repository_entry.Text = text; repository_entry.Sensitive = (state == FieldState.Enabled); repository_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; //Controller.CheckAddPage (address_entry.Text); // Repository layout_repository.PackStart(new Label() { Markup = "<b>" + "Repository:" + "</b>", Xalign = 0 }, true, true, 0); layout_repository.PackStart(repository_entry, false, false, 0); layout_repository.PackStart(repository_example, false, false, 0); // Path layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path:" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_repository); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add") { //Sensitive = false }; add_button.Clicked += delegate { Controller.Add2PageCompleted(repository_entry.Text, path_entry.Text); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(add_button); //Controller.CheckAddPage (address_entry.Text); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add"); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may either take a short or a long time depending on the project's size."; this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = "Finish" }; Button cancel_button = new Button() { Label = "Cancel" }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Do you have access rights to this remote project?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here's the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button("Try Again…") { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = "Your documents are ready!"; string subtext = "You can find them in your CmisSync folder."; Program.UI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = "Your documents are ready!"; Description = "You can find them in your CmisSync folder."; // A button that opens the synced folder Button open_folder_button = new Button(string.Format("Open {0}", System.IO.Path.GetFileName(Controller.PreviousPath))); open_folder_button.Clicked += delegate { Controller.OpenFolderClicked(); }; Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "CmisSync creates a special folder on your computer " + "that will keep track of your folders."; Button skip_tutorial_button = new Button("Skip Tutorial"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to the server are automatically synced to your " + "local folder."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = "The status icon is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your folders and let's you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = "Adding repository folders to CmisSync"; Description = " " + " "; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; CheckButton check_button = new CheckButton("Add CmisSync to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; Add(slide); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public void CreateMenu() { this.menu = new Menu(); this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare") { Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16)) }; folder_item.Activated += delegate { Controller.SparkleShareClicked(); }; this.menu.Add(folder_item); if (Program.Controller.Folders.Count > 0) { foreach (string folder_name in Controller.Folders) { Gdk.Pixbuf folder_icon; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16, IconLookupFlags.GenericFallback); } else { folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); } ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name) { Image = new Image(folder_icon) }; subfolder_item.Activated += OpenFolderDelegate(folder_name); this.menu.Add(subfolder_item); } Menu submenu = new Menu(); foreach (string folder_name in Controller.OverflowFolders) { Gdk.Pixbuf folder_icon; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { folder_icon = IconTheme.Default.LoadIcon("dialog-error", 16, IconLookupFlags.GenericFallback); } else { folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); } ImageMenuItem subfolder_item = new SparkleMenuItem(folder_name) { Image = new Image(folder_icon) }; subfolder_item.Activated += OpenFolderDelegate(folder_name); submenu.Add(subfolder_item); } if (submenu.Children.Length > 0) { SparkleMenuItem more_item = new SparkleMenuItem("More Projects") { Submenu = submenu }; this.menu.Add(new SeparatorMenuItem()); this.menu.Add(more_item); } } this.menu.Add(new SeparatorMenuItem()); MenuItem sync_item = new MenuItem(_("Add Hosted Project…")); sync_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.menu.Add(sync_item); this.recent_events_item = new MenuItem(_("View Recent Changes…")); this.recent_events_item.Sensitive = Controller.OpenRecentEventsItemEnabled; this.recent_events_item.Activated += delegate { Controller.OpenRecentEventsClicked(); }; this.menu.Add(this.recent_events_item); this.menu.Add(new SeparatorMenuItem()); MenuItem notify_item; if (Program.Controller.NotificationsEnabled) { notify_item = new MenuItem(_("Turn Notifications Off")); } else { notify_item = new MenuItem(_("Turn Notifications On")); } notify_item.Activated += delegate { Application.Invoke(delegate { Program.Controller.ToggleNotifications(); if (Program.Controller.NotificationsEnabled) { (notify_item.Child as Label).Text = _("Turn Notifications Off"); } else { (notify_item.Child as Label).Text = _("Turn Notifications On"); } }); }; this.menu.Add(notify_item); this.menu.Add(new SeparatorMenuItem()); MenuItem about_item = new MenuItem(_("About SparkleShare")); about_item.Activated += delegate { Controller.AboutClicked(); }; this.menu.Add(about_item); this.menu.Add(new SeparatorMenuItem()); this.quit_item = new MenuItem(_("Quit")) { Sensitive = Controller.QuitItemEnabled }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; this.menu.Add(this.quit_item); this.menu.ShowAll(); #if HAVE_APP_INDICATOR this.indicator.Menu = this.menu; #endif }
public SparkleSetup() : base() { SecondaryTextColor = SparkleUIHelpers.GdkColorToHex(Style.Foreground(StateType.Insensitive)); SecondaryTextColorSelected = SparkleUIHelpers.GdkColorToHex( MixColors( new TreeView().Style.Foreground(StateType.Selected), new TreeView().Style.Background(StateType.Selected), 0.15 ) ); Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = _("Welcome to SparkleShare!"); Description = "We'll need some info to mark your changes in the event log. " + "Don't worry, this stays between you and your peers."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + _("Full Name:") + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(Controller.GuessedUserName) { Xalign = 0 }; Entry email_entry = new Entry(Controller.GuessedUserEmail) { Xalign = 0 }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; Label email_label = new Label("<b>" + _("Email:") + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button continue_button = new Button(_("Continue")) { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(full_name, email); }; AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(name_entry.Text, email_entry.Text); break; } case PageType.Add: { Header = _("Where's your project hosted?"); VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow(); scrolled_window.AddWithViewport(tree); // Icon column tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0); tree.Columns [0].Cells [0].Xpad = 6; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 4 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues( new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree.AppendColumn(service_column); SparkleEntry path_entry = new SparkleEntry(); SparkleEntry address_entry = new SparkleEntry(); // Select the first plugin by default TreeSelection default_selection = tree.Selection; TreePath default_path = new TreePath("0"); default_selection.SelectPath(default_path); Controller.SelectedPluginChanged(0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); if (string.IsNullOrEmpty(example_text)) { address_entry.ExampleText = null; } else { address_entry.ExampleText = example_text; } if (string.IsNullOrEmpty(text)) { address_entry.ExampleTextActive = true; } else { address_entry.ExampleTextActive = false; } }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); if (string.IsNullOrEmpty(example_text)) { path_entry.ExampleText = null; } else { path_entry.ExampleText = example_text; } if (string.IsNullOrEmpty(text)) { path_entry.ExampleTextActive = true; } else { path_entry.ExampleTextActive = false; } }); }; // Update the address field text when the selection changes tree.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree.SelectedRow); // TODO: Scroll to selected row when using arrow keys }; tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } // TODO: Scroll to the selection return(true); } else { return(false); } })); address_entry.Completion = new EntryCompletion(); ListStore server_store = new ListStore(typeof(string)); foreach (string host in Program.Controller.PreviousHosts) { server_store.AppendValues(host); } address_entry.Completion.Model = server_store; address_entry.Completion.TextColumn = 0; address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_address.PackStart(new Label() { Markup = "<b>" + _("Address") + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, true, true, 0); path_entry.Completion = new EntryCompletion(); ListStore folder_store = new ListStore(typeof(string)); //foreach (string host in Program.Controller.FolderPaths) // folder_store.AppendValues (host); path_entry.Completion.Model = folder_store; path_entry.Completion.TextColumn = 0; path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + _("Remote Path") + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, true, true, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Close(); }; // Sync button Button add_button = new Button(_("Add")); add_button.Clicked += delegate { string server = address_entry.Text; string folder_name = path_entry.Text; Controller.AddPageCompleted(server, folder_name); }; AddButton(cancel_button); AddButton(add_button); Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); break; } case PageType.Syncing: { Header = String.Format(_("Adding project ‘{0}’…"), Controller.SyncingFolder); Description = _("This may take a while.") + Environment.NewLine + _("Are you sure it’s not coffee o'clock?"); Button finish_button = new Button() { Sensitive = false, Label = _("Finish") }; Button cancel_button = new Button() { Label = _("Cancel") }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 0); Add(bar_wrapper); break; } case PageType.Error: { Header = _("Something went wrong") + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)) { }; Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)) { }; Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)) { }; Label label_one = new Label() { Text = "First, have you tried turning it off and on again?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_three = new Label() { Text = "The host needs to know who you are. Did you upload the key that's in " + "your SparkleShare folder?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); points.PackStart(new Label(""), true, true, 0); Button try_again_button = new Button(_("Try Again…")) { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(try_again_button); Add(points); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = String.Format(_("‘{0}’ has been successfully added"), Controller.SyncingFolder); string subtext = ""; SparkleUI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = _("Project successfully added!"); Description = _("Access the files from your SparkleShare folder."); // A button that opens the synced folder Button open_folder_button = new Button(_("Open Folder")); open_folder_button.Clicked += delegate { Program.Controller.OpenSparkleShareFolder(Controller.SyncingFolder); }; Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Controller.FinishedPageCompleted(); Close(); }; if (warnings != null) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-warning", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 0); warning_layout.PackStart(warning_label, true, true, 15); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = _("What's happening next?"); Description = _("SparkleShare creates a special folder in your personal folder " + "that will keep track of your projects."); Button skip_tutorial_button = new Button(_("Skip Tutorial")); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = _("Sharing files with others"); Description = _("All files added to your project folders are synced with the host " + "automatically, as well as with your collaborators."); Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = _("The status icon is here to help"); Description = _("It shows the syncing process status, " + "and contains links to your projects and the event log."); Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = _("Adding projects to SparkleShare"); Description = _("Just click this button when you see it on the web, and " + "the project will be automatically added:"); Label label = new Label(_("…or select <b>‘Add Hosted Project…’</b> from the status icon menu " + "to add one by hand.")) { Wrap = true, Xalign = 0, UseMarkup = true }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Close(); }; VBox box = new VBox(false, 0); box.Add(slide); box.Add(label); Add(box); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = _("Welcome to SparkleShare!"); Description = "Before we get started, what's your name and email? " + "Don't worry, this information will only be visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + _("Full Name:") + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(Controller.GuessedUserName) { Xalign = 0 }; Entry email_entry = new Entry(Controller.GuessedUserEmail) { Xalign = 0 }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; Label email_label = new Label("<b>" + _("Email:") + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button(_("Continue")) { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(full_name, email); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(name_entry.Text, email_entry.Text); break; } case PageType.Add: { Header = _("Where's your project hosted?"); VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow(); scrolled_window.AddWithViewport(tree); // Icon column tree.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 0); tree.Columns [0].Cells [0].Xpad = 6; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 4 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues( new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + SecondaryTextColorSelected + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree.AppendColumn(service_column); Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null) }; Entry path_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null) }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; // Select the first plugin by default TreeSelection default_selection = tree.Selection; TreePath default_path = new TreePath("0"); default_selection.SelectPath(default_path); Controller.SelectedPluginChanged(0); Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); // Update the address field text when the selection changes tree.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree.SelectedRow); // TODO: Scroll to selected row when using arrow keys }; tree.Model.Foreach(new TreeModelForeachFunc(delegate(TreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } // TODO: Scroll to the selection return(true); } else { return(false); } })); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_address.PackStart(new Label() { Markup = "<b>" + _("Address:") + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + _("Remote Path:") + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button(_("Add")); add_button.Clicked += delegate { string server = address_entry.Text; string folder_name = path_entry.Text; Controller.AddPageCompleted(server, folder_name); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; CheckButton check_button = new CheckButton("Fetch prior history") { Active = false }; check_button.Toggled += delegate { Controller.HistoryItemChanged(check_button.Active); }; AddOption(check_button); AddButton(cancel_button); AddButton(add_button); break; } case PageType.Invite: { Header = _("You've received an invite!"); Description = _("Do you want to add this project to SparkleShare?"); Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label(_("Address:")) { Xalign = 1 }; Label path_label = new Label(_("Remote Path:")) { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button(_("Add")); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format(_("Adding project ‘{0}’…"), Controller.SyncingFolder); Description = _("This may either take a short or a long time depending on the project's size."); this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = _("Finish") }; Button cancel_button = new Button() { Label = _("Cancel") }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = _("Something went wrong") + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Label label_one = new Label() { Text = "Is the host online?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_three = new Label() { Text = "The host needs to know who you are. Did you upload the key that's in " + "your SparkleShare folder?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button(_("Cancel")); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button(_("Try Again…")) { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; Label password_label = new Label("<b>" + _("Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + _("Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = _("Your shared project is ready!"); string subtext = _("You can find the files in your SparkleShare folder."); SparkleUI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = _("Your shared project is ready!"); Description = _("You can find it in your SparkleShare folder"); // A button that opens the synced folder Button open_folder_button = new Button(string.Format("Open {0}", System.IO.Path.GetFileName(Controller.PreviousPath))); open_folder_button.Clicked += delegate { Controller.OpenFolderClicked(); }; Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = _("What's happening next?"); Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; Button skip_tutorial_button = new Button(_("Skip Tutorial")); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = _("Sharing files with others"); Description = _("All files added to your project folders are synced automatically with " + "the host and your team members."); Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = _("The status icon is here to help"); Description = _("It shows the syncing progress, provides easy access to " + "your projects and let's you view recent changes."); Button continue_button = new Button(_("Continue")); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = _("Adding projects to SparkleShare"); Description = _("You can do this through the status icon menu, or by clicking " + "magic buttons on webpages that look like this:"); Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button(_("Finish")); finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; CheckButton check_button = new CheckButton("Add SparkleShare to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; Add(slide); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
public void CreateMenu() { this.menu = new Menu(); this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare"); folder_item.Image = new Image(SparkleUIHelpers.GetIcon("sparkleshare", 16)); this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(folder_item); if (Program.Controller.Folders.Count > 0) { int i = 0; foreach (string folder_name in Controller.Folders) { ImageMenuItem item = new SparkleMenuItem(folder_name); Gdk.Pixbuf folder_icon; if (!string.IsNullOrEmpty(Controller.FolderErrors [i])) { folder_icon = IconTheme.Default.LoadIcon("dialog-warning", 16, IconLookupFlags.GenericFallback); item.Submenu = new Menu(); MenuItem error_item = new MenuItem(Controller.FolderErrors [i]) { Sensitive = false }; MenuItem try_again_item = new MenuItem("Try Again"); try_again_item.Activated += Controller.TryAgainDelegate(folder_name); (item.Submenu as Menu).Add(error_item); (item.Submenu as Menu).Add(new SeparatorMenuItem()); (item.Submenu as Menu).Add(try_again_item); } else { folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); item.Activated += Controller.OpenFolderDelegate(folder_name); } (item.Child as Label).UseUnderline = false; item.Image = new Image(folder_icon); this.menu.Add(item); i++; } } this.recent_events_item = new MenuItem("Recent Changes…"); this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled; this.quit_item = new MenuItem("Quit") { Sensitive = Controller.QuitItemEnabled }; MenuItem add_item = new MenuItem("Add Hosted Project…"); MenuItem notify_item; if (Program.Controller.NotificationsEnabled) { notify_item = new MenuItem("Turn Notifications Off"); } else { notify_item = new MenuItem("Turn Notifications On"); } notify_item.Activated += delegate { Program.Controller.ToggleNotifications(); Application.Invoke(delegate { if (Program.Controller.NotificationsEnabled) { (notify_item.Child as Label).Text = "Turn Notifications Off"; } else { (notify_item.Child as Label).Text = "Turn Notifications On"; } }); }; MenuItem link_code_item = new MenuItem("Client ID"); if (Controller.LinkCodeItemEnabled) { link_code_item.Submenu = new Menu(); string link_code = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..."; MenuItem code_item = new MenuItem(link_code) { Sensitive = false }; MenuItem copy_item = new MenuItem("Copy to Clipboard"); copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); }; (link_code_item.Submenu as Menu).Add(code_item); (link_code_item.Submenu as Menu).Add(new SeparatorMenuItem()); (link_code_item.Submenu as Menu).Add(copy_item); } MenuItem about_item = new MenuItem("About SparkleShare"); about_item.Activated += delegate { Controller.AboutClicked(); }; add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; folder_item.Submenu = new Menu(); (folder_item.Submenu as Menu).Add(this.recent_events_item); (folder_item.Submenu as Menu).Add(add_item); (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(notify_item); (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(link_code_item); (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(about_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(this.quit_item); this.menu.ShowAll(); #if HAVE_APP_INDICATOR this.indicator.Menu = this.menu; #endif }
// Creates the menu that is popped up when the // user clicks the status icon public void CreateMenu() { Menu = new Menu(); // The menu item showing the status and size of the SparkleShare folder MenuItem status_menu_item = new MenuItem(StateText) { Sensitive = false }; Menu.Add(status_menu_item); Menu.Add(new SeparatorMenuItem()); ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare") { Image = new Image(SparkleUIHelpers.GetIcon("folder-sparkleshare", 16)) }; folder_item.Activated += delegate { SparkleShare.Controller.OpenSparkleShareFolder(); }; Menu.Add(folder_item); if (SparkleShare.Controller.Folders.Count > 0) { // Creates a menu item for each repository with a link to their logs foreach (string path in SparkleShare.Controller.Folders) { Gdk.Pixbuf folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); ImageMenuItem subfolder_item = new SparkleMenuItem(Path.GetFileName(path)) { Image = new Image(folder_icon) }; // if (repo.HasUnsyncedChanges) // folder_action.IconName = "dialog-error"; subfolder_item.Activated += OpenEventLogDelegate(path); Menu.Add(subfolder_item); } } else { MenuItem no_folders_item = new MenuItem(_("No Remote Folders Yet")) { Sensitive = false }; Menu.Add(no_folders_item); } // Opens the wizard to add a new remote folder MenuItem sync_item = new MenuItem(_("Add Remote Folder…")); if (SparkleShare.Controller.FirstRun) { sync_item.Sensitive = false; } sync_item.Activated += delegate { Application.Invoke(delegate { if (SparkleUI.Intro == null) { SparkleUI.Intro = new SparkleIntro(); SparkleUI.Intro.ShowServerForm(true); } if (!SparkleUI.Intro.Visible) { SparkleUI.Intro.ShowServerForm(true); } SparkleUI.Intro.ShowAll(); SparkleUI.Intro.Present(); }); }; Menu.Add(sync_item); Menu.Add(new SeparatorMenuItem()); MenuItem notify_item; if (SparkleShare.Controller.NotificationsEnabled) { notify_item = new MenuItem(_("Turn Notifications Off")); } else { notify_item = new MenuItem(_("Turn Notifications On")); } notify_item.Activated += delegate { SparkleShare.Controller.ToggleNotifications(); CreateMenu(); }; Menu.Add(notify_item); Menu.Add(new SeparatorMenuItem()); // A menu item that takes the user to http://www.sparkleshare.org/ MenuItem about_item = new MenuItem(_("About SparkleShare")); about_item.Activated += delegate { SparkleAbout about = new SparkleAbout(); about.ShowAll(); }; Menu.Add(about_item); Menu.Add(new SeparatorMenuItem()); // A menu item that quits the application MenuItem quit_item = new MenuItem(_("Quit")); quit_item.Activated += delegate { SparkleShare.Controller.Quit(); }; Menu.Add(quit_item); Menu.ShowAll(); }
public SparkleStatusIcon() { CreateAnimationFrames(); #if HAVE_APP_INDICATOR this.indicator = new ApplicationIndicator("sparkleshare", "process-syncing-sparkleshare-i", Category.ApplicationStatus); this.indicator.Status = Status.Attention; #else this.status_icon = new StatusIcon(); this.status_icon.Pixbuf = this.animation_frames [0]; this.status_icon.Activate += ShowMenu; // Primary mouse button click this.status_icon.PopupMenu += ShowMenu; // Secondary mouse button click #endif CreateMenu(); Controller.UpdateIconEvent += delegate(int icon_frame) { Application.Invoke(delegate { if (icon_frame > -1) { #if HAVE_APP_INDICATOR string icon_name = "process-syncing-sparkleshare-"; for (int i = 0; i <= icon_frame; i++) { icon_name += "i"; } this.indicator.IconName = icon_name; #else this.status_icon.Pixbuf = this.animation_frames [icon_frame]; #endif } else { #if HAVE_APP_INDICATOR this.indicator.IconName = "sparkleshare-syncing-error"; #else this.status_icon.Pixbuf = SparkleUIHelpers.GetIcon("sparkleshare-syncing-error", 24); #endif } }); }; Controller.UpdateStatusItemEvent += delegate(string state_text) { Application.Invoke(delegate { (this.state_item.Child as Label).Text = state_text; this.state_item.ShowAll(); }); }; Controller.UpdateQuitItemEvent += delegate(bool item_enabled) { Application.Invoke(delegate { this.quit_item.Sensitive = item_enabled; this.quit_item.ShowAll(); }); }; Controller.UpdateOpenRecentEventsItemEvent += delegate(bool item_enabled) { Application.Invoke(delegate { this.recent_events_item.Sensitive = item_enabled; this.recent_events_item.ShowAll(); }); }; Controller.UpdateMenuEvent += delegate(IconState state) { Application.Invoke(delegate { CreateMenu(); }); }; }
public void CreateMenu() { this.menu = new Menu(); this.state_item = new MenuItem(Controller.StateText) { Sensitive = false }; ImageMenuItem folder_item = new SparkleMenuItem("SparkleShare"); folder_item.Image = new Image(SparkleUIHelpers.GetIcon("sparkleshare", 16)); this.menu.Add(this.state_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(folder_item); this.state_menu_items = new SparkleMenuItem [Controller.Projects.Length]; if (Controller.Projects.Length > 0) { int i = 0; foreach (ProjectInfo project in Controller.Projects) { SparkleMenuItem item = new SparkleMenuItem(project.Name); Gdk.Pixbuf folder_icon; folder_icon = IconTheme.Default.LoadIcon("folder", 16, IconLookupFlags.GenericFallback); item.Submenu = new Menu(); this.state_menu_items [i] = new MenuItem(project.StatusMessage) { Sensitive = false }; (item.Submenu as Menu).Add(this.state_menu_items [i]); (item.Submenu as Menu).Add(new SeparatorMenuItem()); if (project.IsPaused) { MenuItem resume_item; if (project.UnsyncedChangesInfo.Count > 0) { string icons_path = new string [] { SparkleUI.AssetsPath, "icons", "hicolor", "12x12", "status" }.Combine(); foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo) { (item.Submenu as Menu).Add(new MenuItem(pair.Key) { Image = new Image() { File = new string [] { icons_path, pair.Value.Replace("-12", "") }.Combine() }, Sensitive = false }); } if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) { (item.Submenu as Menu).Add(new MenuItem(MoreUnsyncedChanges) { Sensitive = false }); } (item.Submenu as Menu).Add(new SeparatorMenuItem()); resume_item = new MenuItem("Sync and Resume…"); } else { resume_item = new MenuItem("Resume"); } resume_item.Activated += Controller.ResumeDelegate(project.Name); (item.Submenu as Menu).Add(resume_item); } else { if (Controller.Projects [i].HasError) { folder_icon = IconTheme.Default.LoadIcon("dialog-warning", 16, IconLookupFlags.GenericFallback); MenuItem try_again_item = new MenuItem("Try Again"); try_again_item.Activated += Controller.TryAgainDelegate(project.Name); (item.Submenu as Menu).Add(try_again_item); } else { MenuItem pause_item = new MenuItem("Pause"); pause_item.Activated += Controller.PauseDelegate(project.Name); (item.Submenu as Menu).Add(pause_item); } } (item.Child as Label).UseUnderline = false; item.Image = new Image(folder_icon); this.menu.Add(item); i++; } ; } this.recent_events_item = new MenuItem("Recent Changes…"); this.recent_events_item.Sensitive = Controller.RecentEventsItemEnabled; this.quit_item = new MenuItem("Quit") { Sensitive = Controller.QuitItemEnabled }; MenuItem add_item = new MenuItem("Add Hosted Project…"); #if HAVE_APP_INDICATOR MenuItem notify_item; if (Program.Controller.NotificationsEnabled) { notify_item = new MenuItem("Turn Notifications Off"); } else { notify_item = new MenuItem("Turn Notifications On"); } notify_item.Activated += delegate { Program.Controller.ToggleNotifications(); Application.Invoke(delegate { if (Program.Controller.NotificationsEnabled) { (notify_item.Child as Label).Text = "Turn Notifications Off"; } else { (notify_item.Child as Label).Text = "Turn Notifications On"; } }); }; #endif MenuItem link_code_item = new MenuItem("Client ID"); if (Controller.LinkCodeItemEnabled) { link_code_item.Submenu = new Menu(); string link_code = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..."; MenuItem code_item = new MenuItem(link_code) { Sensitive = false }; MenuItem copy_item = new MenuItem("Copy to Clipboard"); copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); }; (link_code_item.Submenu as Menu).Add(code_item); (link_code_item.Submenu as Menu).Add(new SeparatorMenuItem()); (link_code_item.Submenu as Menu).Add(copy_item); } MenuItem about_item = new MenuItem("About SparkleShare"); about_item.Activated += delegate { Controller.AboutClicked(); }; add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; folder_item.Submenu = new Menu(); (folder_item.Submenu as Menu).Add(this.recent_events_item); (folder_item.Submenu as Menu).Add(add_item); #if HAVE_APP_INDICATOR (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(notify_item); #endif (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(link_code_item); (folder_item.Submenu as Menu).Add(new SeparatorMenuItem()); (folder_item.Submenu as Menu).Add(about_item); this.menu.Add(new SeparatorMenuItem()); this.menu.Add(this.quit_item); this.menu.ShowAll(); #if HAVE_APP_INDICATOR this.indicator.Menu = this.menu; #endif }
public void ShowPage(PageType type, string [] warnings) { if (type == PageType.Setup) { Header = "Welcome to SparkleShare!"; Description = "First off, what’s your name and email?\n(visible only to team members)"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; try { UnixUserInfo user_info = UnixUserInfo.GetRealUser(); if (user_info != null && user_info.RealName != null) { // Some systems append a series of "," for some reason name_entry.Text = user_info.RealName.TrimEnd(",".ToCharArray()); } } catch (ArgumentException) { // No username, not a big deal } Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); Button continue_button = new Button("Continue") { Sensitive = false }; Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; name_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; email_entry.Changed += delegate { Controller.CheckSetupPage(name_entry.Text, email_entry.Text); }; cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; continue_button.Clicked += delegate { Controller.SetupPageCompleted(name_entry.Text, email_entry.Text); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.CheckSetupPage(name_entry.Text, email_entry.Text); if (name_entry.Text.Equals("")) { name_entry.GrabFocus(); } else { email_entry.GrabFocus(); } } if (type == PageType.Add) { Header = "Where’s your project hosted?"; VBox layout_vertical = new VBox(false, 16); HBox layout_fields = new HBox(true, 32); VBox layout_address = new VBox(true, 0); VBox layout_path = new VBox(true, 0); ListStore store = new ListStore(typeof(string), typeof(Gdk.Pixbuf), typeof(string), typeof(SparklePlugin)); SparkleTreeView tree_view = new SparkleTreeView(store) { HeadersVisible = false }; ScrolledWindow scrolled_window = new ScrolledWindow() { ShadowType = ShadowType.In }; scrolled_window.SetPolicy(PolicyType.Never, PolicyType.Automatic); // Padding column tree_view.AppendColumn("Padding", new Gtk.CellRendererText(), "text", 0); tree_view.Columns [0].Cells [0].Xpad = 4; // Icon column tree_view.AppendColumn("Icon", new Gtk.CellRendererPixbuf(), "pixbuf", 1); tree_view.Columns [1].Cells [0].Xpad = 4; // Service column TreeViewColumn service_column = new TreeViewColumn() { Title = "Service" }; CellRendererText service_cell = new CellRendererText() { Ypad = 8 }; service_column.PackStart(service_cell, true); service_column.SetCellDataFunc(service_cell, new TreeCellDataFunc(RenderServiceColumn)); foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues("", new Gdk.Pixbuf(plugin.ImagePath), "<span size=\"small\"><b>" + plugin.Name + "</b>\n" + "<span fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + plugin.Description + "</span>" + "</span>", plugin); } tree_view.AppendColumn(service_column); scrolled_window.Add(tree_view); Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Entry path_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; TreeSelection default_selection = tree_view.Selection; TreePath default_path = new TreePath("" + Controller.SelectedPluginIndex); default_selection.SelectPath(default_path); tree_view.Model.Foreach(new TreeModelForeachFunc( delegate(ITreeModel model, TreePath path, TreeIter iter) { string address; try { address = (model.GetValue(iter, 2) as SparklePlugin).Address; } catch (NullReferenceException) { address = ""; } if (!string.IsNullOrEmpty(address) && address.Equals(Controller.PreviousAddress)) { tree_view.SetCursor(path, service_column, false); SparklePlugin plugin = (SparklePlugin)model.GetValue(iter, 2); if (plugin.Address != null) { address_entry.Sensitive = false; } if (plugin.Path != null) { path_entry.Sensitive = false; } return(true); } else { return(false); } } )); layout_address.PackStart(new Label() { Markup = "<b>" + "Address" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); path_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_address, true, true, 0); layout_fields.PackStart(layout_path, true, true, 0); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(scrolled_window, true, true, 0); layout_vertical.PackStart(layout_fields, false, false, 0); tree_view.ScrollToCell(new TreePath("" + Controller.SelectedPluginIndex), null, true, 0, 0); Add(layout_vertical); if (string.IsNullOrEmpty(path_entry.Text)) { address_entry.GrabFocus(); address_entry.Position = -1; } else { path_entry.GrabFocus(); path_entry.Position = -1; } Button cancel_button = new Button("Cancel"); Button add_button = new Button("Add") { Sensitive = false }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + Program.UI.SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; tree_view.CursorChanged += delegate(object sender, EventArgs e) { Controller.SelectedPluginChanged(tree_view.SelectedRow); }; address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text, path_entry.Text, tree_view.SelectedRow); }; cancel_button.Clicked += delegate { Controller.PageCancelled(); }; add_button.Clicked += delegate { Controller.AddPageCompleted(address_entry.Text, path_entry.Text); }; CheckButton check_button = new CheckButton("Fetch prior revisions") { Active = true }; check_button.Toggled += delegate { Controller.HistoryItemChanged(check_button.Active); }; AddOption(check_button); AddButton(cancel_button); AddButton(add_button); Controller.HistoryItemChanged(check_button.Active); Controller.CheckAddPage(address_entry.Text, path_entry.Text, 1); } if (type == PageType.Invite) { Header = "You’ve received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); Button add_button = new Button("Add"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); } if (type == PageType.Syncing) { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may take a while for large projects.\nIsn’t it coffee-o’clock?"; ProgressBar progress_bar = new ProgressBar(); progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button cancel_button = new Button() { Label = "Cancel" }; Button finish_button = new Button("Finish") { Sensitive = false }; Label progress_label = new Label("Preparing to fetch files…") { Justify = Justification.Right, Xalign = 1 }; Controller.UpdateProgressBarEvent += delegate(double percentage, string speed) { Application.Invoke(delegate { progress_bar.Fraction = percentage / 100; progress_label.Text = speed; }); }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(progress_bar, false, false, 21); bar_wrapper.PackStart(progress_label, false, true, 0); Add(bar_wrapper); AddButton(cancel_button); AddButton(finish_button); } if (type == PageType.Error) { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("list-point", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we’ve compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Is this computer’s Client ID known by the host?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here’s the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); Button try_again_button = new Button("Try Again…") { Sensitive = true }; cancel_button.Clicked += delegate { Controller.PageCancelled(); }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); } if (type == PageType.CryptoSetup || type == PageType.CryptoPassword) { if (type == PageType.CryptoSetup) { Header = "Set up file encryption"; Description = "Please a provide a strong password that you don’t use elsewhere."; } else { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; } Label password_label = new Label("<b>" + "Password" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24)); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can’t be changed later, and your files can’t be recovered if it’s forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); if (type == PageType.CryptoSetup) { wrapper.PackStart(warning_wrapper, false, false, 0); } Button cancel_button = new Button("Cancel"); Button continue_button = new Button("Continue") { Sensitive = false }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { if (type == PageType.CryptoSetup) { Controller.CheckCryptoSetupPage(password_entry.Text); } else { Controller.CheckCryptoPasswordPage(password_entry.Text); } }; cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; continue_button.Clicked += delegate { if (type == PageType.CryptoSetup) { Controller.CryptoSetupPageCompleted(password_entry.Text); } else { Controller.CryptoPasswordPageCompleted(password_entry.Text); } }; Add(wrapper); AddButton(cancel_button); AddButton(continue_button); password_entry.GrabFocus(); } if (type == PageType.Finished) { Header = "Your shared project is ready!"; Description = "You can find the files in your SparkleShare folder."; UrgencyHint = true; Button show_files_button = new Button("Show Files…"); Button finish_button = new Button("Finish"); show_files_button.Clicked += delegate { Controller.ShowFilesClicked(); }; finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image(SparkleUIHelpers.GetIcon("dialog-information", 24)); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(show_files_button); AddButton(finish_button); } if (type == PageType.Tutorial) { switch (Controller.TutorialPageNumber) { case 1: { Header = "What’s happening next?"; Description = "SparkleShare creates a special folder on your computer " + "that will keep track of your projects."; Button skip_tutorial_button = new Button("Skip Tutorial"); Button continue_button = new Button("Continue"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to your project folders are synced automatically with " + "the host and your team members."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; AddButton(continue_button); break; } case 3: { Header = "The status icon helps you"; Description = "It shows the syncing progress, provides easy access to " + "your projects, and lets you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; AddButton(continue_button); break; } case 4: { Header = "Here’s your unique Client ID"; Description = "You’ll need it whenever you want to link this computer to a host. " + "You can also find it in the status icon menu."; Button finish_button = new Button("Finish"); VBox layout_vertical = new VBox(false, 0) { BorderWidth = 48 }; HBox layout_horizontal = new HBox(false, 6); Entry link_code_entry = new Entry() { Text = Program.Controller.CurrentUser.PublicKey, Sensitive = false }; Button copy_button = new Button(" Copy "); CheckButton check_button = new CheckButton("Add SparkleShare to startup items"); check_button.Active = true; copy_button.Clicked += delegate { Controller.CopyToClipboardClicked(); }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; layout_horizontal.PackStart(link_code_entry, true, true, 0); layout_horizontal.PackStart(copy_button, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 0); layout_vertical.PackStart(layout_horizontal, false, false, 0); layout_vertical.PackStart(new Label(""), true, true, 18); Add(layout_vertical); AddOption(check_button); AddButton(finish_button); break; } } if (Controller.TutorialPageNumber < 4) { Image slide = SparkleUIHelpers.GetImage("tutorial-slide-" + Controller.TutorialPageNumber + ".png"); Add(slide); } } }