[gnome-calendar/gbsneto/gtk4: 19/34] meeting-row: Port to GTK4




commit ce888873d52dcfb809861647fc6f5b64dd9b00b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jan 14 11:46:08 2022 -0300

    meeting-row: Port to GTK4

 src/gui/gcal-meeting-row.c  | 16 ++++-----
 src/gui/gcal-meeting-row.h  |  4 +--
 src/gui/gcal-meeting-row.ui | 84 +++++++++------------------------------------
 3 files changed, 24 insertions(+), 80 deletions(-)
---
diff --git a/src/gui/gcal-meeting-row.c b/src/gui/gcal-meeting-row.c
index ac2a0c54..1877968a 100644
--- a/src/gui/gcal-meeting-row.c
+++ b/src/gui/gcal-meeting-row.c
@@ -27,15 +27,12 @@
 
 struct _GcalMeetingRow
 {
-  GtkListBoxRow       parent_instance;
-
-  GtkLabel           *service_label;
-  GtkLabel           *url_label;
+  AdwActionRow        parent_instance;
 
   gchar              *url;
 };
 
-G_DEFINE_TYPE (GcalMeetingRow, gcal_meeting_row, GTK_TYPE_LIST_BOX_ROW)
+G_DEFINE_TYPE (GcalMeetingRow, gcal_meeting_row, ADW_TYPE_ACTION_ROW)
 
 enum
 {
@@ -86,10 +83,10 @@ setup_meeting (GcalMeetingRow *self)
 {
   g_autofree gchar *markup_url = NULL;
 
-  gtk_label_set_label (self->service_label, get_service_name_from_url (self->url));
+  adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), get_service_name_from_url (self->url));
 
   markup_url = g_strdup_printf ("<a href=\"%s\">%s</a>", self->url, self->url);
-  gtk_label_set_markup (self->url_label, markup_url);
+  adw_action_row_set_subtitle (ADW_ACTION_ROW (self), markup_url);
 }
 
 
@@ -187,10 +184,9 @@ gcal_meeting_row_class_init (GcalMeetingRowClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/calendar/ui/gui/gcal-meeting-row.ui");
 
-  gtk_widget_class_bind_template_child (widget_class, GcalMeetingRow, service_label);
-  gtk_widget_class_bind_template_child (widget_class, GcalMeetingRow, url_label);
-
   gtk_widget_class_bind_template_callback (widget_class, on_join_button_clicked_cb);
+
+  gtk_widget_class_set_css_name (widget_class, "meetingrow");
 }
 
 static void
diff --git a/src/gui/gcal-meeting-row.h b/src/gui/gcal-meeting-row.h
index 51367021..ffccb989 100644
--- a/src/gui/gcal-meeting-row.h
+++ b/src/gui/gcal-meeting-row.h
@@ -20,13 +20,13 @@
 
 #pragma once
 
-#include <gtk/gtk.h>
+#include <adwaita.h>
 
 G_BEGIN_DECLS
 
 #define GCAL_TYPE_MEETING_ROW (gcal_meeting_row_get_type())
 
-G_DECLARE_FINAL_TYPE (GcalMeetingRow, gcal_meeting_row, GCAL, MEETING_ROW, GtkListBoxRow)
+G_DECLARE_FINAL_TYPE (GcalMeetingRow, gcal_meeting_row, GCAL, MEETING_ROW, AdwActionRow)
 
 GtkWidget*           gcal_meeting_row_new                        (const gchar        *url);
 
diff --git a/src/gui/gcal-meeting-row.ui b/src/gui/gcal-meeting-row.ui
index 71d4b96f..8a3cb614 100644
--- a/src/gui/gcal-meeting-row.ui
+++ b/src/gui/gcal-meeting-row.ui
@@ -1,76 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.14"/>
-  <template class="GcalMeetingRow" parent="GtkListBoxRow">
-    <property name="visible">True</property>
+  <template class="GcalMeetingRow" parent="AdwActionRow">
     <property name="activatable">False</property>
-    <focus-chain>
-      <widget name="url_label"/>
-      <widget name="join_button"/>
-    </focus-chain>
 
     <child>
-      <object class="GtkGrid">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin-start">12</property>
-        <property name="margin-end">12</property>
-        <property name="margin-top">6</property>
-        <property name="margin-bottom">6</property>
-        <property name="column-spacing">18</property>
-
-        <child>
-          <object class="GtkLabel" id="service_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="xalign">0.0</property>
-            <style>
-              <class name="title" />
-            </style>
-          </object>
-          <packing>
-            <property name="top-attach">0</property>
-            <property name="left-attach">0</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkLabel" id="url_label">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="xalign">0.0</property>
-            <style>
-              <class name="subtitle" />
-              <class name="dim-label" />
-            </style>
-          </object>
-          <packing>
-            <property name="top-attach">1</property>
-            <property name="left-attach">0</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkButton" id="join_button">
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
-            <property name="halign">center</property>
-            <property name="valign">center</property>
-            <!-- Translators: "Join" as in "Join meeting" -->
-            <property name="label" translatable="yes">Join</property>
-            <style>
-              <class name="suggested-action" />
-            </style>
-            <signal name="clicked" handler="on_join_button_clicked_cb" object="GcalMeetingRow" swapped="no" 
/>
-          </object>
-          <packing>
-            <property name="top-attach">0</property>
-            <property name="left-attach">1</property>
-            <property name="height">2</property>
-          </packing>
-        </child>
+      <object class="GtkButton" id="join_button">
+        <property name="can-focus">True</property>
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <!-- Translators: "Join" as in "Join meeting" -->
+        <property name="label" translatable="yes">Join</property>
+        <layout>
+          <property name="row">0</property>
+          <property name="column">1</property>
+          <property name="row-span">2</property>
+        </layout>
+        <style>
+          <class name="suggested-action" />
+        </style>
+        <signal name="clicked" handler="on_join_button_clicked_cb" object="GcalMeetingRow" swapped="no" />
       </object>
     </child>
 


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