[gnome-control-center/wip/carlosg/calibrator-fixes: 38/45] wacom: Update/unbreak calibrator




commit 1777a42aefe95975139685c30e8b2a852675828b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Feb 10 00:03:07 2022 +0100

    wacom: Update/unbreak calibrator
    
    It got to a building state in the GTK4 port, but was broken at
    runtime. Update event handlers and builder objects so it works again.

 panels/wacom/calibrator/calibrator-gui.c | 43 ++++++------------
 panels/wacom/calibrator/calibrator.css   | 10 ++---
 panels/wacom/calibrator/calibrator.ui    | 75 +++++++++++---------------------
 3 files changed, 45 insertions(+), 83 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator-gui.c b/panels/wacom/calibrator/calibrator-gui.c
index afe309917..dfa262774 100644
--- a/panels/wacom/calibrator/calibrator-gui.c
+++ b/panels/wacom/calibrator/calibrator-gui.c
@@ -79,10 +79,11 @@ calib_area_finish_idle_cb (CalibArea *area)
 static void
 set_success (CalibArea *area)
 {
-  GtkWidget *stack;
+  GtkWidget *stack, *image;
 
   stack = GTK_WIDGET (gtk_builder_get_object (area->builder, "stack"));
-  gtk_stack_set_visible_child_name (GTK_STACK (stack), "page1");
+  image = GTK_WIDGET (gtk_builder_get_object (area->builder, "success"));
+  gtk_stack_set_visible_child (GTK_STACK (stack), image);
 }
 
 static void
@@ -179,11 +180,11 @@ on_gesture_press (GtkGestureClick *gesture,
 }
 
 static gboolean
-on_key_release_event (GtkWidget       *widget,
-                      guint            keyval,
-                      guint            keycode,
-                      GdkModifierType  state,
-                      CalibArea       *area)
+on_key_release (GtkEventControllerKey *controller,
+               guint                  keyval,
+               guint                  keycode,
+               GdkModifierType        state,
+               CalibArea             *area)
 {
   if (area->success || keyval != GDK_KEY_Escape)
     return GDK_EVENT_PROPAGATE;
@@ -192,20 +193,6 @@ on_key_release_event (GtkWidget       *widget,
   return GDK_EVENT_STOP;
 }
 
-static gboolean
-on_focus_out_event (GtkWidget *widget,
-                    GdkEvent  *event,
-                    CalibArea *area)
-{
-  if (area->success)
-    return FALSE;
-
-  /* If the calibrator window loses focus, simply bail out... */
-  calib_area_notify_finish (area);
-
-  return FALSE;
-}
-
 static void
 on_clock_finished (CcClock   *clock,
                    CalibArea *area)
@@ -260,6 +247,7 @@ calib_area_new (GdkDisplay     *display,
   CalibArea *calib_area;
   GdkRectangle rect;
   GtkGesture *click;
+  GtkEventController *key;
 
   g_return_val_if_fail (callback, NULL);
 
@@ -302,18 +290,10 @@ calib_area_new (GdkDisplay     *display,
 
   calib_area->calibrator.geometry = rect;
 
-  g_signal_connect (calib_area->window,
-                    "key-release-event",
-                    G_CALLBACK (on_key_release_event),
-                    calib_area);
   g_signal_connect (calib_area->window,
                     "close-request",
                     G_CALLBACK (on_close_request),
                     calib_area);
-  g_signal_connect (calib_area->window,
-                    "focus-out-event",
-                    G_CALLBACK(on_focus_out_event),
-                    calib_area);
   g_signal_connect (calib_area->window,
                     "notify::fullscreened",
                     G_CALLBACK (on_fullscreen),
@@ -325,6 +305,11 @@ calib_area_new (GdkDisplay     *display,
                     G_CALLBACK (on_gesture_press), calib_area);
   gtk_widget_add_controller (calib_area->window, GTK_EVENT_CONTROLLER (click));
 
+  key = gtk_event_controller_key_new ();
+  g_signal_connect (key, "key-released",
+                    G_CALLBACK (on_key_release), calib_area);
+  gtk_widget_add_controller (calib_area->window, key);
+
   gtk_window_fullscreen_on_monitor (GTK_WINDOW (calib_area->window), monitor);
   gtk_widget_show (calib_area->window);
 
diff --git a/panels/wacom/calibrator/calibrator.css b/panels/wacom/calibrator/calibrator.css
index cf5fcedc2..462c766c8 100644
--- a/panels/wacom/calibrator/calibrator.css
+++ b/panels/wacom/calibrator/calibrator.css
@@ -26,14 +26,14 @@
 }
 
 @keyframes target-enabled-animation {
-    0%   { background-size: 0px }
-    90%  { background-size: 120px }
-    100% { background-size: 100px }
+    0%   { background-size: 0px; }
+    90%  { background-size: 120px; }
+    100% { background-size: 100px; }
 }
 
 @keyframes target-disabled-animation {
-    0%   { background-size: 100px }
-    100% { background-size: 0px }
+    0%   { background-size: 100px; }
+    100% { background-size: 0px; }
 }
 
 #calibrator #target:not(disabled) {
diff --git a/panels/wacom/calibrator/calibrator.ui b/panels/wacom/calibrator/calibrator.ui
index 81b0ee11b..f2fc2c564 100644
--- a/panels/wacom/calibrator/calibrator.ui
+++ b/panels/wacom/calibrator/calibrator.ui
@@ -1,15 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.20"/>
+  <requires lib="gtk" version="4.0"/>
   <object class="GtkWindow" id="window">
     <property name="name">calibrator</property>
-    <child>
+    <property name="child">
       <object class="GtkStack" id="stack">
         <property name="transition_duration">0</property>
         <child>
           <object class="GtkGrid">
-            <property name="row_homogeneous">True</property>
-            <property name="column_homogeneous">True</property>
+            <property name="row_homogeneous">1</property>
+            <property name="column_homogeneous">1</property>
             <child>
               <object class="GtkBox">
                 <property name="orientation">vertical</property>
@@ -22,48 +22,48 @@
                 <child>
                   <object class="GtkBox" id="box1">
                     <property name="orientation">vertical</property>
-                    <property name="vexpand">True</property>
+                    <property name="vexpand">1</property>
                   </object>
                 </child>
                 <child>
-                  <object class="CcClock" id="clock" />
+                  <object class="CcClock" id="clock"/>
                 </child>
                 <child>
                   <object class="GtkBox" id="box2">
                     <property name="orientation">vertical</property>
-                    <property name="vexpand">True</property>
+                    <property name="vexpand">1</property>
                     <child>
                       <object class="GtkRevealer" id="title_revealer">
                         <property name="transition_duration">300</property>
-                        <child>
+                        <property name="child">
                           <object class="GtkLabel">
                             <property name="name">title</property>
-                            <property name="label" translatable="yes">Screen Calibration</property>
+                            <property name="label" translatable="1">Screen Calibration</property>
                           </object>
-                        </child>
+                        </property>
                       </object>
                     </child>
                     <child>
                       <object class="GtkRevealer" id="subtitle_revealer">
                         <property name="transition_duration">300</property>
-                        <child>
+                        <property name="child">
                           <object class="GtkLabel">
                             <property name="name">subtitle</property>
-                            <property name="label" translatable="yes">Please tap the target markers as they 
appear on screen to calibrate the tablet.</property>
+                            <property name="label" translatable="1">Please tap the target markers as they 
appear on screen to calibrate the tablet.</property>
                           </object>
-                        </child>
+                        </property>
                       </object>
                     </child>
                     <child>
                       <object class="GtkRevealer" id="error_revealer">
                         <property name="transition_type">crossfade</property>
                         <property name="transition_duration">500</property>
-                        <child>
+                        <property name="child">
                           <object class="GtkLabel">
                             <property name="name">error</property>
-                            <property name="label" translatable="yes">Mis-click detected, 
restarting…</property>
+                            <property name="label" translatable="1">Mis-click detected, 
restarting…</property>
                           </object>
-                        </child>
+                        </property>
                       </object>
                     </child>
                   </object>
@@ -71,12 +71,11 @@
               </object>
             </child>
             <child>
-              <object class="GtkEventBox" id="target1">
+              <object class="GtkImage" id="target1">
                 <property name="name">target</property>
                 <property name="width_request">100</property>
                 <property name="height_request">100</property>
-                <property name="visible_window">True</property>
-                <property name="sensitive">False</property>
+                <property name="sensitive">0</property>
                 <layout>
                   <property name="column">0</property>
                   <property name="row">0</property>
@@ -86,12 +85,11 @@
               </object>
             </child>
             <child>
-              <object class="GtkEventBox" id="target2">
+              <object class="GtkImage" id="target2">
                 <property name="name">target</property>
                 <property name="width_request">100</property>
                 <property name="height_request">100</property>
-                <property name="visible_window">True</property>
-                <property name="sensitive">False</property>
+                <property name="sensitive">0</property>
                 <layout>
                   <property name="column">6</property>
                   <property name="row">0</property>
@@ -101,12 +99,11 @@
               </object>
             </child>
             <child>
-              <object class="GtkEventBox" id="target3">
+              <object class="GtkImage" id="target3">
                 <property name="name">target</property>
                 <property name="width_request">100</property>
                 <property name="height_request">100</property>
-                <property name="visible_window">True</property>
-                <property name="sensitive">False</property>
+                <property name="sensitive">0</property>
                 <layout>
                   <property name="column">0</property>
                   <property name="row">6</property>
@@ -116,12 +113,11 @@
               </object>
             </child>
             <child>
-              <object class="GtkEventBox" id="target4">
+              <object class="GtkImage" id="target4">
                 <property name="name">target</property>
                 <property name="width_request">100</property>
                 <property name="height_request">100</property>
-                <property name="visible_window">True</property>
-                <property name="sensitive">False</property>
+                <property name="sensitive">0</property>
                 <layout>
                   <property name="column">6</property>
                   <property name="row">6</property>
@@ -130,35 +126,16 @@
                 </layout>
               </object>
             </child>
-            <child>
-              <object class="GtkRevealer">
-                <property name="transition_type">none</property>
-                <property name="transition_duration">0</property>
-                <layout>
-                  <property name="column">0</property>
-                  <property name="row">0</property>
-                  <property name="column-span">8</property>
-                  <property name="row-span">8</property>
-                </layout>
-              </object>
-            </child>
           </object>
-          <layout>
-            <property name="name">page0</property>
-          </layout>
         </child>
         <child>
-          <object class="GtkImage">
+          <object class="GtkImage" id="success">
             <property name="pixel_size">300</property>
             <property name="icon_name">emblem-ok-symbolic</property>
           </object>
-          <layout>
-            <property name="name">page1</property>
-            <property name="position">1</property>
-          </layout>
         </child>
       </object>
-    </child>
+    </property>
   </object>
   <object class="GtkSizeGroup">
     <property name="mode">vertical</property>


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