[goobox] ripper dialog: use the headerbar



commit f442cd80a7fb3257150885b53a2b43f474822628
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Dec 29 10:20:48 2018 +0100

    ripper dialog: use the headerbar

 src/dlg-ripper.c |  39 ++++++++++----
 src/ui/ripper.ui | 162 +++++++++++--------------------------------------------
 2 files changed, 59 insertions(+), 142 deletions(-)
---
diff --git a/src/dlg-ripper.c b/src/dlg-ripper.c
index e9ff66d..c92fd5b 100644
--- a/src/dlg-ripper.c
+++ b/src/dlg-ripper.c
@@ -462,7 +462,7 @@ done_dialog_response_cb (GtkDialog  *dialog,
                        char *uri;
 
                        uri = g_file_get_uri (folder);
-                       if (! gtk_show_uri_on_window (GTK_WINDOW (dialog), uri, GDK_CURRENT_TIME, &error))
+                       if (! gtk_show_uri_on_window (GTK_WINDOW (data->dialog), uri, GDK_CURRENT_TIME, 
&error))
                                _gtk_error_dialog_from_gerror_run (GTK_WINDOW (data->window), _("Could not 
display the destination folder"), &error);
 
                        g_free (uri);
@@ -576,7 +576,6 @@ static void
 rip_current_track (DialogData *data)
 {
        TrackInfo *track;
-       char      *msg;
        char      *escaped;
        GFile     *folder;
        GError    *error = NULL;
@@ -609,11 +608,9 @@ rip_current_track (DialogData *data)
 
        track = data->current_track->data;
 
-       msg = g_strdup_printf (_("Extracting ā€œ%sā€"), track->title);
-       escaped = g_markup_printf_escaped ("<i>%s</i>", msg);
+       escaped = g_markup_printf_escaped ("<i>%s</i>", track->title);
        gtk_label_set_markup (GTK_LABEL (GET_WIDGET ("track_label")), escaped);
        g_free (escaped);
-       g_free (msg);
 
        /* Set the destination file */
 
@@ -710,6 +707,15 @@ start_ripper (DialogData *data)
 }
 
 
+static void
+dialog_response_cb (GtkWidget  *dialog,
+                   int         response_id,
+                   DialogData *data)
+{
+       gtk_widget_destroy (dialog);
+}
+
+
 void
 dlg_ripper (GooWindow *window,
            GList     *tracks)
@@ -725,7 +731,20 @@ dlg_ripper (GooWindow *window,
        data->settings_ripper = g_settings_new (GOOBOX_SCHEMA_RIPPER);
        data->settings_encoder = g_settings_new (GOOBOX_SCHEMA_ENCODER);
        data->builder = _gtk_builder_new_from_resource ("ripper.ui");
-       data->dialog = GET_WIDGET ("ripper_dialog");
+
+       data->dialog = g_object_new (GTK_TYPE_DIALOG,
+                                    "title", _("Extracting Tracks"),
+                                    "transient-for", GTK_WINDOW (window),
+                                    "modal", TRUE,
+                                    "use-header-bar", _gtk_settings_get_dialogs_use_header (),
+                                    "resizable", TRUE,
+                                    NULL);
+       gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))),
+                          GET_WIDGET ("ripper_dialog"));
+       gtk_dialog_add_buttons (GTK_DIALOG (data->dialog),
+                               _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL,
+                               NULL);
+
        data->destination = g_settings_get_string (data->settings_ripper, PREF_RIPPER_DESTINATION);
        if ((data->destination == NULL) || (strcmp (data->destination, "") == 0))
                data->destination = g_filename_to_uri (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC), NULL, 
NULL);
@@ -752,10 +771,10 @@ dlg_ripper (GooWindow *window,
                          "destroy",
                          G_CALLBACK (dialog_destroy_cb),
                          data);
-       g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
-                                 "clicked",
-                                 G_CALLBACK (gtk_widget_destroy),
-                                 data->dialog);
+       g_signal_connect (G_OBJECT (data->dialog),
+                         "response",
+                         G_CALLBACK (dialog_response_cb),
+                         data);
 
        /* run dialog. */
 
diff --git a/src/ui/ripper.ui b/src/ui/ripper.ui
index ce70b8c..11956be 100644
--- a/src/ui/ripper.ui
+++ b/src/ui/ripper.ui
@@ -1,158 +1,56 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkDialog" id="ripper_dialog">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkBox" id="ripper_dialog">
+    <property name="width_request">550</property>
+    <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="border_width">5</property>
-    <property name="title" translatable="yes">Extracting Tracks</property>
-    <property name="resizable">False</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="type_hint">dialog</property>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox3">
+    <property name="hexpand">True</property>
+    <property name="border_width">15</property>
+    <child>
+      <object class="GtkBox" id="vbox12">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="border_width">5</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area3">
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkProgressBar" id="progress_progressbar">
+            <property name="width_request">350</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancel_button">
-                <property name="label">gtk-cancel</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_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
+            <property name="pulse_step">0.10000000149</property>
+            <property name="show_text">True</property>
+            <property name="ellipsize">start</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="hbox1">
+          <object class="GtkLabel" id="track_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <child>
-              <object class="GtkVBox" id="vbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkImage" id="image1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="pixel_size">64</property>
-                    <property name="icon_name">drive-optical</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="padding">12</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="vbox12">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="border_width">5</property>
-                <property name="spacing">6</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" translatable="yes">Extracting tracks</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                      <attribute name="size" value="12000"/>
-                    </attributes>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="padding">6</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkVBox" id="vbox170">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="spacing">2</property>
-                    <child>
-                      <object class="GtkProgressBar" id="progress_progressbar">
-                        <property name="width_request">350</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="pulse_step">0.10000000149</property>
-                        <property name="ellipsize">start</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="track_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="ellipsize">end</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">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>
+            <property name="use_markup">True</property>
+            <property name="ellipsize">end</property>
+            <property name="xalign">0</property>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
     </child>
-    <action-widgets>
-      <action-widget response="-6">cancel_button</action-widget>
-    </action-widgets>
   </object>
 </interface>


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