[gnome-screenshot/wip/exalm/libhandy: 2/3] interactive-dialog: Port to libhandy




commit 0f7d97478bda96adfd0aebc3ac77b24576a820a9
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Jul 31 16:10:56 2020 +0500

    interactive-dialog: Port to libhandy

 data/ui/screenshot-interactive-dialog.ui | 308 ++++++++++++++-----------------
 src/screenshot-interactive-dialog.c      |  31 +---
 src/screenshot-interactive-dialog.h      |   5 +-
 3 files changed, 146 insertions(+), 198 deletions(-)
---
diff --git a/data/ui/screenshot-interactive-dialog.ui b/data/ui/screenshot-interactive-dialog.ui
index 4b22d98..272b388 100644
--- a/data/ui/screenshot-interactive-dialog.ui
+++ b/data/ui/screenshot-interactive-dialog.ui
@@ -2,127 +2,170 @@
 <!-- Generated with glade 3.22.0 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
-  <template class="ScreenshotInteractiveDialog" parent="GtkApplicationWindow">
+  <template class="ScreenshotInteractiveDialog" parent="HdyApplicationWindow">
     <property name="resizable">False</property>
     <property name="window-position">center</property>
     <child>
       <object class="GtkBox">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="halign">center</property>
-        <property name="valign">center</property>
         <property name="orientation">vertical</property>
-        <property name="spacing">24</property>
-        <property name="margin">24</property>
         <child>
-          <object class="GtkBox">
+          <object class="HdyHeaderBar">
             <property name="visible">True</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
+            <property name="show_close_button">True</property>
+            <child>
+              <object class="GtkButton" id="capture_button">
+                <property name="label" translatable="yes">_Take Screenshot</property>
+                <property name="visible">True</property>
+                <property name="receives_default">True</property>
+                <property name="action_name">app.screen-shot</property>
+                <property name="use_underline">True</property>
+                <property name="can-default">True</property>
+                <signal name="clicked" handler="capture_button_clicked_cb"/>
+                <style>
+                  <class name="suggested-action"/>
+                </style>
+              </object>
+            </child>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkMenuButton" id="menu">
                 <property name="visible">True</property>
-                <property name="halign">start</property>
-                <property name="label" translatable="yes">Capture Area</property>
+                <property name="receives_default">True</property>
+                <property name="menu-model">primary_menu</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon_name">open-menu-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+            <property name="spacing">24</property>
+            <property name="margin">24</property>
+            <property name="orientation">vertical</property>
             <child>
               <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="homogeneous">True</property>
-                <style>
-                  <class name="linked"/>
-                </style>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
                 <child>
-                  <object class="GtkRadioButton" id="screen">
+                  <object class="GtkLabel">
                     <property name="visible">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="draw_indicator">False</property>
-                    <property name="group">selection</property>
-                    <signal name="toggled" handler="screen_toggled_cb"/>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="visible">True</property>
-                        <property name="margin">12</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkImage" id="screen_img">
-                            <property name="visible">True</property>
-                            <property name="icon_name">display-symbolic</property>
-                            <property name="pixel_size">32</property>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">_Screen</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">screen</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                    <property name="halign">start</property>
+                    <property name="label" translatable="yes">Capture Area</property>
                   </object>
                 </child>
                 <child>
-                  <object class="GtkRadioButton" id="window">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="active">True</property>
-                    <property name="draw_indicator">False</property>
-                    <property name="group">screen</property>
-                    <signal name="toggled" handler="window_toggled_cb"/>
+                    <property name="homogeneous">True</property>
+                    <style>
+                      <class name="linked"/>
+                    </style>
                     <child>
-                      <object class="GtkBox">
+                      <object class="GtkRadioButton" id="screen">
                         <property name="visible">True</property>
-                        <property name="margin">12</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkImage" id="window_img">
-                            <property name="visible">True</property>
-                            <property name="icon_name">window-symbolic</property>
-                            <property name="pixel_size">32</property>
-                          </object>
-                        </child>
+                        <property name="receives_default">True</property>
+                        <property name="draw_indicator">False</property>
+                        <property name="group">selection</property>
+                        <signal name="toggled" handler="screen_toggled_cb"/>
                         <child>
-                          <object class="GtkLabel">
+                          <object class="GtkBox">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">_Window</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">window</property>
+                            <property name="margin">12</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkImage" id="screen_img">
+                                <property name="visible">True</property>
+                                <property name="icon_name">display-symbolic</property>
+                                <property name="pixel_size">32</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">_Screen</property>
+                                <property name="use_underline">True</property>
+                                <property name="mnemonic_widget">screen</property>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
                     </child>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkRadioButton" id="selection">
-                    <property name="visible">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="draw_indicator">False</property>
-                    <property name="group">screen</property>
-                    <signal name="toggled" handler="selection_toggled_cb"/>
                     <child>
-                      <object class="GtkBox">
+                      <object class="GtkRadioButton" id="window">
                         <property name="visible">True</property>
-                        <property name="margin">12</property>
-                        <property name="orientation">vertical</property>
-                        <property name="spacing">6</property>
+                        <property name="receives_default">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">False</property>
+                        <property name="group">screen</property>
+                        <signal name="toggled" handler="window_toggled_cb"/>
                         <child>
-                          <object class="GtkImage" id="selection_img">
+                          <object class="GtkBox">
                             <property name="visible">True</property>
-                            <property name="icon_name">selection-symbolic</property>
-                            <property name="pixel_size">32</property>
+                            <property name="margin">12</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkImage" id="window_img">
+                                <property name="visible">True</property>
+                                <property name="icon_name">window-symbolic</property>
+                                <property name="pixel_size">32</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">_Window</property>
+                                <property name="use_underline">True</property>
+                                <property name="mnemonic_widget">window</property>
+                              </object>
+                            </child>
                           </object>
                         </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="selection">
+                        <property name="visible">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="draw_indicator">False</property>
+                        <property name="group">screen</property>
+                        <signal name="toggled" handler="selection_toggled_cb"/>
                         <child>
-                          <object class="GtkLabel">
+                          <object class="GtkBox">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes">Se_lection</property>
-                            <property name="use_underline">True</property>
+                            <property name="margin">12</property>
+                            <property name="orientation">vertical</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkImage" id="selection_img">
+                                <property name="visible">True</property>
+                                <property name="icon_name">selection-symbolic</property>
+                                <property name="pixel_size">32</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkLabel">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Se_lection</property>
+                                <property name="use_underline">True</property>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
@@ -131,68 +174,34 @@
                 </child>
               </object>
             </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkListBox" id="listbox">
-            <property name="visible">True</property>
-            <property name="selection_mode">none</property>
-            <property name="activate_on_single_click">False</property>
-            <property name="width_request">360</property>
-            <style>
-              <class name="frame"/>
-            </style>
             <child>
-              <object class="GtkListBoxRow" id="pointer_row">
+              <object class="GtkListBox" id="listbox">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="selection_mode">none</property>
+                <property name="width_request">360</property>
+                <style>
+                  <class name="preferences"/>
+                </style>
                 <child>
-                  <object class="GtkBox">
+                  <object class="HdyActionRow" id="pointer_row">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="margin">12</property>
-                    <property name="spacing">10</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="halign">start</property>
-                        <property name="hexpand">True</property>
-                        <property name="label" translatable="yes">Show _Pointer</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">pointer</property>
-                      </object>
-                    </child>
+                    <property name="title" translatable="yes">Show _Pointer</property>
+                    <property name="use_underline">True</property>
+                    <property name="activatable-widget">pointer</property>
                     <child>
                       <object class="GtkSwitch" id="pointer">
                         <property name="visible">True</property>
+                        <property name="valign">center</property>
                         <signal name="state-set" handler="include_pointer_toggled_cb"/>
                       </object>
                     </child>
                   </object>
                 </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkListBoxRow" id="delayrow">
-                <property name="visible">True</property>
                 <child>
-                  <object class="GtkBox">
+                  <object class="HdyActionRow">
                     <property name="visible">True</property>
-                    <property name="margin-top">9</property>
-                    <property name="margin-bottom">9</property>
-                    <property name="margin-start">12</property>
-                    <property name="margin-end">12</property>
-                    <property name="spacing">10</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="halign">start</property>
-                        <property name="hexpand">True</property>
-                        <property name="label" translatable="yes">_Delay in Seconds</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">delay</property>
-                      </object>
-                    </child>
+                    <property name="title" translatable="yes">_Delay in Seconds</property>
+                    <property name="use_underline">True</property>
                     <child>
                       <object class="GtkSpinButton" id="delay">
                         <property name="visible">True</property>
@@ -202,6 +211,7 @@
                         <property name="climb_rate">1</property>
                         <property name="snap_to_ticks">True</property>
                         <property name="numeric">True</property>
+                        <property name="valign">center</property>
                         <signal name= "value-changed" handler="delay_spin_value_changed_cb"/>
                       </object>
                     </child>
@@ -213,42 +223,6 @@
         </child>
       </object>
     </child>
-    <child type="titlebar">
-      <object class="GtkHeaderBar">
-        <property name="visible">True</property>
-        <property name="show_close_button">True</property>
-        <child>
-          <object class="GtkButton" id="capture_button">
-            <property name="label" translatable="yes">_Take Screenshot</property>
-            <property name="visible">True</property>
-            <property name="receives_default">True</property>
-            <property name="action_name">app.screen-shot</property>
-            <property name="use_underline">True</property>
-            <property name="can-default">True</property>
-            <signal name="clicked" handler="capture_button_clicked_cb"/>
-            <style>
-              <class name="suggested-action"/>
-            </style>
-          </object>
-        </child>
-        <child>
-          <object class="GtkMenuButton" id="menu">
-            <property name="visible">True</property>
-            <property name="receives_default">True</property>
-            <property name="menu-model">primary_menu</property>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">True</property>
-                <property name="icon_name">open-menu-symbolic</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
-        </child>
-      </object>
-    </child>
   </template>
   <object class="GtkAdjustment" id="delay_adjustment">
     <property name="lower">0</property>
diff --git a/src/screenshot-interactive-dialog.c b/src/screenshot-interactive-dialog.c
index ab866b3..a7b15ba 100644
--- a/src/screenshot-interactive-dialog.c
+++ b/src/screenshot-interactive-dialog.c
@@ -36,7 +36,7 @@ typedef enum {
 
 struct _ScreenshotInteractiveDialog
 {
-  GtkApplicationWindow parent_instance;
+  HdyApplicationWindow parent_instance;
 
   GtkWidget *listbox;
   GtkWidget *pointer;
@@ -46,7 +46,7 @@ struct _ScreenshotInteractiveDialog
   GtkWidget *selection;
 };
 
-G_DEFINE_TYPE (ScreenshotInteractiveDialog, screenshot_interactive_dialog, GTK_TYPE_APPLICATION_WINDOW)
+G_DEFINE_TYPE (ScreenshotInteractiveDialog, screenshot_interactive_dialog, HDY_TYPE_APPLICATION_WINDOW)
 
 enum {
   SIGNAL_CAPTURE,
@@ -114,28 +114,6 @@ capture_button_clicked_cb (GtkButton                   *button,
   g_signal_emit (self, signals[SIGNAL_CAPTURE], 0);
 }
 
-static void
-header_func (GtkListBoxRow               *row,
-             GtkListBoxRow               *before,
-             ScreenshotInteractiveDialog *self)
-{
-  GtkWidget *current;
-
-  if (before == NULL)
-    {
-      gtk_list_box_row_set_header (row, NULL);
-      return;
-    }
-
-  current = gtk_list_box_row_get_header (row);
-  if (current == NULL)
-    {
-      current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
-      gtk_widget_show (current);
-      gtk_list_box_row_set_header (row, current);
-    }
-}
-
 static void
 screenshot_interactive_dialog_class_init (ScreenshotInteractiveDialogClass *klass)
 {
@@ -171,11 +149,6 @@ screenshot_interactive_dialog_init (ScreenshotInteractiveDialog *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  gtk_list_box_set_header_func (GTK_LIST_BOX (self->listbox),
-                                (GtkListBoxUpdateHeaderFunc) header_func,
-                                self,
-                                NULL);
-
   if (screenshot_config->take_window_shot)
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->window), TRUE);
 
diff --git a/src/screenshot-interactive-dialog.h b/src/screenshot-interactive-dialog.h
index cd98c1d..e506b66 100644
--- a/src/screenshot-interactive-dialog.h
+++ b/src/screenshot-interactive-dialog.h
@@ -22,13 +22,14 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
+#define HANDY_USE_UNSTABLE_API
+#include <handy.h>
 
 G_BEGIN_DECLS
 
 #define SCREENSHOT_TYPE_INTERACTIVE_DIALOG (screenshot_interactive_dialog_get_type())
 
-G_DECLARE_FINAL_TYPE (ScreenshotInteractiveDialog, screenshot_interactive_dialog, SCREENSHOT, 
INTERACTIVE_DIALOG, GtkApplicationWindow)
+G_DECLARE_FINAL_TYPE (ScreenshotInteractiveDialog, screenshot_interactive_dialog, SCREENSHOT, 
INTERACTIVE_DIALOG, HdyApplicationWindow)
 
 ScreenshotInteractiveDialog *screenshot_interactive_dialog_new (GtkApplication *app);
 


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