[file-roller] ask-password: Use gtk-dialogs-use-header GtkSetting



commit 2389c4c9cc369e48d8412213eb1f46239812fce8
Author: Iain Lane <iain lane canonical com>
Date:   Fri Dec 19 13:00:44 2014 +0000

    ask-password: Use gtk-dialogs-use-header GtkSetting
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741925

 src/dlg-ask-password.c |   24 ++++-
 src/ui/ask-password.ui |  281 ++++++++++++++++++------------------------------
 2 files changed, 124 insertions(+), 181 deletions(-)
---
diff --git a/src/dlg-ask-password.c b/src/dlg-ask-password.c
index 132e353..5a80238 100644
--- a/src/dlg-ask-password.c
+++ b/src/dlg-ask-password.c
@@ -98,9 +98,11 @@ dlg_ask_password__common (FrWindow       *window,
 {
        DialogData *data;
        GFile      *file;
+       GtkWidget  *content_area;
        const char *old_password;
        char       *filename;
        char       *message;
+       gboolean   use_header;
 
        data = g_new0 (DialogData, 1);
        data->builder = _gtk_builder_new_from_resource ("ask-password.ui");
@@ -111,9 +113,25 @@ dlg_ask_password__common (FrWindow       *window,
        data->window = window;
        data->pwd_type = pwd_type;
 
-       /* Get the widgets. */
-
-       data->dialog = GET_WIDGET ("password_dialog");
+       /* Make the widgets. */
+       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,
+                                                       _("_OK"), GTK_RESPONSE_OK,
+                                                       NULL);
+       gtk_dialog_set_default_response (GTK_DIALOG (data->dialog),
+                       GTK_RESPONSE_OK);
        data->password_entry = GET_WIDGET ("password_entry");
 
        /* Set widgets data. */
diff --git a/src/ui/ask-password.ui b/src/ui/ask-password.ui
index 9cecbff..ffd7cc2 100644
--- a/src/ui/ask-password.ui
+++ b/src/ui/ask-password.ui
@@ -1,200 +1,125 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkDialog" id="password_dialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">5</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="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="show_close_button">False</property>
-        <child>
-          <object class="GtkButton" id="pw_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="pw_ok_button">
-            <property name="label" translatable="yes">_OK</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">
-            <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="GtkHBox" id="hbox29">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="spacing">12</property>
-                <child>
+  <object class="GtkVBox" id="password_vbox">
+      <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="GtkHBox" id="hbox29">
+              <property name="visible">True</property>
+              <property name="can_focus">False</property>
+              <property name="spacing">12</property>
+              <child>
                   <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>
+                      <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>
+                      <property name="expand">False</property>
+                      <property name="fill">True</property>
+                      <property name="position">0</property>
                   </packing>
-                </child>
-                <child>
+              </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">12</property>
-                    <child>
-                      <object class="GtkLabel" id="title_label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label">Password required for "archive.tar.xz"</property>
-                        <attributes>
-                          <attribute name="weight" value="bold"/>
-                          <attribute name="size" value="12000"/>
-                        </attributes>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkBox" id="error_box">
-                        <property name="visible">True</property>
-                        <property name="app_paintable">True</property>
-                        <property name="can_focus">False</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="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="GtkLabel" id="message_label">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">_Password:</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">password_entry</property>
+                      <property name="visible">True</property>
+                      <property name="can_focus">False</property>
+                      <property name="orientation">vertical</property>
+                      <property name="spacing">12</property>
+                      <child>
+                          <object class="GtkLabel" id="title_label">
+                              <property name="visible">True</property>
+                              <property name="can_focus">False</property>
+                              <property name="xalign">0</property>
+                              <property name="label">Password required for "archive.tar.xz"</property>
+                              <attributes>
+                                  <attribute name="weight" value="bold"/>
+                                  <attribute name="size" value="12000"/>
+                              </attributes>
+                          </object>
+                          <packing>
+                              <property name="expand">False</property>
+                              <property name="fill">True</property>
+                              <property name="position">0</property>
+                          </packing>
+                      </child>
+                      <child>
+                          <object class="GtkBox" id="error_box">
+                              <property name="visible">True</property>
+                              <property name="app_paintable">True</property>
+                              <property name="can_focus">False</property>
+                              <child>
+                                  <placeholder/>
+                              </child>
                           </object>
                           <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
+                              <property name="expand">False</property>
+                              <property name="fill">True</property>
+                              <property name="position">1</property>
                           </packing>
-                        </child>
-                        <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>
+                      </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="GtkLabel" id="message_label">
+                                      <property name="visible">True</property>
+                                      <property name="can_focus">False</property>
+                                      <property name="xalign">0</property>
+                                      <property name="label" translatable="yes">_Password:</property>
+                                      <property name="use_underline">True</property>
+                                      <property name="mnemonic_widget">password_entry</property>
+                                  </object>
+                                  <packing>
+                                      <property name="expand">False</property>
+                                      <property name="fill">True</property>
+                                      <property name="position">0</property>
+                                  </packing>
+                              </child>
+                              <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>
+                                  </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>
+                              <property name="expand">False</property>
+                              <property name="fill">True</property>
+                              <property name="position">2</property>
                           </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
+                      </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</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">0</property>
-              </packing>
-            </child>
+              </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+              <property name="expand">True</property>
+              <property name="fill">True</property>
+              <property name="position">0</property>
           </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">pw_cancel_button</action-widget>
-      <action-widget response="-5">pw_ok_button</action-widget>
-    </action-widgets>
+      </child>
   </object>
 </interface>


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