private void browseButton_clicked(object o, EventArgs args) { FileSelector selector = new FileSelector("Select Image"); selector.Show(); int result = selector.Run(); if (result == (int)Gtk.ResponseType.Ok) { try { AddFile(selector.Filename); } catch (Exception ex) { selector.Hide(); Gui.ShowMessageDialog(ex.Message); return; } } selector.Hide(); }
public static bool QuitMeshwork() { try { int result = Gui.ShowMessageDialog("Are you sure you want to quit Meshwork?", Gui.MainWindow.Window, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo); if (result == (int)ResponseType.Yes) { Gui.Settings.SaveSettings(); Core.Stop(); Gtk.Application.Quit(); Environment.Exit(0); return(true); } else { return(false); } } catch (Exception ex) { LoggingService.LogError(ex); throw ex; } }
public static PrivateChatSubpage StartPrivateChat(Network network, Node node, bool focus) { if (node == null) { throw new ArgumentNullException("node"); } if (Runtime.Core.IsLocalNode(node)) { Gui.ShowErrorDialog("You cannot send messages to yourself!"); return(null); } else if (node.FinishedKeyExchange == true) { PrivateChatSubpage page; if (privateMessageWindows.ContainsKey(network.NetworkID + node.NodeID) == false) { page = new PrivateChatSubpage(network, node); privateMessageWindows[network.NetworkID + node.NodeID] = page; ChatsPage.Instance.AddPrivateChatSubpage(page); } else { page = (PrivateChatSubpage)privateMessageWindows[network.NetworkID + node.NodeID]; } if (focus) { Gui.MainWindow.SelectedPage = ChatsPage.Instance; page.GrabFocus(); } return(page); } else { Gui.ShowErrorDialog("You cannot send messages to untrusted nodes."); return(null); } }
public static void Main(string[] args) { /* Initialize our catalog */ // Catalog.Init (Defines.Name, Defines.LocaleDir); /* Process our args */ options = new GtkMeshworkOptions(); options.ProcessArgs(args); getPlatform().SetProcessName("meshwork-gtk"); /* Initialize the GTK application */ Gtk.Application.Init(); if (!System.Diagnostics.Debugger.IsAttached) { /* If we crash, attempt to log the error */ GLib.ExceptionManager.UnhandledException += UnhandledGLibExceptionHandler; AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; } //XXX: Implement Gunique code here! splashWindow = new SplashWindow(); splashWindow.Show(); /* Load settings */ if (options.ConfigPath != null) { LoggingService.LogDebug("Using config dir: " + options.ConfigPath); Settings.OverrideConfigPath(options.ConfigPath); } tmpSettings = Settings.ReadSettings(); // First run, create initial settings. if (tmpSettings == null) { tmpSettings = new Settings { // FIXME // NickName = core.Platform.UserName, // RealName = core.Platform.RealName, IncompleteDownloadDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), CompletedDownloadDir = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) }; tmpSettings.FirstRun = true; } /* Load Icons */ Gtk.Window.DefaultIconList = new Gdk.Pixbuf[] { new Gdk.Pixbuf(null, "Meshwork.Client.GtkClient.tray_icon.png") }; // Windows specific. Override stock icons to use embeded files. var sizes = new [] { 16, 22, 24, 34 }; var iconNames = new[] { "application-exit", "application-x-executable", "audio-x-generic", "computer", "dialog-error", "dialog-information", "dialog-password", "gtk-preferences", "dialog-question", "dialog-warning", "folder", "go-down", "go-home", "go-next", "go-previous", "go-up", "image-x-generic", "internet-group-chat", "list-add", "list-remove", "mail-attachment", "mail_generic", "mail-message-new", "mail-signed-verified", "network-transmit-receive", "stock_channel", "stock_internet", "system-search", "text-x-generic", "user-home", "video-x-generic", "view-refresh", "x-office-document" }; foreach (var size in sizes) { foreach (var iconName in iconNames) { if (Environment.OSVersion.Platform != PlatformID.Unix || !IconTheme.Default.HasIcon(iconName) || !IconTheme.Default.GetIconSizes(iconName).Contains(size)) { var pixbuf = Gui.LoadIconFromResource(iconName, size); if (pixbuf != null) { Gtk.IconTheme.AddBuiltinIcon(iconName, size, pixbuf); } else { LoggingService.LogWarning("Missing embeded icon: {0} ({1}x{1})", iconName, size); } } } } /* Start the event loop */ GLib.Idle.Add(new GLib.IdleHandler(FinishLoading)); Gtk.Application.Run(); }