[file-roller] modernized the 'update files' dialog
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] modernized the 'update files' dialog
- Date: Sat, 19 Dec 2015 16:27:58 +0000 (UTC)
commit f20b945209a3b524be33ef0b48546d97613bba5c
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Dec 19 17:24:13 2015 +0100
modernized the 'update files' dialog
src/dlg-update.c | 104 ++++++++++------
src/ui/update.ui | 365 +++++++++---------------------------------------------
2 files changed, 119 insertions(+), 350 deletions(-)
---
diff --git a/src/dlg-update.c b/src/dlg-update.c
index 5d3ebe4..7a5ef75 100644
--- a/src/dlg-update.c
+++ b/src/dlg-update.c
@@ -30,6 +30,11 @@
#include "fr-window.h"
+typedef enum {
+ DIALOG_RESPONSE_UPDATE = 1
+} DialogResponse;
+
+
enum {
IS_SELECTED_COLUMN,
NAME_COLUMN,
@@ -42,24 +47,20 @@ typedef struct {
GtkBuilder *builder;
GtkWidget *update_file_dialog;
- GtkWidget *update_file_primary_text_label;
- GtkWidget *update_file_secondary_text_label;
GtkWidget *update_files_dialog;
GtkWidget *update_files_primary_text_label;
GtkWidget *update_files_secondary_text_label;
GtkWidget *update_files_treeview;
- GtkWidget *update_files_ok_button;
GList *file_list;
GtkTreeModel *list_model;
} DialogData;
-/* called when the main dialog is closed. */
static void
-dlg_update__destroy_cb (GtkWidget *widget,
- DialogData *data)
+update_dialog_destroy (GtkWidget *widget,
+ DialogData *data)
{
fr_window_update_dialog_closed (data->window);
g_object_unref (data->window);
@@ -96,11 +97,9 @@ get_selected_files (DialogData *data)
static void
-update_cb (GtkWidget *widget,
- gpointer callback_data)
+execute_update (DialogData *data)
{
- DialogData *data = callback_data;
- GList *selection;
+ GList *selection;
selection = get_selected_files (data);
if (fr_window_update_files (data->window, selection)) {
@@ -162,7 +161,8 @@ update_file_list (DialogData *data)
archive_name = _g_file_get_display_basename (fr_window_get_archive_file (data->window));
label = g_markup_printf_escaped (_("Update the file \"%s\" in the archive \"%s\"?"),
file_name, archive_name);
markup = g_strdup_printf ("<big><b>%s</b></big>", label);
- gtk_label_set_markup (GTK_LABEL (data->update_file_primary_text_label), markup);
+ /*gtk_label_set_markup (GTK_LABEL (data->update_file_primary_text_label), markup);*/
+ g_object_set (data->update_file_dialog , "text", markup, "use-markup", TRUE, NULL);
g_free (markup);
g_free (label);
@@ -175,7 +175,8 @@ update_file_list (DialogData *data)
"%d files have been modified with an external application.
If you don't update the files in the archive, all of your changes will be lost.",
n_files),
n_files);
- gtk_label_set_text (GTK_LABEL (data->update_file_secondary_text_label), label);
+ /*gtk_label_set_text (GTK_LABEL (data->update_file_secondary_text_label), label);*/
+ g_object_set (data->update_file_dialog , "secondary-text", label, NULL);
g_free (label);
}
else if (n_files > 1) {
@@ -264,7 +265,28 @@ is_selected_toggled (GtkCellRendererToggle *cell,
gtk_tree_path_free (path);
- gtk_widget_set_sensitive (data->update_files_ok_button, n_selected (data) > 0);
+ gtk_dialog_set_response_sensitive (GTK_DIALOG( data->update_files_dialog), DIALOG_RESPONSE_UPDATE,
n_selected (data) > 0);
+}
+
+
+static void
+update_dialog_response (GtkDialog *dialog,
+ int response_id,
+ DialogData *data)
+{
+ switch (response_id) {
+ case GTK_RESPONSE_CANCEL:
+ case GTK_RESPONSE_DELETE_EVENT:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+
+ case DIALOG_RESPONSE_UPDATE:
+ execute_update (data);
+ break;
+
+ default:
+ break;
+ }
}
@@ -272,9 +294,7 @@ gpointer
dlg_update (FrWindow *window)
{
DialogData *data;
- GtkWidget *update_file_ok_button;
- GtkWidget *update_file_cancel_button;
- GtkWidget *update_files_cancel_button;
+ GtkWidget *content;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
@@ -291,46 +311,48 @@ dlg_update (FrWindow *window)
/* Get the widgets. */
- data->update_file_dialog = _gtk_builder_get_widget (data->builder, "update_file_dialog");
- data->update_file_primary_text_label = _gtk_builder_get_widget (data->builder,
"update_file_primary_text_label");
- data->update_file_secondary_text_label = _gtk_builder_get_widget (data->builder,
"update_file_secondary_text_label");
-
- update_file_ok_button = _gtk_builder_get_widget (data->builder, "update_file_ok_button");
- update_file_cancel_button = _gtk_builder_get_widget (data->builder, "update_file_cancel_button");
+ data->update_file_dialog = _gtk_message_dialog_new (GTK_WINDOW (window),
+ 0,
+ "",
+ NULL,
+ _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Update"), DIALOG_RESPONSE_UPDATE,
+ NULL);
+
+ data->update_files_dialog = g_object_new (GTK_TYPE_DIALOG,
+ "title", _("Update Files"),
+ "transient-for", GTK_WINDOW (window),
+ "use-header-bar", _gtk_settings_get_dialogs_use_header (),
+ NULL);
+ content = _gtk_builder_get_widget (data->builder, "update_files_dialog_content");
+ gtk_widget_set_vexpand (content, TRUE);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG
(data->update_files_dialog))), content);
+
+ gtk_dialog_add_button (GTK_DIALOG (data->update_files_dialog ), _GTK_LABEL_CANCEL,
GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (data->update_files_dialog ), _("_Update"), DIALOG_RESPONSE_UPDATE);
- data->update_files_dialog = _gtk_builder_get_widget (data->builder, "update_files_dialog");
data->update_files_primary_text_label = _gtk_builder_get_widget (data->builder,
"update_files_primary_text_label");
data->update_files_secondary_text_label = _gtk_builder_get_widget (data->builder,
"update_files_secondary_text_label");
data->update_files_treeview = _gtk_builder_get_widget (data->builder, "update_files_treeview");
- data->update_files_ok_button = _gtk_builder_get_widget (data->builder, "update_files_ok_button");
- update_files_cancel_button = _gtk_builder_get_widget (data->builder, "update_files_cancel_button");
/* Set the signals handlers. */
g_signal_connect (G_OBJECT (data->update_file_dialog),
"destroy",
- G_CALLBACK (dlg_update__destroy_cb),
+ G_CALLBACK (update_dialog_destroy),
data);
- g_signal_connect (G_OBJECT (update_file_ok_button),
- "clicked",
- G_CALLBACK (update_cb),
+ g_signal_connect (G_OBJECT (data->update_file_dialog),
+ "response",
+ G_CALLBACK (update_dialog_response),
data);
- g_signal_connect_swapped (G_OBJECT (update_file_cancel_button),
- "clicked",
- G_CALLBACK (gtk_widget_destroy),
- G_OBJECT (data->update_file_dialog));
g_signal_connect (G_OBJECT (data->update_files_dialog),
"destroy",
- G_CALLBACK (dlg_update__destroy_cb),
+ G_CALLBACK (update_dialog_destroy),
data);
- g_signal_connect (G_OBJECT (data->update_files_ok_button),
- "clicked",
- G_CALLBACK (update_cb),
+ g_signal_connect (G_OBJECT (data->update_files_dialog),
+ "response",
+ G_CALLBACK (update_dialog_response),
data);
- g_signal_connect_swapped (G_OBJECT (update_files_cancel_button),
- "clicked",
- G_CALLBACK (gtk_widget_destroy),
- G_OBJECT (data->update_files_dialog));
/* Set dialog data. */
diff --git a/src/ui/update.ui b/src/ui/update.ui
index 6971e4c..8cea1a0 100644
--- a/src/ui/update.ui
+++ b/src/ui/update.ui
@@ -1,345 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.19.0 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
- <object class="GtkImage" id="save_image">
+ <requires lib="gtk+" version="3.16"/>
+ <object class="GtkBox" id="update_files_dialog_content">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="stock">gtk-save</property>
- </object>
- <object class="GtkDialog" id="update_file_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="resizable">False</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
+ <property name="border_width">15</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">15</property>
+ <child>
+ <object class="GtkLabel" id="update_files_primary_text_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">4</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="update_file_cancel_button">
- <property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">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="update_file_ok_button">
- <property name="label" translatable="yes">_Update</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</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>
- </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="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon-size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="update_file_primary_text_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="update_file_secondary_text_label">
- <property name="width_request">400</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">The file has been modified with an external
application. If you don't update the file in the archive, all of your changes will be lost.</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="use_markup">True</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
- <action-widgets>
- <action-widget response="-6">update_file_cancel_button</action-widget>
- <action-widget response="-5">update_file_ok_button</action-widget>
- </action-widgets>
- </object>
- <object class="GtkDialog" id="update_files_dialog">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox5">
+ <child>
+ <object class="GtkLabel" id="update_files_secondary_text_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="spacing">4</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="hbuttonbox1">
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="update_files_cancel_button">
- <property name="label">gtk-cancel</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">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="update_files_ok_button">
- <property name="label" translatable="yes">_Update</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="image">save_image</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>
+ <property name="label" translatable="yes">S_elect the files you want to update:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">update_files_treeview</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="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox4">
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="width_request">400</property>
+ <property name="height_request">120</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="spacing">18</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkVBox" id="vbox6">
+ <object class="GtkTreeView" id="update_files_treeview">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImage" id="image4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon-size">6</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkLabel" id="update_files_primary_text_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="update_files_secondary_text_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox8">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">S_elect the files you want to
update:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">update_files_treeview</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="width_request">400</property>
- <property name="height_request">120</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="update_files_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="headers_visible">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection1"/>
- </child>
- </object>
- </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">2</property>
- </packing>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection3"/>
</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">False</property>
+ <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">2</property>
+ </packing>
</child>
- <action-widgets>
- <action-widget response="-6">update_files_cancel_button</action-widget>
- <action-widget response="-5">update_files_ok_button</action-widget>
- </action-widgets>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]