[file-roller] define the progress dialog with .ui file



commit d485d78ca0b7f2f1a3ad332b8fe3efa1e38323bc
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jun 20 14:48:03 2012 +0200

    define the progress dialog with .ui file

 src/file-roller.gresource.xml |    1 +
 src/fr-window.c               |  123 ++++++++++----------------------------
 src/ui/Makefile.am            |    1 +
 src/ui/progress-dialog.ui     |  132 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 165 insertions(+), 92 deletions(-)
---
diff --git a/src/file-roller.gresource.xml b/src/file-roller.gresource.xml
index f6d5c42..9df229e 100644
--- a/src/file-roller.gresource.xml
+++ b/src/file-roller.gresource.xml
@@ -10,6 +10,7 @@
     <file compressed="true">ui/menus-toolbars.ui</file>
     <file compressed="true">ui/new.ui</file>
     <file compressed="true">ui/password.ui</file>
+    <file compressed="true">ui/progress-dialog.ui</file>
     <file compressed="true">ui/properties.ui</file>
     <file compressed="true">ui/update.ui</file>
     <file compressed="true">../data/org.gnome.ArchiveManager1.xml</file>
diff --git a/src/fr-window.c b/src/fr-window.c
index dacca3c..fd1d721 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -2462,112 +2462,51 @@ static void
 create_the_progress_dialog (FrWindow *window)
 {
 	GtkWindow      *parent;
-	GtkDialogFlags flags;
-	GtkDialog      *d;
-	GtkWidget      *hbox;
-	GtkWidget      *vbox;
-	GtkWidget      *align;
-	GtkWidget      *progress_vbox;
-	GtkWidget      *lbl;
-	PangoAttrList  *attr_list;
-	GdkPixbuf      *icon;
+	GtkDialogFlags  flags;
+	const char     *title;
+	GtkBuilder     *builder;
+	GtkWidget      *dialog;
 
 	if (window->priv->progress_dialog != NULL)
 		return;
 
-	flags = GTK_DIALOG_DESTROY_WITH_PARENT;
 	if (window->priv->batch_mode) {
 		parent = NULL;
+		flags = 0;
+		title = window->priv->batch_title;
 	}
 	else {
 		parent = GTK_WINDOW (window);
-		flags |= GTK_DIALOG_MODAL;
-	}
-
-	window->priv->progress_dialog = gtk_dialog_new_with_buttons ((window->priv->batch_mode ? window->priv->batch_title : NULL),
-								     parent,
-								     flags,
-								     NULL,
-								     NULL);
-
-	window->priv->pd_quit_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog), GTK_STOCK_QUIT, DIALOG_RESPONSE_QUIT);
-	window->priv->pd_open_archive_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog), _("_Open the Archive"), DIALOG_RESPONSE_OPEN_ARCHIVE);
-	window->priv->pd_open_destination_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog), _("_Show the Files"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER);
-	window->priv->pd_close_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-	window->priv->pd_cancel_button = gtk_dialog_add_button (GTK_DIALOG (window->priv->progress_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
-
-	d = GTK_DIALOG (window->priv->progress_dialog);
-	gtk_window_set_resizable (GTK_WINDOW (d), TRUE);
-	gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK);
-	gtk_window_set_default_size (GTK_WINDOW (d), PROGRESS_DIALOG_DEFAULT_WIDTH, -1);
-
-	/* Main */
-
-	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
-	gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
-	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (d)), hbox, FALSE, FALSE, 10);
-
-	icon = get_mime_type_pixbuf ("package-x-generic", _gtk_widget_lookup_for_size (GTK_WIDGET (window), GTK_ICON_SIZE_DIALOG), NULL);
-	window->priv->pd_icon = gtk_image_new_from_pixbuf (icon);
-	g_object_unref (icon);
-
-	gtk_misc_set_alignment (GTK_MISC (window->priv->pd_icon), 0.5, 0.0);
-	gtk_box_pack_start (GTK_BOX (hbox), window->priv->pd_icon, FALSE, FALSE, 0);
-
-	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
-	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
-
-	/* action description */
-
-	lbl = window->priv->pd_action = gtk_label_new ("");
-
-	align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
-	gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 12, 0, 0);
-
-	gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
-	gtk_misc_set_padding (GTK_MISC (lbl), 0, 0);
-	gtk_label_set_ellipsize (GTK_LABEL (lbl), PANGO_ELLIPSIZE_END);
-
-	gtk_container_add (GTK_CONTAINER (align), lbl);
-	gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
-
-	/* archive name */
+		flags = GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL;
+		title = NULL;
+	}
+
+	builder = _gtk_builder_new_from_resource ("progress-dialog.ui");
+	dialog = _gtk_builder_get_widget (builder, "progress_dialog");
+	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+	gtk_window_set_title (GTK_WINDOW (dialog), title);
+	gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+	gtk_window_set_modal (GTK_WINDOW (dialog), (flags & GTK_DIALOG_MODAL));
+	gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), (flags & GTK_DIALOG_DESTROY_WITH_PARENT));
+	g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, builder);
+
+	window->priv->pd_quit_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_QUIT, DIALOG_RESPONSE_QUIT);
+	window->priv->pd_open_archive_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Open the Archive"), DIALOG_RESPONSE_OPEN_ARCHIVE);
+	window->priv->pd_open_destination_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Show the Files"), DIALOG_RESPONSE_OPEN_DESTINATION_FOLDER);
+	window->priv->pd_close_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+	window->priv->pd_cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+	window->priv->progress_dialog = dialog;
+	window->priv->pd_icon = _gtk_builder_get_widget (builder, "icon_image");
+	window->priv->pd_action = _gtk_builder_get_widget (builder, "action_label");
+	window->priv->pd_progress_bar = _gtk_builder_get_widget (builder, "progress_progressbar");
+	window->priv->pd_message = _gtk_builder_get_widget (builder, "message_label");
 
 	g_free (window->priv->pd_last_archive);
 	window->priv->pd_last_archive = NULL;
 	if (window->priv->archive_uri != NULL)
 		window->priv->pd_last_archive = g_strdup (window->priv->archive_uri);
-
-	/* progress and details */
-
-	align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
-	gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 6, 0, 0);
-
-	progress_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-	gtk_container_add (GTK_CONTAINER (align), progress_vbox);
-	gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
-
-	/* progress bar */
-
-	window->priv->pd_progress_bar = gtk_progress_bar_new ();
-	gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->pd_progress_bar), ACTIVITY_PULSE_STEP);
-	gtk_box_pack_start (GTK_BOX (progress_vbox), window->priv->pd_progress_bar, TRUE, TRUE, 0);
-
-	/* details label */
-
-	lbl = window->priv->pd_message = gtk_label_new ("");
-
-	attr_list = pango_attr_list_new ();
-	pango_attr_list_insert (attr_list, pango_attr_size_new (9000));
-	gtk_label_set_attributes (GTK_LABEL (lbl), attr_list);
-	pango_attr_list_unref (attr_list);
-
-	gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
-	gtk_label_set_ellipsize (GTK_LABEL (lbl), PANGO_ELLIPSIZE_END);
-	gtk_box_pack_start (GTK_BOX (progress_vbox), lbl, TRUE, TRUE, 0);
-
-	gtk_widget_show_all (hbox);
-
 	progress_dialog_update_action_description (window);
 
 	/* signals */
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index c35c649..c393c1e 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST = 			\
 	menus-toolbars.ui	\
 	new.ui			\
 	password.ui		\
+	progress-dialog.ui	\
 	properties.ui		\
 	update.ui
 
diff --git a/src/ui/progress-dialog.ui b/src/ui/progress-dialog.ui
new file mode 100644
index 0000000..08f8e4c
--- /dev/null
+++ b/src/ui/progress-dialog.ui
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="progress_dialog">
+    <property name="width_request">500</property>
+    <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="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </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="hbox28">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="border_width">5</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkImage" id="icon_image">
+                <property name="width_request">64</property>
+                <property name="height_request">64</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="yalign">0</property>
+                <property name="pixel_size">48</property>
+                <property name="icon_name">package-x-generic</property>
+                <property name="icon-size">6</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</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">18</property>
+                <child>
+                  <object class="GtkLabel" id="action_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="ellipsize">end</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="box2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">2</property>
+                    <child>
+                      <object class="GtkProgressBar" id="progress_progressbar">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="pulse_step">0.029999999999999999</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="message_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="ellipsize">end</property>
+                        <attributes>
+                          <attribute name="size" value="9000"/>
+                        </attributes>
+                      </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="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">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]