예제 #1
0
        public Dialog(string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
        {
            if (GetType() != typeof(Dialog))
            {
                GLib.Value[] vals  = new GLib.Value [1];
                string[]     names = new string [1];
                names [0] = "title";
                vals [0]  = new GLib.Value(title);
                CreateNativeObject(names, vals);
                TransientFor = parent;
                if ((flags & DialogFlags.Modal) > 0)
                {
                    Modal = true;
                }
                if ((flags & DialogFlags.DestroyWithParent) > 0)
                {
                    DestroyWithParent = true;
                }
            }
            else
            {
                IntPtr native = GLib.Marshaller.StringToPtrGStrdup(title);
                Raw = gtk_dialog_new_with_buttons(native, parent == null ? IntPtr.Zero : parent.Handle, (int)flags, IntPtr.Zero);
                GLib.Marshaller.Free(native);
            }

            for (int i = 0; i < button_data.Length - 1; i += 2)
            {
                AddButton((string)button_data [i], (int)button_data [i + 1]);
            }
        }
예제 #2
0
 // constructor for a HIG confirmation alert with two buttons
 public HigMessageDialog(Gtk.Window parent,
                         Gtk.DialogFlags flags,
                         Gtk.MessageType type,
                         string header,
                         string msg,
                         string ok_caption)
     : this(parent, flags, type, Gtk.ButtonsType.Cancel, header, msg)
 {
     AddButton(ok_caption, Gtk.ResponseType.Ok, false);
 }
예제 #3
0
    public static Gtk.ResponseType  Show(Gtk.Window window, Gtk.DialogFlags dialogflags,
                                         MessageType msgType, ButtonsType btnType, string Message, String caption)
    {
        MessageDialog md = new MessageDialog(window, dialogflags, msgType, btnType, Message);

        md.Title = caption;
        ResponseType tp = (Gtk.ResponseType)md.Run();

        md.Destroy();
        return(tp);
    }            //end  Show
예제 #4
0
        public Dialog(string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
        {
            IntPtr native = GLib.Marshaller.StringToPtrGStrdup(title);

            Raw = gtk_dialog_new_with_buttons(native, parent == null ? IntPtr.Zero : parent.Handle, (int)flags, IntPtr.Zero);
            GLib.Marshaller.Free(native);

            for (int i = 0; i < button_data.Length - 1; i += 2)
            {
                AddButton((string)button_data [i], (int)button_data [i + 1]);
            }
        }
예제 #5
0
        //Run and destroy a standard confirmation dialog
        public static Gtk.ResponseType RunHigConfirmation(Gtk.Window parent,
                                                          Gtk.DialogFlags flags,
                                                          Gtk.MessageType type,
                                                          string header,
                                                          string msg,
                                                          string ok_caption)
        {
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, header, msg, ok_caption);

            try {
                return((Gtk.ResponseType)hmd.Run());
            } finally {
                hmd.Destroy();
            }
        }
예제 #6
0
        //run and destroy a standard dialog
        public static Gtk.ResponseType RunHigMessageDialog(Gtk.Window parent,
                                                           Gtk.DialogFlags flags,
                                                           Gtk.MessageType type,
                                                           Gtk.ButtonsType buttons,
                                                           string header,
                                                           string msg)
        {
            HigMessageDialog hmd = new HigMessageDialog(parent, flags, type, buttons, header, msg);

            try {
                return((Gtk.ResponseType)hmd.Run());
            } finally {
                hmd.Destroy();
            }
        }
예제 #7
0
        public CreateNotebookDialog(Gtk.Window parent,
                                    Gtk.DialogFlags flags)
            : base(parent, flags, Gtk.MessageType.Info,
                   Gtk.ButtonsType.None,
                   Catalog.GetString("Create a new notebook"),
                   Catalog.GetString("Type the name of the notebook you'd like to create."))
        {
            this.Pixbuf = newNotebookIconDialog;

            Gtk.Table table = new Gtk.Table(2, 2, false);

            Gtk.Label label = new Gtk.Label(Catalog.GetString("N_otebook name:"));
            label.Xalign       = 0;
            label.UseUnderline = true;
            label.Show();

            nameEntry                  = new Gtk.Entry();
            nameEntry.Changed         += OnNameEntryChanged;
            nameEntry.ActivatesDefault = true;
            nameEntry.Show();
            label.MnemonicWidget = nameEntry;

            errorLabel        = new Gtk.Label();
            errorLabel.Xalign = 0;
            errorLabel.Markup = string.Format("<span foreground='red' style='italic'>{0}</span>",
                                              Catalog.GetString("Name already taken"));

            table.Attach(label, 0, 1, 0, 1);
            table.Attach(nameEntry, 1, 2, 0, 1);
            table.Attach(errorLabel, 1, 2, 1, 2);
            table.Show();

            ExtraWidget = table;

            AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
            AddButton(
                newNotebookIcon,
                // Translation note: This is the Create button in the Create
                // New Note Dialog.
                Catalog.GetString("C_reate"),
                Gtk.ResponseType.Ok,
                true);

            // Only let the Ok response be sensitive when
            // there's something in nameEntry
            SetResponseSensitive(Gtk.ResponseType.Ok, false);
            errorLabel.Hide();
        }
 public AppChooserDialog(Gtk.Window parent, Gtk.DialogFlags flags, GLib.IFile file) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(AppChooserDialog))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (parent != null)
         {
             names.Add("parent");
             vals.Add(new GLib.Value(parent));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_app_chooser_dialog_new(parent == null ? IntPtr.Zero : parent.Handle, (int)flags, file == null ? IntPtr.Zero : ((file is GLib.Object) ? (file as GLib.Object).Handle : (file as GLib.FileAdapter).Handle));
 }
        public AppChooserDialog(Gtk.Window parent, Gtk.DialogFlags flags, string content_type) : base(IntPtr.Zero)
        {
            if (GetType() != typeof(AppChooserDialog))
            {
                var vals  = new List <GLib.Value> ();
                var names = new List <string> ();
                if (parent != null)
                {
                    names.Add("parent");
                    vals.Add(new GLib.Value(parent));
                }
                CreateNativeObject(names.ToArray(), vals.ToArray());
                return;
            }
            IntPtr native_content_type = GLib.Marshaller.StringToPtrGStrdup(content_type);

            Raw = gtk_app_chooser_dialog_new_for_content_type(parent == null ? IntPtr.Zero : parent.Handle, (int)flags, native_content_type);
            GLib.Marshaller.Free(native_content_type);
        }
예제 #10
0
        public HigMessageDialog(Gtk.Window parent,
                                Gtk.DialogFlags flags,
                                Gtk.MessageType type,
                                Gtk.ButtonsType buttons,
                                string header,
                                string msg)
            : base()
        {
            BorderWidth     = 5;
            Resizable       = false;
            Title           = "";
            SkipTaskbarHint = true;

            ContentArea.Spacing = 12;
            ActionArea.Layout   = Gtk.ButtonBoxStyle.End;

            Gtk.HBox hbox = new Gtk.HBox(false, 12);
            hbox.BorderWidth = 5;
            hbox.Show();
            ContentArea.PackStart(hbox, false, false, 0);

            image = null;

            switch (type)
            {
            case Gtk.MessageType.Error:
                image = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Question:
                image = new Gtk.Image(Gtk.Stock.DialogQuestion, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Info:
                image = new Gtk.Image(Gtk.Stock.DialogInfo, Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Warning:
                image = new Gtk.Image(Gtk.Stock.DialogWarning, Gtk.IconSize.Dialog);
                break;
            }

            image.Yalign = 0.1f;
            image.Show();
            hbox.PackStart(image, false, false, 0);

            inner_vbox = new Gtk.VBox(false, 12);
            inner_vbox.Show();
            hbox.PackStart(inner_vbox, true, true, 0);

            label_vbox = new Gtk.VBox(false, 0);
            label_vbox.Show();
            inner_vbox.PackStart(label_vbox, true, true, 0);

            string title = String.Format("<span weight='bold' size='larger'>{0}" +
                                         "</span>\n",
                                         GLib.Markup.EscapeText(header));

            Gtk.Label label;

            label           = new Gtk.Label(title);
            label.UseMarkup = true;
            label.Justify   = Gtk.Justification.Left;
            label.LineWrap  = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            message_label  = label = new Gtk.Label();
            label.Text     = msg;
            label.Justify  = Gtk.Justification.Left;
            label.LineWrap = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            switch (buttons)
            {
            case Gtk.ButtonsType.None:
                break;

            case Gtk.ButtonsType.Ok:
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;

            case Gtk.ButtonsType.Close:
                AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close, true);
                break;

            case Gtk.ButtonsType.Cancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
                break;

            case Gtk.ButtonsType.YesNo:
                AddButton(Gtk.Stock.No, Gtk.ResponseType.No, false);
                AddButton(Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
                break;

            case Gtk.ButtonsType.OkCancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;
            }

            if (parent != null)
            {
                TransientFor = parent;
            }

            if ((int)(flags & Gtk.DialogFlags.Modal) != 0)
            {
                Modal = true;
            }

            if ((int)(flags & Gtk.DialogFlags.DestroyWithParent) != 0)
            {
                DestroyWithParent = true;
            }
        }
예제 #11
0
파일: Utils.cs 프로젝트: thioshp/tomboy
        public HIGMessageDialog(Gtk.Window parent,
                                Gtk.DialogFlags flags,
                                Gtk.MessageType type,
                                Gtk.ButtonsType buttons,
                                string header,
                                string msg)
            : base()
        {
            HasSeparator = false;
            BorderWidth  = 5;
            Resizable    = false;
            Title        = "";

            VBox.Spacing      = 12;
            ActionArea.Layout = Gtk.ButtonBoxStyle.End;

            accel_group = new Gtk.AccelGroup();
            AddAccelGroup(accel_group);

            Gtk.HBox hbox = new Gtk.HBox(false, 12);
            hbox.BorderWidth = 5;
            hbox.Show();
            VBox.PackStart(hbox, false, false, 0);

            switch (type)
            {
            case Gtk.MessageType.Error:
                image = new Gtk.Image(Gtk.Stock.DialogError,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Question:
                image = new Gtk.Image(Gtk.Stock.DialogQuestion,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Info:
                image = new Gtk.Image(Gtk.Stock.DialogInfo,
                                      Gtk.IconSize.Dialog);
                break;

            case Gtk.MessageType.Warning:
                image = new Gtk.Image(Gtk.Stock.DialogWarning,
                                      Gtk.IconSize.Dialog);
                break;

            default:
                image = new Gtk.Image();
                break;
            }

            if (image != null)
            {
                image.Show();
                image.Yalign = 0;
                hbox.PackStart(image, false, false, 0);
            }

            Gtk.VBox label_vbox = new Gtk.VBox(false, 0);
            label_vbox.Show();
            hbox.PackStart(label_vbox, true, true, 0);

            string title = String.Format("<span weight='bold' size='larger'>{0}" +
                                         "</span>\n",
                                         header);

            Gtk.Label label;

            label              = new Gtk.Label(title);
            label.UseMarkup    = true;
            label.UseUnderline = false;
            label.Justify      = Gtk.Justification.Left;
            label.LineWrap     = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            label              = new Gtk.Label(msg);
            label.UseMarkup    = true;
            label.UseUnderline = false;
            label.Justify      = Gtk.Justification.Left;
            label.LineWrap     = true;
            label.SetAlignment(0.0f, 0.5f);
            label.Show();
            label_vbox.PackStart(label, false, false, 0);

            extra_widget_vbox = new Gtk.VBox(false, 0);
            extra_widget_vbox.Show();
            label_vbox.PackStart(extra_widget_vbox, true, true, 12);

            switch (buttons)
            {
            case Gtk.ButtonsType.None:
                break;

            case Gtk.ButtonsType.Ok:
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;

            case Gtk.ButtonsType.Close:
                AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close, true);
                break;

            case Gtk.ButtonsType.Cancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, true);
                break;

            case Gtk.ButtonsType.YesNo:
                AddButton(Gtk.Stock.No, Gtk.ResponseType.No, false);
                AddButton(Gtk.Stock.Yes, Gtk.ResponseType.Yes, true);
                break;

            case Gtk.ButtonsType.OkCancel:
                AddButton(Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, false);
                AddButton(Gtk.Stock.Ok, Gtk.ResponseType.Ok, true);
                break;
            }

            if (parent != null)
            {
                TransientFor = parent;
            }

            if ((int)(flags & Gtk.DialogFlags.Modal) != 0)
            {
                Modal = true;
            }

            if ((int)(flags & Gtk.DialogFlags.DestroyWithParent) != 0)
            {
                DestroyWithParent = true;
            }
        }