[gthumb] add to catalog: use the header bar
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] add to catalog: use the header bar
- Date: Wed, 29 Jan 2020 07:45:57 +0000 (UTC)
commit d4c53d69576e273316ecf3a879939650f91459c1
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jan 28 16:30:30 2020 +0100
add to catalog: use the header bar
extensions/catalogs/data/ui/add-to-catalog.ui | 284 +++++++++-----------------
extensions/catalogs/dlg-add-to-catalog.c | 62 +++---
2 files changed, 135 insertions(+), 211 deletions(-)
---
diff --git a/extensions/catalogs/data/ui/add-to-catalog.ui b/extensions/catalogs/data/ui/add-to-catalog.ui
index f0d15196..16c38c66 100644
--- a/extensions/catalogs/data/ui/add-to-catalog.ui
+++ b/extensions/catalogs/data/ui/add-to-catalog.ui
@@ -1,223 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
- <requires lib="gtk+" version="3.16"/>
- <object class="GtkDialog" id="add_to_catalog_dialog">
- <property name="width_request">400</property>
- <property name="height_request">350</property>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkBox" id="dialog_content">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
- <property name="title" translatable="yes">Add to Catalog</property>
- <property name="type_hint">dialog</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <placeholder/>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="catalogs_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="add_button">
- <property name="label" translatable="yes">_Add</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="add_close_button">
- <property name="label" translatable="yes">A_dd and Close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">C_atalogs:</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="vbox1">
+ <object class="GtkButton" id="new_library_button">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">12</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">New Library</property>
+ <property name="relief">none</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkBox" id="hbox2">
+ <object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox" id="catalog_list_container0">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="catalogs_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">C_atalogs:</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="catalog_list_container">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkScrolledWindow" id="catalog_list_scrolled_window">
- <property name="width_request">400</property>
- <property name="height_request">350</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="vbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkButton" id="new_catalog_button">
- <property name="label" translatable="yes">_New Catalog</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="new_library_button">
- <property name="label" translatable="yes">New _Library</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
+ <property name="icon_name">file-library-symbolic</property>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="new_catalog_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">New Catalog</property>
+ <property name="relief">none</property>
+ <property name="use_underline">True</property>
<child>
- <object class="GtkCheckButton" id="view_destination_checkbutton">
- <property name="label" translatable="yes">_View the destination</property>
+ <object class="GtkImage">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">file-catalog-symbolic</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="catalog_list_scrolled_window">
+ <property name="width_request">500</property>
+ <property name="height_request">500</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="keep_open_checkbutton">
+ <property name="label" translatable="yes">_Keep the dialog open</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="view_destination_checkbutton">
+ <property name="label" translatable="yes">_View the destination</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
</child>
- <action-widgets>
- <action-widget response="0">cancel_button</action-widget>
- <action-widget response="0">add_button</action-widget>
- </action-widgets>
</object>
</interface>
diff --git a/extensions/catalogs/dlg-add-to-catalog.c b/extensions/catalogs/dlg-add-to-catalog.c
index 76fd4a0a..8d31e57b 100644
--- a/extensions/catalogs/dlg-add-to-catalog.c
+++ b/extensions/catalogs/dlg-add-to-catalog.c
@@ -161,10 +161,10 @@ catalog_save_done_cb (void **buffer,
add_data->files,
GTH_MONITOR_EVENT_CREATED);
- if (add_data->view_destination)
- gth_browser_go_to (add_data->browser, add_data->catalog_file, NULL);
-
if (add_data->close_after_adding) {
+ if (add_data->view_destination)
+ gth_browser_go_to (add_data->browser, add_data->catalog_file, NULL);
+
if (add_data->dialog != NULL)
gtk_widget_destroy (add_data->dialog);
}
@@ -257,15 +257,7 @@ static void
add_button_clicked_cb (GtkWidget *widget,
DialogData *data)
{
- add_selection_to_catalog (data, FALSE);
-}
-
-
-static void
-add_close_button_clicked_cb (GtkWidget *widget,
- DialogData *data)
-{
- add_selection_to_catalog (data, TRUE);
+ add_selection_to_catalog (data, ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET
("keep_open_checkbutton"))));
}
@@ -279,9 +271,9 @@ update_sensitivity (DialogData *data)
selected_catalog = get_selected_catalog (data);
items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view
(data->browser)));
can_add = (items != NULL) && (selected_catalog != NULL);
- gtk_widget_set_sensitive (GET_WIDGET ("add_close_button"), can_add);
- gtk_widget_set_sensitive (GET_WIDGET ("add_button"), can_add);
-
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, can_add);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (GET_WIDGET ("view_destination_checkbutton")),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_open_checkbutton"))));
+ gtk_widget_set_sensitive (GET_WIDGET ("view_destination_checkbutton"), ! gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_open_checkbutton"))));
_gtk_tree_path_list_free (items);
_g_object_unref (selected_catalog);
}
@@ -456,7 +448,7 @@ new_catalog_button_clicked_cb (GtkWidget *widget,
dialog = gth_request_dialog_new (GTK_WINDOW (data->dialog),
GTK_DIALOG_MODAL,
- _("New catalog"),
+ _("New Catalog"),
_("Enter the catalog name:"),
_GTK_LABEL_CANCEL,
_("C_reate"));
@@ -615,7 +607,7 @@ new_library_button_clicked_cb (GtkWidget *widget,
dialog = gth_request_dialog_new (GTK_WINDOW (data->dialog),
GTK_DIALOG_MODAL,
- _("New library"),
+ _("New Library"),
_("Enter the library name:"),
_GTK_LABEL_CANCEL,
_("C_reate"));
@@ -654,6 +646,14 @@ file_selection_changed_cb (GthFileSelection *self,
}
+static void
+keep_open_button_toggled_cb (GtkToggleButton *button,
+ DialogData *data)
+{
+ update_sensitivity (data);
+}
+
+
void
dlg_add_to_catalog (GthBrowser *browser)
{
@@ -669,9 +669,22 @@ dlg_add_to_catalog (GthBrowser *browser)
data = g_new0 (DialogData, 1);
data->browser = browser;
data->builder = _gtk_builder_new_from_file ("add-to-catalog.ui", "catalogs");
- data->dialog = _gtk_builder_get_widget (data->builder, "add_to_catalog_dialog");
data->settings = g_settings_new (GTHUMB_CATALOGS_SCHEMA);
+ data->dialog = g_object_new (GTK_TYPE_DIALOG,
+ "title", _("Add to Catalog"),
+ "transient-for", GTK_WINDOW (browser),
+ "modal", FALSE,
+ "use-header-bar", _gtk_settings_get_dialogs_use_header (),
+ NULL);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))),
+ GET_WIDGET ("dialog_content"));
+ gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
+ _GTK_LABEL_CLOSE, GTK_RESPONSE_CANCEL,
+ _("_Add"), GTK_RESPONSE_OK,
+ NULL);
+ _gtk_dialog_add_class_to_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK,
GTK_STYLE_CLASS_SUGGESTED_ACTION);
+
gth_browser_set_dialog (browser, ADD_TO_CATALOG_DIALOG_NAME, data->dialog);
data->add_data = add_data_new ();
@@ -695,7 +708,7 @@ dlg_add_to_catalog (GthBrowser *browser)
"destroy",
G_CALLBACK (destroy_cb),
data);
- g_signal_connect_swapped (G_OBJECT (GET_WIDGET ("cancel_button")),
+ g_signal_connect_swapped (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog),
GTK_RESPONSE_CANCEL),
"clicked",
G_CALLBACK (gtk_widget_destroy),
G_OBJECT (data->dialog));
@@ -703,14 +716,10 @@ dlg_add_to_catalog (GthBrowser *browser)
"changed",
G_CALLBACK (source_tree_changed_cb),
data);
- g_signal_connect (G_OBJECT (GET_WIDGET ("add_button")),
+ g_signal_connect (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK),
"clicked",
G_CALLBACK (add_button_clicked_cb),
data);
- g_signal_connect (G_OBJECT (GET_WIDGET ("add_close_button")),
- "clicked",
- G_CALLBACK (add_close_button_clicked_cb),
- data);
g_signal_connect (G_OBJECT (GET_WIDGET ("new_catalog_button")),
"clicked",
G_CALLBACK (new_catalog_button_clicked_cb),
@@ -719,7 +728,10 @@ dlg_add_to_catalog (GthBrowser *browser)
"clicked",
G_CALLBACK (new_library_button_clicked_cb),
data);
-
+ g_signal_connect (G_OBJECT (GET_WIDGET ("keep_open_checkbutton")),
+ "toggled",
+ G_CALLBACK (keep_open_button_toggled_cb),
+ data);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->source_tree));
g_signal_connect (selection,
"changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]