Exemplo n.º 1
0
        public MarkdownFindView()
        {
            Builder builder = ViewBase.BuilderFromResource("ApsimNG.Resources.Glade.FindAndReplace.glade");

            window1           = (Window)builder.GetObject("window1");
            chkMatchCase      = (CheckButton)builder.GetObject("chkMatchCase");
            chkMatchWholeWord = (CheckButton)builder.GetObject("chkMatchWholeWord");
            txtLookFor        = (Entry)builder.GetObject("txtLookFor");
            txtReplaceWith    = (Entry)builder.GetObject("txtReplaceWith");
            btnReplace        = (Button)builder.GetObject("btnReplace");
            btnReplaceAll     = (Button)builder.GetObject("btnReplaceAll");
            btnHighlightAll   = (Button)builder.GetObject("btnHighlightAll");
            btnCancel         = (Button)builder.GetObject("btnCancel");
            btnFindPrevious   = (Button)builder.GetObject("btnFindPrevious");
            btnFindNext       = (Button)builder.GetObject("btnFindNext");
            lblReplaceWith    = (Label)builder.GetObject("lblReplaceWith");

            // We use the same glade form as the FindAndReplaceForm, but we don't
            // allow for replacing text (the view is readonly). Therefore we need
            // to hide the controls related to the text replace functionality.
            btnReplace.Visible      = btnReplaceAll.Visible = false;
            lblReplaceWith.Visible  = txtReplaceWith.Visible = false;
            btnHighlightAll.Visible = false;  // !value;

            btnFindNext.Clicked     += BtnFindNext_Click;
            btnFindPrevious.Clicked += BtnFindPrevious_Click;
            btnCancel.Clicked       += BtnCancel_Click;
            btnHighlightAll.Clicked += BtnHighlightAll_Click;
            window1.DeleteEvent     += Window1_DeleteEvent;
            window1.Destroyed       += Window1_Destroyed;
            AccelGroup agr = new AccelGroup();

            // Allow the text input widget to activate the default widget and make
            // the 'find next instance' button the default widget for its toplevel.
            // This means that when the user presses return while the text input
            // has focus, it will activate the default widget (the 'find next' button).
            btnFindNext.HasDefault      = true;
            txtLookFor.ActivatesDefault = true;

            // Add some extra keyboard shortcuts for the various buttons:
            // F3                               - find next
            // Shift + F3, Shift + Return       - find previous
            // Escape                           - Close the dialog
            btnFindNext.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.F3, Gdk.ModifierType.None, AccelFlags.Visible));
            btnFindPrevious.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.F3, Gdk.ModifierType.ShiftMask, AccelFlags.Visible));
            btnFindPrevious.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Return, Gdk.ModifierType.ShiftMask, AccelFlags.Visible));
            btnCancel.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Escape, Gdk.ModifierType.None, AccelFlags.Visible));
            window1.AddAccelGroup(agr);
        }
Exemplo n.º 2
0
        public FindAndReplaceForm()
        {
            Builder builder = ViewBase.BuilderFromResource("ApsimNG.Resources.Glade.FindAndReplace.glade");

            window1           = (Window)builder.GetObject("window1");
            chkMatchCase      = (CheckButton)builder.GetObject("chkMatchCase");
            chkMatchWholeWord = (CheckButton)builder.GetObject("chkMatchWholeWord");
            txtLookFor        = (Entry)builder.GetObject("txtLookFor");
            txtReplaceWith    = (Entry)builder.GetObject("txtReplaceWith");
            btnReplace        = (Button)builder.GetObject("btnReplace");
            btnReplaceAll     = (Button)builder.GetObject("btnReplaceAll");
            btnHighlightAll   = (Button)builder.GetObject("btnHighlightAll");
            btnCancel         = (Button)builder.GetObject("btnCancel");
            btnFindPrevious   = (Button)builder.GetObject("btnFindPrevious");
            btnFindNext       = (Button)builder.GetObject("btnFindNext");
            lblReplaceWith    = (Label)builder.GetObject("lblReplaceWith");

            btnFindNext.Clicked     += BtnFindNext_Click;
            btnFindPrevious.Clicked += BtnFindPrevious_Click;
            btnCancel.Clicked       += BtnCancel_Click;
            btnReplace.Clicked      += BtnReplace_Click;
            btnReplaceAll.Clicked   += BtnReplaceAll_Click;
            btnHighlightAll.Clicked += BtnHighlightAll_Click;
            window1.DeleteEvent     += Window1_DeleteEvent;
            window1.Destroyed       += Window1_Destroyed;
            AccelGroup agr = new AccelGroup();

            btnCancel.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Escape, Gdk.ModifierType.None, AccelFlags.Visible));
            window1.AddAccelGroup(agr);
        }
Exemplo n.º 3
0
        public ImportDialog(bool doNotShowAgainVisible) : base("ImportDialog")
        {
            accel_group = new AccelGroup();

            if (ServiceManager.Contains("GtkElementsService"))
            {
                Dialog.TransientFor = ServiceManager.Get <GtkElementsService> ().PrimaryWindow;
            }

            Dialog.WindowPosition = WindowPosition.CenterOnParent;
            Dialog.AddAccelGroup(accel_group);
            Dialog.DefaultResponse = ResponseType.Ok;
            import_button          = (Glade["ImportButton"] as Button);

            DoNotShowAgainVisible = doNotShowAgainVisible;

            PopulateSourceList();

            ServiceManager.SourceManager.SourceAdded   += OnSourceAdded;
            ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
            ServiceManager.SourceManager.SourceUpdated += OnSourceUpdated;

            Glade["MessageLabel"].Visible = ServiceManager.SourceManager.DefaultSource.Count == 0;

            import_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);

            Dialog.StyleSet += delegate {
                UpdateIcons();
            };
        }
Exemplo n.º 4
0
        public FindInBrowserForm()
        {
            Builder builder = ViewBase.BuilderFromResource("ApsimNG.Resources.Glade.BrowserFind.glade");

            window1         = (Window)builder.GetObject("window1");
            chkMatchCase    = (CheckButton)builder.GetObject("chkMatchCase");
            chkHighlightAll = (CheckButton)builder.GetObject("chkHighlightAll");
            txtLookFor      = (Entry)builder.GetObject("txtLookFor");
            btnCancel       = (Button)builder.GetObject("btnCancel");
            btnFindPrevious = (Button)builder.GetObject("btnFindPrevious");
            btnFindNext     = (Button)builder.GetObject("btnFindNext");

            txtLookFor.Changed       += TxtLookFor_Changed;
            btnFindNext.Clicked      += BtnFindNext_Click;
            btnFindPrevious.Clicked  += BtnFindPrevious_Click;
            btnCancel.Clicked        += BtnCancel_Click;
            chkHighlightAll.Clicked  += ChkHighlightAll_Click;
            chkHighlightAll.Visible   = false;           // Hide this for now...
            chkHighlightAll.NoShowAll = true;
            window1.DeleteEvent      += Window1_DeleteEvent;
            window1.Destroyed        += Window1_Destroyed;
            AccelGroup agr = new AccelGroup();

            btnCancel.AddAccelerator("activate", agr, new AccelKey(Gdk.Key.Escape, Gdk.ModifierType.None, AccelFlags.Visible));
            window1.AddAccelGroup(agr);
        }
        public void AddButton(string message, ResponseType response, bool isDefault)
        {
            Button button = (Button)AddButton(message, response);

            if (isDefault)
            {
                DefaultResponse = response;
                button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                      0, Gtk.AccelFlags.Visible);
            }
        }
Exemplo n.º 6
0
//		Entry sipServerAddressEntry;
//		Entry sipUsernameEntry;
//		Entry sipPasswordEntry;

        public PreferencesDialog() : base()
        {
            SetDefaultSize(600, 600);
            WindowPosition = WindowPosition.Center;
            IconName       = "rtc";
            HasSeparator   = false;
            BorderWidth    = 5;
            Resizable      = true;
            Title          = Catalog.GetString("Banter Preferences");

            VBox.Spacing      = 5;
            ActionArea.Layout = ButtonBoxStyle.End;

            // Notebook Tabs (General, Messages)...
            Gtk.Notebook notebook = new Notebook();
            notebook.TabPos      = PositionType.Top;
            notebook.BorderWidth = 5;
            notebook.Show();

//			notebook.AppendPage (MakeGeneralPage (),
//									new Label (Catalog.GetString ("General")));
            notebook.AppendPage(MakeAccountsPage(),
                                new Label(Catalog.GetString("Accounts")));
            notebook.AppendPage(MakeMessagesPage(),
                                new Label(Catalog.GetString("Messages")));

            VBox.PackStart(notebook, true, true, 0);

            // Close button...
            Button button = new Button(Stock.Close);

            button.CanDefault = true;
            button.Show();

            AccelGroup accelGroup = new AccelGroup();

            AddAccelGroup(accelGroup);

            button.AddAccelerator("activate",
                                  accelGroup,
                                  (uint)Gdk.Key.Escape,
                                  0,
                                  0);

            AddActionWidget(button, ResponseType.Close);
            DefaultResponse = ResponseType.Close;

            Realized += DialogRealized;

            Preferences.PreferenceChanged += PreferenceChanged;

            ShowAll();
        }
Exemplo n.º 7
0
        public Button AddButton(Button button, ResponseType response, bool isDefault)
        {
            AddActionWidget(button, response);

            if (isDefault)
            {
                DefaultResponse = response;
                button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);
            }

            return(button);
        }
        public VersionInformationDialog() : base()
        {
            var accel_group = new AccelGroup();

            AddAccelGroup(accel_group);
            Modal = true;

            var button = new Button("gtk-close")
            {
                CanDefault = true,
                UseStock   = true
            };

            button.Show();
            DefaultResponse = ResponseType.Close;
            button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                  0, Gtk.AccelFlags.Visible);

            AddActionWidget(button, ResponseType.Close);

            Title       = Catalog.GetString("Assembly Version Information");
            BorderWidth = 10;

            version_tree = new TreeView {
                RulesHint = true
            };
            version_tree.AppendColumn(Catalog.GetString("Assembly Name"),
                                      new CellRendererText(), "text", 0);
            version_tree.AppendColumn(Catalog.GetString("Version"),
                                      new CellRendererText(), "text", 1);

            version_tree.Model          = FillStore();
            version_tree.CursorChanged += OnCursorChanged;

            var scroll = new ScrolledWindow();

            scroll.Add(version_tree);
            scroll.ShadowType = ShadowType.In;
            scroll.SetSizeRequest(420, 200);

            VBox.PackStart(scroll, true, true, 0);
            VBox.Spacing = 5;

            path_label = new Label {
                Ellipsize = Pango.EllipsizeMode.End
            };
            path_label.Hide();
            path_label.Xalign = 0.0f;
            path_label.Yalign = 1.0f;
            VBox.PackStart(path_label, false, true, 0);

            scroll.ShowAll();
        }
Exemplo n.º 9
0
        private void AddButton(string stock_id, Gtk.ResponseType response, bool is_default)
        {
            Button button = new Button(stock_id);

            button.CanDefault = true;
            button.Show();

            AddActionWidget(button, response);

            if (is_default)
            {
                DefaultResponse = response;
                button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                      0, AccelFlags.Visible);
            }
        }
Exemplo n.º 10
0
        public void AddButton(string message, ResponseType response, bool isDefault, bool isStock)
        {
            Button button = new Button(message);

            button.CanDefault = true;
            button.UseStock   = isStock;
            button.Show();

            Dialog.AddActionWidget(button, response);

            if (isDefault)
            {
                Dialog.DefaultResponse = response;
                button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                      0, AccelFlags.Visible);
            }
        }
        public ProfileConfigurationDialog(Profile profile) : base()
        {
            this.profile = profile;

            HasSeparator = false;
            BorderWidth  = 5;

            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Button button = new Button(Stock.Close);

            button.CanDefault = true;
            button.Show();

            if (ApplicationContext.Debugging)
            {
                Button test_button = new Button("Test S-Expr");
                test_button.Show();
                test_button.Clicked += delegate {
                    if (sexpr_results != null)
                    {
                        sexpr_results.Buffer.Text = profile.Pipeline.GetDefaultProcess();
                    }
                };
                ActionArea.PackStart(test_button, true, true, 0);

                sexpr_results = new TextView();
            }

            AddActionWidget(button, ResponseType.Close);
            DefaultResponse = ResponseType.Close;
            button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                  0, AccelFlags.Visible);

            BuildContents();

            LoadProfile();
        }
Exemplo n.º 12
0
        public void InitializeDialog()
        {
            FillGenreList();

            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Title           = String.Empty;
            SkipTaskbarHint = true;

            BorderWidth     = 6;
            DefaultResponse = ResponseType.Ok;

            ContentArea.Spacing = 6;

            HBox split_box = new HBox();

            split_box.Spacing     = 12;
            split_box.BorderWidth = 6;

            Image image = new Image();

            image.IconSize = (int)IconSize.Dialog;
            image.IconName = "radio";
            image.Yalign   = 0.0f;
            image.Show();

            VBox main_box = new VBox();

            main_box.BorderWidth = 5;
            main_box.Spacing     = 10;

            Label header = new Label();

            header.Text = String.Format(AddinManager.CurrentLocalizer.GetString("{0}Radiostation fetcher{1}\n({2})"),
                                        "<span weight=\"bold\" size=\"larger\">", "</span>", source_name);
            header.Xalign    = 0.0f;
            header.Yalign    = 0.0f;
            header.UseMarkup = true;
            header.Wrap      = true;
            header.Show();

            Label message = new Label();

            message.Text = AddinManager.CurrentLocalizer.GetString("Choose a genre or enter a text that you wish to be queried, " +
                                                                   "then press the Get stations button. Found stations will be added to internet-radio source.");
            message.Xalign = 0.0f;
            message.Wrap   = true;
            message.Show();

            table               = new Table(5, 2, false);
            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            genre_entry    = new ComboBoxText();
            freeText_entry = new Entry();

            genre_button    = new Button(AddinManager.CurrentLocalizer.GetString("Get stations"));
            freeText_button = new Button(AddinManager.CurrentLocalizer.GetString("Get stations"));

            genre_button.CanDefault = true;
            genre_button.UseStock   = true;
            genre_button.Clicked   += OnGenreQueryButtonClick;
            genre_button.Show();


            freeText_button.CanDefault = true;
            freeText_button.UseStock   = true;
            freeText_button.Clicked   += OnFreetextQueryButtonClick;
            freeText_button.Show();

            foreach (string genre in genre_list)
            {
                if (!String.IsNullOrEmpty(genre))
                {
                    genre_entry.AppendText(genre);
                }
            }

            if (this is IGenreSearchable)
            {
                AddRow(AddinManager.CurrentLocalizer.GetString("Query by genre:"), genre_entry, genre_button);
            }

            if (this is IFreetextSearchable)
            {
                AddRow(AddinManager.CurrentLocalizer.GetString("Query by free text:"), freeText_entry, freeText_button);
            }

            table.ShowAll();

            main_box.PackStart(header, false, false, 0);
            main_box.PackStart(message, false, false, 0);
            main_box.PackStart(table, false, false, 0);
            main_box.Show();

            split_box.PackStart(image, false, false, 0);
            split_box.PackStart(main_box, true, true, 0);
            split_box.Show();

            ContentArea.PackStart(split_box, true, true, 0);

            close_button            = new Button();
            close_button.Image      = new Image("gtk-close", IconSize.Button);
            close_button.Label      = AddinManager.CurrentLocalizer.GetString("_Close");
            close_button.CanDefault = true;
            close_button.UseStock   = true;
            close_button.Show();
            AddActionWidget(close_button, ResponseType.Close);

            close_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                        0, Gtk.AccelFlags.Visible);

            close_button.Clicked += OnCloseButtonClick;

            statusbar = new Statusbar();
            SetStatusBarMessage(source_name);
            main_box.PackEnd(statusbar, false, false, 0);
        }
Exemplo n.º 13
0
        public StationEditor(DatabaseTrackInfo track) : base()
        {
            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Title           = String.Empty;
            SkipTaskbarHint = true;
            Modal           = true;

            this.track = track;

            string title = track == null
                ? Catalog.GetString("Add new radio station")
                : Catalog.GetString("Edit radio station");

            BorderWidth     = 6;
            DefaultResponse = ResponseType.Ok;
            Modal           = true;

            ContentArea.Spacing = 6;

            HBox split_box = new HBox();

            split_box.Spacing     = 12;
            split_box.BorderWidth = 6;

            Image image = new Image();

            image.IconSize = (int)IconSize.Dialog;
            image.IconName = "radio";
            image.Yalign   = 0.0f;
            image.Show();

            VBox main_box = new VBox();

            main_box.BorderWidth = 5;
            main_box.Spacing     = 10;

            Label header = new Label();

            header.Markup = String.Format("<big><b>{0}</b></big>", GLib.Markup.EscapeText(title));
            header.Xalign = 0.0f;
            header.Show();

            Label message = new Label();

            message.Text   = Catalog.GetString("Enter the Genre, Title and URL of the radio station you wish to add. A description is optional.");
            message.Xalign = 0.0f;
            message.Wrap   = true;
            message.Show();

            table               = new Table(5, 2, false);
            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            genre_entry = ComboBoxText.NewWithEntry();

            foreach (string genre in ServiceManager.DbConnection.QueryEnumerable <string> ("SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre"))
            {
                if (!String.IsNullOrEmpty(genre))
                {
                    genre_entry.AppendText(genre);
                }
            }

            if (track != null && !String.IsNullOrEmpty(track.Genre))
            {
                genre_entry.Entry.Text = track.Genre;
            }

            AddRow(Catalog.GetString("Station Genre:"), genre_entry);

            name_entry        = AddEntryRow(Catalog.GetString("Station Name:"));
            stream_entry      = AddEntryRow(Catalog.GetString("Stream URL:"));
            creator_entry     = AddEntryRow(Catalog.GetString("Station Creator:"));
            description_entry = AddEntryRow(Catalog.GetString("Description:"));

            rating_entry = new RatingEntry();
            HBox rating_box = new HBox();

            rating_box.PackStart(rating_entry, false, false, 0);
            AddRow(Catalog.GetString("Rating:"), rating_box);

            table.ShowAll();

            main_box.PackStart(header, false, false, 0);
            main_box.PackStart(message, false, false, 0);
            main_box.PackStart(table, false, false, 0);
            main_box.Show();

            split_box.PackStart(image, false, false, 0);
            split_box.PackStart(main_box, true, true, 0);
            split_box.Show();

            ContentArea.PackStart(split_box, true, true, 0);

            Button cancel_button = new Button(Stock.Cancel);

            cancel_button.CanDefault = false;
            cancel_button.UseStock   = true;
            cancel_button.Show();
            AddActionWidget(cancel_button, ResponseType.Close);

            cancel_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                         0, Gtk.AccelFlags.Visible);

            save_button            = new Button(Stock.Save);
            save_button.CanDefault = true;
            save_button.UseStock   = true;
            save_button.Sensitive  = false;
            save_button.Show();
            AddActionWidget(save_button, ResponseType.Ok);

            save_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                       0, Gtk.AccelFlags.Visible);

            name_entry.HasFocus = true;

            if (track != null)
            {
                if (!String.IsNullOrEmpty(track.TrackTitle))
                {
                    name_entry.Text = track.TrackTitle;
                }

                if (!String.IsNullOrEmpty(track.Uri.AbsoluteUri))
                {
                    stream_entry.Text = track.Uri.AbsoluteUri;
                }

                if (!String.IsNullOrEmpty(track.Comment))
                {
                    description_entry.Text = track.Comment;
                }

                if (!String.IsNullOrEmpty(track.ArtistName))
                {
                    creator_entry.Text = track.ArtistName;
                }

                rating_entry.Value = track.Rating;
            }

            error_container            = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            error_container.TopPadding = 6;
            HBox error_box = new HBox();

            error_box.Spacing = 4;

            Image error_image = new Image();

            error_image.Stock    = Stock.DialogError;
            error_image.IconSize = (int)IconSize.Menu;
            error_image.Show();

            error        = new Label();
            error.Xalign = 0.0f;
            error.Show();

            error_box.PackStart(error_image, false, false, 0);
            error_box.PackStart(error, true, true, 0);
            error_box.Show();

            error_container.Add(error_box);

            table.Attach(error_container, 0, 2, 6, 7, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

            genre_entry.Entry.Changed += OnFieldsChanged;
            name_entry.Changed        += OnFieldsChanged;
            stream_entry.Changed      += OnFieldsChanged;

            OnFieldsChanged(this, EventArgs.Empty);
        }
Exemplo n.º 14
0
        private void BuildUI()
        {
            // The BorderWidth situation here is a bit nuts b/c the
            // ActionArea's is set to 5.  So we work everything else out
            // so it all totals to 12.
            //
            // WIDGET           BorderWidth
            // Dialog           5
            //   VBox           2
            //     inner_vbox   5 => total = 12
            //     ActionArea   5 => total = 12
            BorderWidth           = 5;
            base.VBox.BorderWidth = 0;

            // This spacing is 2 b/c the inner_vbox and ActionArea should be
            // 12 apart, and they already have BorderWidth 5 each
            base.VBox.Spacing = 2;

            inner_vbox = new VBox()
            {
                Spacing = 12, BorderWidth = 5, Visible = true
            };
            base.VBox.PackStart(inner_vbox, true, true, 0);

            Visible      = false;
            HasSeparator = false;

            var table = new Table(3, 2, false)
            {
                RowSpacing    = 12,
                ColumnSpacing = 16
            };

            table.Attach(new Image()
            {
                IconName = "dialog-error",
                IconSize = (int)IconSize.Dialog,
                Yalign   = 0.0f
            }, 0, 1, 0, 3, AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0);

            table.Attach(header_label = new Label()
            {
                Xalign = 0.0f
            }, 1, 2, 0, 1,
                         AttachOptions.Fill | AttachOptions.Expand,
                         AttachOptions.Shrink, 0, 0);

            table.Attach(message_label = new Hyena.Widgets.WrapLabel(), 1, 2, 1, 2,
                         AttachOptions.Fill | AttachOptions.Expand,
                         AttachOptions.Shrink, 0, 0);

            var scrolled_window = new ScrolledWindow()
            {
                HscrollbarPolicy = PolicyType.Automatic,
                VscrollbarPolicy = PolicyType.Automatic,
                ShadowType       = ShadowType.In
            };

            list_view = new TreeView()
            {
                HeightRequest = 120,
                WidthRequest  = 200
            };
            scrolled_window.Add(list_view);

            table.Attach(details_expander = new Expander(Catalog.GetString("Details")),
                         1, 2, 2, 3,
                         AttachOptions.Fill | AttachOptions.Expand,
                         AttachOptions.Fill | AttachOptions.Expand,
                         0, 0);
            details_expander.Add(scrolled_window);

            VBox.PackStart(table, true, true, 0);
            VBox.Spacing = 12;
            VBox.ShowAll();

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

            Button button = new Button(Stock.Close);

            button.CanDefault = true;
            button.UseStock   = true;
            button.Show();
            button.Clicked += (o, a) => {
                Destroy();
            };

            AddActionWidget(button, ResponseType.Close);

            DefaultResponse = ResponseType.Close;
            button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return, 0, AccelFlags.Visible);
        }
Exemplo n.º 15
0
        public ArtistAdder() : base()
        {
            string title = Catalog.GetString("Add new SoundCloud artist");

            AccelGroup accel_group = new AccelGroup();

            AddAccelGroup(accel_group);

            Title           = title;
            SkipTaskbarHint = true;
            Modal           = true;
            BorderWidth     = 6;
            HasSeparator    = false;
            DefaultResponse = ResponseType.Ok;
            Modal           = true;

            VBox.Spacing = 6;

            HBox split_box = new HBox();

            split_box.Spacing     = 12;
            split_box.BorderWidth = 6;

            /* TODO:
             *      Get this bloody image to display.
             * Image image = new Image("soundcloud");
             * image.IconSize =(int)IconSize.Dialog;
             * image.IconName = "soundcloudd";
             * image.Yalign = 0.0f;
             * image.Show();
             */

            VBox main_box = new VBox();

            main_box.BorderWidth = 5;
            main_box.Spacing     = 10;

            Label header = new Label();

            header.Markup = String.Format("<big><b>{0}</b></big>", GLib.Markup.EscapeText(title));
            header.Xalign = 0.0f;
            header.Show();

            Label message = new Label();

            message.Text   = Catalog.GetString("Enter the name of the artist you'd like to add.");
            message.Xalign = 0.0f;
            message.Wrap   = true;
            message.Show();

            table               = new Table(5, 2, false);
            table.RowSpacing    = 6;
            table.ColumnSpacing = 6;

            artist_entry = AddEntryRow(Catalog.GetString("Artist Name:"));

            table.ShowAll();

            main_box.PackStart(header, false, false, 0);
            main_box.PackStart(message, false, false, 0);
            main_box.PackStart(table, false, false, 0);
            main_box.Show();

            //split_box.PackStart(image, false, false, 0);
            split_box.PackStart(main_box, true, true, 0);
            split_box.Show();

            VBox.PackStart(split_box, true, true, 0);

            Button cancel_button = new Button(Stock.Cancel);

            cancel_button.CanDefault = false;
            cancel_button.UseStock   = true;
            cancel_button.Show();
            AddActionWidget(cancel_button, ResponseType.Close);

            cancel_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Escape,
                                         0, Gtk.AccelFlags.Visible);

            save_button            = new Button(Stock.Save);
            save_button.CanDefault = true;
            save_button.UseStock   = true;
            save_button.Sensitive  = false;
            save_button.Show();
            AddActionWidget(save_button, ResponseType.Ok);

            save_button.AddAccelerator("activate", accel_group, (uint)Gdk.Key.Return,
                                       0, Gtk.AccelFlags.Visible);

            artist_entry.HasFocus = true;

            error_container            = new Alignment(0.0f, 0.0f, 1.0f, 1.0f);
            error_container.TopPadding = 6;
            HBox error_box = new HBox();

            error_box.Spacing = 4;

            Image error_image = new Image();

            error_image.Stock    = Stock.DialogError;
            error_image.IconSize = (int)IconSize.Menu;
            error_image.Show();

            error        = new Label();
            error.Xalign = 0.0f;
            error.Show();

            error_box.PackStart(error_image, false, false, 0);
            error_box.PackStart(error, true, true, 0);
            error_box.Show();

            error_container.Add(error_box);

            table.Attach(error_container, 0, 2, 6, 7, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Shrink, 0, 0);

            artist_entry.Changed += OnFieldsChanged;

            OnFieldsChanged(this, EventArgs.Empty);
        }