From e516b0a2c803cf6b0f54c6b3cb2779107a49ed85 Mon Sep 17 00:00:00 2001 From: rbuj Date: Mon, 30 Mar 2020 17:09:14 +0200 Subject: Add set-title-dialog.ui --- src/Makefile.am | 1 + src/set-title-dialog.ui | 128 +++++++++++++++++++++++++++++++++++++++++++++ src/terminal-window.c | 46 ++++------------ src/terminal.gresource.xml | 1 + 4 files changed, 141 insertions(+), 35 deletions(-) create mode 100644 src/set-title-dialog.ui (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 04bebf9..df984f5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,6 +165,7 @@ EXTRA_DIST = \ profile-manager.ui \ profile-new-dialog.ui \ profile-preferences.ui \ + set-title-dialog.ui \ skey-challenge.ui \ terminal.about \ terminal.xml \ diff --git a/src/set-title-dialog.ui b/src/set-title-dialog.ui new file mode 100644 index 0000000..e2576ff --- /dev/null +++ b/src/set-title-dialog.ui @@ -0,0 +1,128 @@ + + + + + + True + False + process-stop + + + True + False + gtk-ok + + + False + 5 + Set Title + mate-terminal-change-title + True + True + dialog + + + + + + False + vertical + + + False + True + True + expand + + + _Cancel + True + True + True + image1 + True + True + + + True + True + 0 + + + + + _OK + True + True + True + True + True + image2 + True + True + + + True + True + 1 + + + + + + False + False + 0 + + + + + True + False + 12 + 12 + 12 + + + True + False + _Title: + True + title_entry + + + False + True + 0 + + + + + True + True + True + 30 + + + False + True + 1 + + + + + False + True + 1 + + + + + + button1 + button2 + + + diff --git a/src/terminal-window.c b/src/terminal-window.c index 5e98629..b50378f 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -4224,53 +4224,29 @@ static void terminal_set_title_callback (GtkAction *action, TerminalWindow *window) { + GtkBuilder *builder; TerminalWindowPrivate *priv = window->priv; - GtkWidget *dialog, *message_area, *hbox, *label, *entry; + GtkWidget *dialog, *entry; if (priv->active_screen == NULL) return; - /* FIXME: hook the screen up so this dialogue closes if the terminal screen closes */ - - dialog = gtk_message_dialog_new (GTK_WINDOW (window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_OTHER, - GTK_BUTTONS_OK_CANCEL, - "%s", ""); + builder = gtk_builder_new_from_resource (TERMINAL_RESOURCES_PATH_PREFIX G_DIR_SEPARATOR_S "ui/set-title-dialog.ui"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dialog")); + entry = GTK_WIDGET (gtk_builder_get_object (builder, "title_entry")); + g_object_unref (builder); - gtk_window_set_title (GTK_WINDOW (dialog), _("Set Title")); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_window_set_role (GTK_WINDOW (dialog), "mate-terminal-change-title"); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - /* Alternative button order was set automatically by GtkMessageDialog */ + gtk_widget_grab_focus (entry); + gtk_entry_set_text (GTK_ENTRY (entry), terminal_screen_get_raw_title (priv->active_screen)); + gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); + g_object_set_data (G_OBJECT (dialog), "title-entry", entry); g_signal_connect (dialog, "response", G_CALLBACK (terminal_set_title_dialog_response_cb), priv->active_screen); g_signal_connect (dialog, "delete-event", G_CALLBACK (terminal_util_dialog_response_on_delete), NULL); - message_area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); - gtk_container_foreach (GTK_CONTAINER (message_area), (GtkCallback) gtk_widget_hide, NULL); - - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); - gtk_box_pack_start (GTK_BOX (message_area), hbox, FALSE, FALSE, 0); - - label = gtk_label_new_with_mnemonic (_("_Title:")); - gtk_label_set_xalign (GTK_LABEL (label), 0.0); - gtk_label_set_yalign (GTK_LABEL (label), 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - entry = gtk_entry_new (); - gtk_entry_set_width_chars (GTK_ENTRY (entry), 32); - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - gtk_widget_show_all (hbox); - - gtk_widget_grab_focus (entry); - gtk_entry_set_text (GTK_ENTRY (entry), terminal_screen_get_raw_title (priv->active_screen)); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); - g_object_set_data (G_OBJECT (dialog), "title-entry", entry); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); gtk_window_present (GTK_WINDOW (dialog)); } diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml index 4332ba8..02fc71d 100644 --- a/src/terminal.gresource.xml +++ b/src/terminal.gresource.xml @@ -24,6 +24,7 @@ profile-manager.ui profile-new-dialog.ui profile-preferences.ui + set-title-dialog.ui skey-challenge.ui terminal.xml terminal.about -- cgit v1.2.1