[file-roller] password: Use gtk-dialogs-use-header GtkSetting
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] password: Use gtk-dialogs-use-header GtkSetting
- Date: Sun, 15 Feb 2015 12:00:05 +0000 (UTC)
commit 841bf118f818e0d1c8f808c544d95a4d8a6d6db7
Author: Iain Lane <iain lane canonical com>
Date: Fri Dec 19 16:05:30 2014 +0000
password: Use gtk-dialogs-use-header GtkSetting
https://bugzilla.gnome.org/show_bug.cgi?id=741925
src/dlg-password.c | 31 +++++++--
src/ui/password.ui | 185 +++++++++++++++++-----------------------------------
2 files changed, 86 insertions(+), 130 deletions(-)
---
diff --git a/src/dlg-password.c b/src/dlg-password.c
index 5d274f2..fbe3b58 100644
--- a/src/dlg-password.c
+++ b/src/dlg-password.c
@@ -35,6 +35,7 @@
typedef struct {
GtkBuilder *builder;
FrWindow *window;
+ GtkWidget *dialog;
} DialogData;
@@ -64,7 +65,7 @@ response_cb (GtkWidget *dialog,
g_free (password);
}
- gtk_widget_destroy (GET_WIDGET ("dialog"));
+ gtk_widget_destroy (data->dialog);
}
@@ -74,8 +75,10 @@ dlg_password (GtkWidget *widget,
{
FrWindow *window = callback_data;
DialogData *data;
+ GtkWidget *content_area;
char *basename;
char *title;
+ gboolean use_header;
data = g_new0 (DialogData, 1);
data->window = window;
@@ -86,6 +89,24 @@ dlg_password (GtkWidget *widget,
}
/* Set widgets data. */
+ g_object_get (gtk_settings_get_default (),
+ "gtk-dialogs-use-header", &use_header,
+ NULL);
+
+ data->dialog = g_object_new (GTK_TYPE_DIALOG,
+ "transient-for", GTK_WINDOW (window),
+ "modal", TRUE,
+ "use-header-bar", use_header,
+ NULL);
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (data->dialog));
+ gtk_container_add (GTK_CONTAINER (content_area),
+ GET_WIDGET ("password_vbox"));
+ gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Save"), GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (data->dialog),
+ GTK_RESPONSE_OK);
basename = _g_file_get_display_basename (fr_archive_get_file (window->archive));
title = g_strdup_printf (_("Enter a password for \"%s\""), basename);
@@ -107,11 +128,11 @@ dlg_password (GtkWidget *widget,
/* Set the signals handlers. */
- g_signal_connect (GET_WIDGET ("dialog"),
+ g_signal_connect ((data->dialog),
"destroy",
G_CALLBACK (destroy_cb),
data);
- g_signal_connect (GET_WIDGET ("dialog"),
+ g_signal_connect ((data->dialog),
"response",
G_CALLBACK (response_cb),
data);
@@ -119,7 +140,5 @@ dlg_password (GtkWidget *widget,
/* Run dialog. */
gtk_widget_grab_focus (GET_WIDGET ("password_entry"));
- gtk_window_set_transient_for (GTK_WINDOW (GET_WIDGET ("dialog")), GTK_WINDOW (window));
- gtk_window_set_modal (GTK_WINDOW (GET_WIDGET ("dialog")), TRUE);
- gtk_widget_show (GET_WIDGET ("dialog"));
+ gtk_widget_show (data->dialog);
}
diff --git a/src/ui/password.ui b/src/ui/password.ui
index b4573f7..6d97253 100644
--- a/src/ui/password.ui
+++ b/src/ui/password.ui
@@ -1,87 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkDialog" id="dialog">
+ <object class="GtkBox" id="password_vbox">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Password</property>
- <property name="resizable">False</property>
- <property name="window_position">center-on-parent</property>
- <property name="type_hint">dialog</property>
- <property name="use_header_bar">1</property>
- <child internal-child="headerbar">
- <object class="GtkHeaderBar" id="dialog-header_bar">
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkVBox" id="vbox11">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="show_close_button">False</property>
+ <property name="border_width">5</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_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_underline">True</property>
- <property name="valign">center</property>
- <style>
- <class name="text-button"/>
- </style>
- </object>
- <packing>
- <property name="pack_type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="ok_button">
- <property name="label" translatable="yes">_Save</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="has_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="valign">center</property>
- <style>
- <class name="text-button"/>
- <class name="suggested-action"/>
- </style>
- </object>
- <packing>
- <property name="pack_type">end</property>
- </packing>
- </child>
- </object>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox15">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkVBox" id="vbox11">
+ <object class="GtkHBox" id="hbox29">
<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="GtkHBox" id="hbox29">
+ <object class="GtkImage" id="image2">
+ <property name="width_request">64</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="stock">gtk-dialog-authentication</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>
+ <child>
+ <object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
<child>
- <object class="GtkImage" id="image2">
- <property name="width_request">64</property>
+ <object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="yalign">0</property>
- <property name="stock">gtk-dialog-authentication</property>
- <property name="icon-size">6</property>
+ <property name="xalign">0</property>
+ <property name="label">Enter a password for "archive.tar.xz"</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ <attribute name="size" value="12000"/>
+ </attributes>
</object>
<packing>
<property name="expand">False</property>
@@ -90,21 +56,20 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
- <property name="spacing">18</property>
+ <property name="spacing">2</property>
<child>
- <object class="GtkLabel" id="title_label">
+ <object class="GtkEntry" id="password_entry">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label">Enter a password for "archive.tar.xz"</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- <attribute name="size" value="12000"/>
- </attributes>
+ <property name="can_focus">True</property>
+ <property name="visibility">False</property>
+ <property name="invisible_char">●</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">40</property>
+ <property name="invisible_char_set">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -113,45 +78,16 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkCheckButton" id="encrypt_header_checkbutton">
+ <property name="label" translatable="yes">_Encrypt the file list</property>
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkEntry" id="password_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="invisible_char">●</property>
- <property name="activates_default">True</property>
- <property name="width_chars">40</property>
- <property name="invisible_char_set">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="encrypt_header_checkbutton">
- <property name="label" translatable="yes">_Encrypt the file list</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -161,7 +97,7 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@@ -170,21 +106,22 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</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>
+ <property name="position">0</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
- <action-widgets>
- <action-widget response="-6">cancel_button</action-widget>
- <action-widget response="-5">ok_button</action-widget>
- </action-widgets>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]