[nautilus] files-view: Port Ctrl+S dialog to use GtkBuilder
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] files-view: Port Ctrl+S dialog to use GtkBuilder
- Date: Sat, 13 Nov 2021 12:32:42 +0000 (UTC)
commit 28ce30df03c4b112abd9b45938e88d1f1fb0ca8e
Author: Apoorv Sachan <apoorv 99 sachan gmail com>
Date: Tue Aug 18 00:48:08 2020 +0530
files-view: Port Ctrl+S dialog to use GtkBuilder
Now the Ctrl+S dialog is being built using the
GtkBuilder API, Now it's styling and can be
handled in the XML UI definition. The UI definiton
needs to be handled manually as Glade doesn't handle
the implementation of the GtkDialog used here.
po/POTFILES.in | 1 +
src/nautilus-files-view.c | 49 ++++----------------
src/resources/nautilus.gresource.xml | 1 +
src/resources/ui/select-items.ui | 88 ++++++++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+), 40 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 859e7efcf..03e8a2f13 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -84,6 +84,7 @@ src/resources/ui/nautilus-create-folder-dialog.ui
src/resources/ui/nautilus-file-conflict-dialog.ui
src/resources/ui/nautilus-file-properties-change-permissions.ui
src/resources/ui/nautilus-files-view-context-menus.ui
+src/resources/ui/nautilus-files-view-select-items.ui
src/resources/ui/nautilus-folder-is-empty.ui
src/resources/ui/nautilus-list-view-column-editor.ui
src/resources/ui/nautilus-no-search-results.ui
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 12bd49899..19a9172b6 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -1778,63 +1778,32 @@ pattern_select_response_cb (GtkWidget *dialog,
static void
select_pattern (NautilusFilesView *view)
{
+ g_autoptr (GtkBuilder) builder = NULL;
GtkWidget *dialog;
- GtkWidget *label;
+ NautilusWindow *window;
GtkWidget *example;
- GtkWidget *grid;
GtkWidget *entry;
char *example_pattern;
- dialog = gtk_dialog_new_with_buttons (_("Select Items Matching"),
- nautilus_files_view_get_containing_window (view),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_USE_HEADER_BAR,
- _("_Cancel"),
- GTK_RESPONSE_CANCEL,
- _("_Select"),
- GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_OK);
- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
-
- label = gtk_label_new_with_mnemonic (_("_Pattern:"));
- gtk_widget_set_halign (label, GTK_ALIGN_START);
+ window = nautilus_files_view_get_window (view);
+ builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/select-items.ui");
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "select_items_dialog"));
- example = gtk_label_new (NULL);
- gtk_widget_set_halign (example, GTK_ALIGN_START);
+ example = GTK_WIDGET (gtk_builder_get_object (builder, "example"));
example_pattern = g_strdup_printf ("%s<i>%s</i> ",
_("Examples: "),
"*.png, file\?\?.txt, pict*.\?\?\?");
gtk_label_set_markup (GTK_LABEL (example), example_pattern);
g_free (example_pattern);
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
- entry = gtk_entry_new ();
- gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
- gtk_widget_set_hexpand (entry, TRUE);
-
- grid = gtk_grid_new ();
- g_object_set (grid,
- "orientation", GTK_ORIENTATION_VERTICAL,
- "border-width", 6,
- "row-spacing", 6,
- "column-spacing", 12,
- NULL);
-
- gtk_container_add (GTK_CONTAINER (grid), label);
- gtk_grid_attach_next_to (GTK_GRID (grid), entry, label,
- GTK_POS_RIGHT, 1, 1);
- gtk_grid_attach_next_to (GTK_GRID (grid), example, entry,
- GTK_POS_BOTTOM, 1, 1);
+ entry = GTK_WIDGET (gtk_builder_get_object (builder, "pattern_entry"));
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
- gtk_widget_show_all (grid);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid);
g_object_set_data (G_OBJECT (dialog), "entry", entry);
g_signal_connect (dialog, "response",
G_CALLBACK (pattern_select_response_cb),
view);
- gtk_widget_show_all (dialog);
+ gtk_widget_show (dialog);
}
static void
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index 5188b58c4..c3e8034b5 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -25,6 +25,7 @@
<file>ui/nautilus-properties-window.ui</file>
<file>ui/nautilus-file-properties-change-permissions.ui</file>
<file>ui/nautilus-file-conflict-dialog.ui</file>
+ <file>ui/nautilus-files-view-select-items.ui</file>
<file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
<file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
<file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
diff --git a/src/resources/ui/select-items.ui b/src/resources/ui/select-items.ui
new file mode 100644
index 000000000..60fd30018
--- /dev/null
+++ b/src/resources/ui/select-items.ui
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.22"/>
+ <object class="GtkDialog" id="select_items_dialog">
+ <property name="title" translatable="yes">Select Items Matching</property>
+ <property name="modal">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="use-header-bar">1</property>
+ <property name="border_width">5</property>
+ <child type="action">
+ <object class="GtkButton" id="cancel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="select">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Select</property>
+ <property name="use_underline">True</property>
+ <property name="can-default">True</property>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkGrid" id="select_item_grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="pattern">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Pattern:</property>
+ <property name="mnemonic_widget">pattern_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="example">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label"></property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="pattern_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="activates_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="cancel">cancel</action-widget>
+ <action-widget response="ok" default="true">select</action-widget>
+ </action-widgets>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]