Пример #1
0
        public MainClass(bool debug, string appName)
        {
            GLibLogging.Enabled = true;

            Assembly exe = typeof (MainClass).Assembly;

            string configDir = Path.GetFullPath (Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), appName));
            string lockFile = Path.Combine (configDir, "pid.lock");

            bool instanceRunning = DetectInstances (lockFile, appName);
            if (instanceRunning) {
                Gtk.Application.Init ();

                Gtk.MessageDialog md = new Gtk.MessageDialog (null, Gtk.DialogFlags.Modal, Gtk.MessageType.Warning, Gtk.ButtonsType.Close,
                    GettextCatalog.GetString ("An instance of StrongMonkey with configuration profile '{0}' is already running.{1}If you really want to run 2 seperate instances, use the \"--appName=StrongMonkeyXXX\" command line parameter",
                        appName, Environment.NewLine));
                md.Run ();
                md.Destroy ();
                md.Dispose ();

                md.Close += delegate(object sender, EventArgs e) {
                    Gtk.Application.Quit ();
                };

                Gtk.Application.Run ();
            } else {
                CoreUtility.Initialize (exe, appName, debug);
                WriteInstancePid (lockFile);

                AddinUtility.Initialize ();
            }
        }
Пример #2
0
        public DialogResult ShowDialog(Control parent)
        {
            Gtk.Window parentWindow = null;
            if (parent != null && parent.ParentWindow != null)
            {
                parentWindow = parent.ParentWindow.ControlObject as Gtk.Window;
            }

            control          = new Gtk.MessageDialog(parentWindow, Gtk.DialogFlags.Modal, Type.ToGtk(), Buttons.ToGtk(), false, string.Empty);
            control.Text     = Text;
            control.TypeHint = Gdk.WindowTypeHint.Dialog;
            var caption = Caption ?? ((parent != null && parent.ParentWindow != null) ? parent.ParentWindow.Title : null);

            if (!string.IsNullOrEmpty(caption))
            {
                control.Title = caption;
            }
            // must add buttons manually for this case
            if (Buttons == MessageBoxButtons.YesNoCancel)
            {
                var bn = (Gtk.Button)control.AddButton(Gtk.Stock.No, (int)Gtk.ResponseType.No);
                bn.UseStock = true;
                var bc = (Gtk.Button)control.AddButton(Gtk.Stock.Cancel, (int)Gtk.ResponseType.Cancel);
                bc.UseStock = true;
                var by = (Gtk.Button)control.AddButton(Gtk.Stock.Yes, (int)Gtk.ResponseType.Yes);
                by.UseStock = true;
            }
            control.DefaultResponse = DefaultButton.ToGtk(Buttons);
            int ret = control.Run();

            control.Hide();
#if GTKCORE
            control.Dispose();
#else
            control.Destroy();
#endif
            var result = ((Gtk.ResponseType)ret).ToEto();
            if (result == DialogResult.None)
            {
                switch (Buttons)
                {
                case MessageBoxButtons.OK:
                    result = DialogResult.Ok;
                    break;

                case MessageBoxButtons.YesNo:
                    result = DialogResult.No;
                    break;

                case MessageBoxButtons.OKCancel:
                case MessageBoxButtons.YesNoCancel:
                    result = DialogResult.Cancel;
                    break;
                }
            }
            return(result);
        }
Пример #3
0
        private void DoCancel()
        {
            m_parser.Cancel = true;
            this.Hide();
            String message = Catalog.GetString("Import cancelled, all changes reverted.");

            Gtk.MessageDialog dlg = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                          Gtk.ButtonsType.Ok, message);
            dlg.Run();
            dlg.Hide();
            dlg.Dispose();
        }
Пример #4
0
        private bool validateEntry()
        {
            if (String.IsNullOrEmpty(nameEntry.Text))
            {
                Gtk.MessageDialog msg = new Gtk.MessageDialog(this, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              "The name field is required.");
                msg.Run();
                msg.Hide();
                msg.Dispose();
                return(false);
            }

            /*if (!locationWidget.Latitude.ValidateEntry())
             *      return false;
             * if (!locationWidget.Longitude.ValidateEntry())
             *      return false;*/
            return(true);
        }
Пример #5
0
        public bool ValidateEntry()
        {
            try
            {
                int    degrees = int.Parse(degreeEntry.Text, CultureInfo.InvariantCulture);
                double minutes = double.Parse(minuteEntry.Text, CultureInfo.InvariantCulture);

                if (degrees < 0 || minutes < 0)
                {
                    throw new Exception();
                }
                return(true);
            }
            catch (Exception)
            {
                Gtk.MessageDialog dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              Catalog.GetString("Invalid Coordinate"));
                dlg.Run();
                dlg.Hide();
                dlg.Dispose();
                return(false);
            }
        }
Пример #6
0
 private bool validateEntry()
 {
     if (String.IsNullOrEmpty(nameEntry.Text))
     {
         Gtk.MessageDialog msg = new Gtk.MessageDialog(this, Gtk.DialogFlags.DestroyWithParent,
                                                       Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                       "The name field is required.");
         msg.Run();
         msg.Hide();
         msg.Dispose();
         return false;
     }
     /*if (!locationWidget.Latitude.ValidateEntry())
         return false;
     if (!locationWidget.Longitude.ValidateEntry())
         return false;*/
     return true;
 }
Пример #7
0
 private void DoCancel()
 {
     m_parser.Cancel = true;
     this.Hide ();
     String message = Catalog.GetString("Import cancelled, all changes reverted.");
     Gtk.MessageDialog dlg = new Gtk.MessageDialog (this, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                                    Gtk.ButtonsType.Ok, message);
     dlg.Run ();
     dlg.Hide ();
     dlg.Dispose ();
 }
        public bool ValidateEntry()
        {
            try
            {
                int degrees = int.Parse(degreeEntry.Text, CultureInfo.InvariantCulture);
                double minutes = double.Parse(minuteEntry.Text, CultureInfo.InvariantCulture);

                if (degrees < 0 || minutes < 0)
                    throw new Exception();
                return true;
            }
            catch (Exception)
            {
                Gtk.MessageDialog dlg = new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                                              Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                                              Catalog.GetString("Invalid Coordinate"));
                dlg.Run();
                dlg.Hide();
                dlg.Dispose();
                return false;
            }
        }