[gnome-disk-utility/udisks2-port] Avoid use of GtkInfoBar in .ui files to work around annoying glade(1) behavior
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Avoid use of GtkInfoBar in .ui files to work around annoying glade(1) behavior
- Date: Wed, 7 Dec 2011 20:00:13 +0000 (UTC)
commit 8d667913c07c120207b95418456d122569e8f713
Author: David Zeuthen <davidz redhat com>
Date: Wed Dec 7 14:59:01 2011 -0500
Avoid use of GtkInfoBar in .ui files to work around annoying glade(1) behavior
Also unify all uses of gtk_info_bar_new() to use a common utility function.
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/create-partition-dialog.ui | 93 ----------------------------
src/palimpsest/gducreatepartitiondialog.c | 14 ++++-
src/palimpsest/gducrypttabdialog.c | 29 ++-------
src/palimpsest/gdufstabdialog.c | 22 +------
src/palimpsest/gdurestorediskimagedialog.c | 13 +++-
src/palimpsest/gduutils.c | 62 ++++++++++++++++++
src/palimpsest/gduutils.h | 4 +
7 files changed, 95 insertions(+), 142 deletions(-)
---
diff --git a/data/ui/create-partition-dialog.ui b/data/ui/create-partition-dialog.ui
index f2de180..01d1776 100644
--- a/data/ui/create-partition-dialog.ui
+++ b/data/ui/create-partition-dialog.ui
@@ -66,99 +66,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <child>
- <object class="GtkInfoBar" id="infobar-dos-error">
- <property name="message_type">error</property>
- <child internal-child="content_area">
- <object class="GtkBox" id="infobar1-vbox1">
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">12</property>
-
- <child>
- <object class="GtkImage" id="infobar1-image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1.0</property>
- <property name="stock">gtk-dialog-error</property>
- <property name="icon-size">2</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="infobar1-label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"><b>Error:</b> Cannot create a new partition. There are already four primary partitions.</property>
- <property name="use_markup">True</property>
- <property name="xalign">0.0</property>
- <property name="selectable">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkInfoBar" id="infobar-dos-warning">
- <property name="message_type">warning</property>
- <child internal-child="content_area">
- <object class="GtkBox" id="infobar2-vbox1">
- <property name="can_focus">False</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkImage" id="infobar2-image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">1.0</property>
- <property name="stock">gtk-dialog-warning</property>
- <property name="icon-size">2</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="infobar2-label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"><b>Warning:</b> This is the last primary partition that can be created.</property>
- <property name="use_markup">True</property>
- <property name="xalign">0.0</property>
- <property name="selectable">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </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">False</property>
diff --git a/src/palimpsest/gducreatepartitiondialog.c b/src/palimpsest/gducreatepartitiondialog.c
index 61be78a..2e63ef5 100644
--- a/src/palimpsest/gducreatepartitiondialog.c
+++ b/src/palimpsest/gducreatepartitiondialog.c
@@ -28,6 +28,7 @@
#include "gduwindow.h"
#include "gducreatepartitiondialog.h"
#include "gducreatefilesystemwidget.h"
+#include "gduutils.h"
/* ---------------------------------------------------------------------------------------------------- */
@@ -44,6 +45,7 @@ typedef struct
GtkBuilder *builder;
GtkWidget *dialog;
+ GtkWidget *infobar_vbox;
GtkWidget *dos_error_infobar;
GtkWidget *dos_warning_infobar;
GtkWidget *size_spinbutton;
@@ -332,8 +334,16 @@ gdu_create_partition_dialog_show (GduWindow *window,
"create-partition-dialog.ui",
"create-partition-dialog",
&data->builder);
- data->dos_error_infobar = GTK_WIDGET (gtk_builder_get_object (data->builder, "infobar-dos-error"));;
- data->dos_warning_infobar = GTK_WIDGET (gtk_builder_get_object (data->builder, "infobar-dos-warning"));;
+
+ data->infobar_vbox = GTK_WIDGET (gtk_builder_get_object (data->builder, "infobar-vbox"));;
+ data->dos_error_infobar = gdu_utils_create_info_bar (GTK_MESSAGE_ERROR,
+ _("Cannot create a new partition. There are already four primary partitions."),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (data->infobar_vbox), data->dos_error_infobar, TRUE, TRUE, 0);
+ data->dos_warning_infobar = gdu_utils_create_info_bar (GTK_MESSAGE_WARNING,
+ _("This is the last primary partition that can be created."),
+ NULL);
+ gtk_box_pack_start (GTK_BOX (data->infobar_vbox), data->dos_warning_infobar, TRUE, TRUE, 0);
data->size_spinbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "size-spinbutton"));
data->size_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (data->builder, "size-adjustment"));
g_signal_connect (data->size_adjustment, "notify::value", G_CALLBACK (create_partition_property_changed), data);
diff --git a/src/palimpsest/gducrypttabdialog.c b/src/palimpsest/gducrypttabdialog.c
index cc4c786..5b50f52 100644
--- a/src/palimpsest/gducrypttabdialog.c
+++ b/src/palimpsest/gducrypttabdialog.c
@@ -477,30 +477,11 @@ gdu_crypttab_dialog_show (GduWindow *window,
data->passphrase_path_value_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "crypttab-passphrase-path-value-label"));
/* do infobar stuff manually because of glade-hate ! #$ :-/ */
- data->passphrase_warning_infobar = gtk_info_bar_new ();
- gtk_info_bar_set_message_type (GTK_INFO_BAR (data->passphrase_warning_infobar),
- GTK_MESSAGE_INFO);
- {
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *image;
-
- /* don't show by default (see crypttab_dialog_on_get_secrets_cb()) */
- gtk_widget_set_no_show_all (data->passphrase_warning_infobar, TRUE);
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (data->passphrase_warning_infobar))),
- hbox, TRUE, TRUE, 0);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON);
- gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
-
- label = gtk_label_new (NULL);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_markup (GTK_LABEL (label), _("<b>NOTE:</b> Only the passphrase referenced by the <i>/etc/crypttab</i> file will be changed. To change the on-disk passphrase, use the <i>Change Passphrase...</i> menu item."));
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
- }
+ data->passphrase_warning_infobar = gdu_utils_create_info_bar (GTK_MESSAGE_INFO,
+ _("<b>NOTE:</b> Only the passphrase referenced by the <i>/etc/crypttab</i> file will be changed. To change the on-disk passphrase, use the <i>Change Passphrase...</i> menu item."),
+ NULL);
+ /* don't show by default (see crypttab_dialog_on_get_secrets_cb()) */
+ gtk_widget_set_no_show_all (data->passphrase_warning_infobar, TRUE);
gtk_box_pack_start (GTK_BOX (data->infobar_vbox), data->passphrase_warning_infobar, TRUE, TRUE, 0);
/* First check if there's an existing configuration */
diff --git a/src/palimpsest/gdufstabdialog.c b/src/palimpsest/gdufstabdialog.c
index 4ccf59e..cd329e8 100644
--- a/src/palimpsest/gdufstabdialog.c
+++ b/src/palimpsest/gdufstabdialog.c
@@ -476,25 +476,9 @@ gdu_fstab_dialog_show (GduWindow *window,
if (is_system_mount)
{
GtkWidget *bar;
- GtkWidget *label;
- GtkWidget *image;
- GtkWidget *hbox;
-
- bar = gtk_info_bar_new ();
- gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_WARNING);
-
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON);
-
- label = gtk_label_new (NULL);
- gtk_label_set_markup (GTK_LABEL (label),
- _("<b>Warning:</b> "
- "The system may not work correctly if this entry is modified or removed."));
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
- gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), hbox);
+ bar = gdu_utils_create_info_bar (GTK_MESSAGE_WARNING,
+ _("The system may not work correctly if this entry is modified or removed."),
+ NULL);
gtk_box_pack_start (GTK_BOX (data.infobar_hbox), bar, TRUE, TRUE, 0);
}
diff --git a/src/palimpsest/gdurestorediskimagedialog.c b/src/palimpsest/gdurestorediskimagedialog.c
index ed71235..9220efe 100644
--- a/src/palimpsest/gdurestorediskimagedialog.c
+++ b/src/palimpsest/gdurestorediskimagedialog.c
@@ -53,6 +53,8 @@ typedef struct
GtkWidget *notebook;
GtkWidget *start_copying_button;
GtkWidget *source_file_fcbutton;
+
+ GtkWidget *infobar_vbox;
GtkWidget *warning_infobar;
GtkWidget *warning_label;
GtkWidget *error_infobar;
@@ -484,10 +486,13 @@ gdu_restore_disk_image_dialog_show (GduWindow *window,
data->source_file_fcbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "source_file_fcbutton"));
g_signal_connect (data->source_file_fcbutton, "file-set",
G_CALLBACK (on_file_set), data);
- data->warning_infobar = GTK_WIDGET (gtk_builder_get_object (data->builder, "warning_infobar"));
- data->warning_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "warning_label"));
- data->error_infobar = GTK_WIDGET (gtk_builder_get_object (data->builder, "error_infobar"));
- data->error_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "error_label"));
+ data->infobar_vbox = GTK_WIDGET (gtk_builder_get_object (data->builder, "infobar-vbox"));
+ data->warning_infobar = gdu_utils_create_info_bar (GTK_MESSAGE_WARNING, "", &data->warning_label);
+ gtk_box_pack_start (GTK_BOX (data->infobar_vbox), data->warning_infobar, TRUE, TRUE, 0);
+ gtk_widget_set_no_show_all (data->warning_infobar, TRUE);
+ data->error_infobar = gdu_utils_create_info_bar (GTK_MESSAGE_ERROR, "", &data->error_label);
+ gtk_box_pack_start (GTK_BOX (data->infobar_vbox), data->error_infobar, TRUE, TRUE, 0);
+ gtk_widget_set_no_show_all (data->error_infobar, TRUE);
data->copying_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "copying_label"));
data->copying_progressbar = GTK_WIDGET (gtk_builder_get_object (data->builder, "copying_progressbar"));
data->copying_progress_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "copying_progress_label"));
diff --git a/src/palimpsest/gduutils.c b/src/palimpsest/gduutils.c
index c7530ad..51b328a 100644
--- a/src/palimpsest/gduutils.c
+++ b/src/palimpsest/gduutils.c
@@ -130,3 +130,65 @@ gdu_utils_duration_to_string (guint duration_sec,
}
return s;
}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+/* wouldn't need this if glade would support GtkInfoBar #$ #$@#!! # */
+
+GtkWidget *
+gdu_utils_create_info_bar (GtkMessageType message_type,
+ const gchar *markup,
+ GtkWidget **out_label)
+{
+ GtkWidget *info_bar;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *image;
+ const gchar *stock_id;
+
+ info_bar = gtk_info_bar_new ();
+ gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), message_type);
+
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))),
+ hbox, TRUE, TRUE, 0);
+
+ switch (message_type)
+ {
+ case GTK_MESSAGE_QUESTION:
+ stock_id = GTK_STOCK_DIALOG_QUESTION;
+ break;
+
+ default: /* explicit fall-through */
+ case GTK_MESSAGE_OTHER: /* explicit fall-through */
+ case GTK_MESSAGE_INFO:
+ stock_id = GTK_STOCK_DIALOG_INFO;
+ break;
+
+ case GTK_MESSAGE_WARNING:
+ stock_id = GTK_STOCK_DIALOG_WARNING;
+ break;
+
+ case GTK_MESSAGE_ERROR:
+ stock_id = GTK_STOCK_DIALOG_ERROR;
+ break;
+ }
+ image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
+
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+
+ if (out_label != NULL)
+ *out_label = label;
+
+ gtk_widget_show (hbox);
+ gtk_widget_show (image);
+ gtk_widget_show (label);
+
+ return info_bar;
+}
+
diff --git a/src/palimpsest/gduutils.h b/src/palimpsest/gduutils.h
index ce9df52..22838bb 100644
--- a/src/palimpsest/gduutils.h
+++ b/src/palimpsest/gduutils.h
@@ -37,6 +37,10 @@ void gdu_utils_configure_file_chooser_for_disk_images (GtkFileChooser *file_choo
gchar *gdu_utils_duration_to_string (guint duration_sec,
gboolean include_second_precision);
+GtkWidget *gdu_utils_create_info_bar (GtkMessageType message_type,
+ const gchar *markup,
+ GtkWidget **out_label);
+
G_END_DECLS
#endif /* __GDU_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]