[nautilus/wip/antoniof/column-chooser-dialog-rework: 5/5] list-view: Build column editor with GtkBuilder
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/column-chooser-dialog-rework: 5/5] list-view: Build column editor with GtkBuilder
- Date: Mon, 26 Jul 2021 22:53:07 +0000 (UTC)
commit fe402b671bfcfb8d5c8bdbec8a78defdd8aba69a
Author: António Fernandes <antoniof gnome org>
Date: Sun Jul 25 16:13:45 2021 +0100
list-view: Build column editor with GtkBuilder
Keeping with the direction of preferring declarative UI definitions.
Also, it will help with porting to GTK4.
While we are at it, adopt HdyWindow for rounded corners, and make
the label not bold.
po/POTFILES.in | 1 +
src/nautilus-list-view.c | 46 +++++-----------------
src/resources/nautilus.gresource.xml | 1 +
.../ui/nautilus-list-view-column-editor.ui | 40 +++++++++++++++++++
4 files changed, 51 insertions(+), 37 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a3ac09cd5..8d1c3df66 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-properties-change-permissions.ui
src/resources/ui/nautilus-files-view-context-menus.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
src/resources/ui/nautilus-pathbar-context-menu.ui
src/resources/ui/nautilus-preferences-window.ui
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 79160e643..1e1188e8e 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3281,14 +3281,6 @@ action_zoom_to_level (GSimpleAction *action,
}
}
-static void
-column_editor_response_callback (GtkWidget *dialog,
- int response_id,
- gpointer user_data)
-{
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
static void
column_chooser_changed_callback (NautilusColumnChooser *chooser,
NautilusListView *view)
@@ -3398,48 +3390,28 @@ column_chooser_use_default_callback (NautilusColumnChooser *chooser,
static GtkWidget *
create_column_editor (NautilusListView *view)
{
+ g_autoptr (GtkBuilder) builder = NULL;
GtkWidget *window;
- GtkWidget *label;
GtkWidget *box;
GtkWidget *column_chooser;
NautilusFile *file;
char *str;
char *name;
- const char *label_text;
+
+ builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-list-view-column-editor.ui");
+
+ window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+ gtk_window_set_transient_for (GTK_WINDOW (window),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))));
file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (view));
name = nautilus_file_get_display_name (file);
str = g_strdup_printf (_("%s Visible Columns"), name);
g_free (name);
-
- window = gtk_dialog_new_with_buttons (str,
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT |
GTK_DIALOG_USE_HEADER_BAR,
- NULL, NULL);
+ gtk_window_set_title (GTK_WINDOW (window), str);
g_free (str);
- g_signal_connect (window, "response",
- G_CALLBACK (column_editor_response_callback), NULL);
-
- gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
-
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_container_set_border_width (GTK_CONTAINER (box), 12);
- gtk_widget_set_hexpand (box, TRUE);
- gtk_widget_show (box);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), box,
- TRUE, TRUE, 0);
-
- label_text = _("Choose the order of information to appear in this folder:");
- str = g_strconcat ("<b>", label_text, "</b>", NULL);
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label), str);
- gtk_label_set_line_wrap (GTK_LABEL (label), FALSE);
- gtk_label_set_xalign (GTK_LABEL (label), 0);
- gtk_label_set_yalign (GTK_LABEL (label), 0);
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
- g_free (str);
+ box = GTK_WIDGET (gtk_builder_get_object (builder, "box"));
column_chooser = nautilus_column_chooser_new (file);
gtk_box_pack_start (GTK_BOX (box), column_chooser, TRUE, TRUE, 0);
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index adfa04861..66f8f43f1 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -8,6 +8,7 @@
<file>ui/nautilus-toolbar-switcher.ui</file>
<file>ui/nautilus-toolbar-view-menu.ui</file>
<file>ui/nautilus-column-chooser.ui</file>
+ <file>ui/nautilus-list-view-column-editor.ui</file>
<file>ui/nautilus-create-folder-dialog.ui</file>
<file>ui/nautilus-compress-dialog.ui</file>
<file>ui/nautilus-rename-file-popover.ui</file>
diff --git a/src/resources/ui/nautilus-list-view-column-editor.ui
b/src/resources/ui/nautilus-list-view-column-editor.ui
new file mode 100644
index 000000000..5b30e863c
--- /dev/null
+++ b/src/resources/ui/nautilus-list-view-column-editor.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface>
+ <object class="HdyWindow" id="window">
+ <property name="modal">True</property>
+ <property name="type-hint">dialog</property>
+ <property name="default-width">300</property>
+ <property name="default-height">400</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="HdyHeaderBar">
+ <property name="visible">True</property>
+ <property name="title" bind-source="window" bind-property="title" bind-flags="sync-create"/>
+ <property name="show-close-button">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="margin">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label" translatable="yes">Choose the order of information to appear in this
folder:</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="wrap">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]