[gnome-text-editor] languagerow: use AdwActionRow



commit 4fdf3c42724687590d93922e05353671b24e1f56
Author: Christian Hergert <chergert redhat com>
Date:   Wed Dec 1 09:59:20 2021 -0800

    languagerow: use AdwActionRow
    
    We can reuse AdwActionRow for this and ensure we have consistent styling
    with other parts of the application.
    
    The check image moves all the way to the right, which isn't exactly what
    I wanted, but that is a fine trade-off.

 src/editor-language-row-private.h |  4 +++-
 src/editor-language-row.c         |  9 ++++-----
 src/editor-language-row.ui        | 29 +++++++----------------------
 3 files changed, 14 insertions(+), 28 deletions(-)
---
diff --git a/src/editor-language-row-private.h b/src/editor-language-row-private.h
index 228835b..a18d468 100644
--- a/src/editor-language-row-private.h
+++ b/src/editor-language-row-private.h
@@ -20,13 +20,15 @@
 
 #pragma once
 
+#include <adwaita.h>
+
 #include "editor-types-private.h"
 
 G_BEGIN_DECLS
 
 #define EDITOR_TYPE_LANGUAGE_ROW (editor_language_row_get_type())
 
-G_DECLARE_FINAL_TYPE (EditorLanguageRow, editor_language_row, EDITOR, LANGUAGE_ROW, GtkListBoxRow)
+G_DECLARE_FINAL_TYPE (EditorLanguageRow, editor_language_row, EDITOR, LANGUAGE_ROW, AdwActionRow)
 
 EditorLanguageRow *_editor_language_row_new          (GtkSourceLanguage *language);
 GtkSourceLanguage *_editor_language_row_get_language (EditorLanguageRow *self);
diff --git a/src/editor-language-row.c b/src/editor-language-row.c
index 4bc3376..7d645dc 100644
--- a/src/editor-language-row.c
+++ b/src/editor-language-row.c
@@ -26,13 +26,12 @@
 
 struct _EditorLanguageRow
 {
-  GtkListBoxRow      parent_instance;
+  AdwActionRow       parent_instance;
 
   GtkSourceLanguage *language;
   gchar             *id;
   gchar             *name;
 
-  GtkLabel          *title;
   GtkImage          *image;
 };
 
@@ -42,7 +41,7 @@ enum {
   N_PROPS
 };
 
-G_DEFINE_TYPE (EditorLanguageRow, editor_language_row, GTK_TYPE_LIST_BOX_ROW)
+G_DEFINE_TYPE (EditorLanguageRow, editor_language_row, ADW_TYPE_ACTION_ROW)
 
 static GParamSpec *properties [N_PROPS];
 
@@ -60,7 +59,7 @@ editor_language_row_constructed (GObject *object)
     return;
 
   name = gtk_source_language_get_name (self->language);
-  gtk_label_set_label (self->title, name);
+  adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), name);
 }
 
 static void
@@ -136,7 +135,6 @@ editor_language_row_class_init (EditorLanguageRowClass *klass)
   g_object_class_install_properties (object_class, N_PROPS, properties);
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/TextEditor/ui/editor-language-row.ui");
-  gtk_widget_class_bind_template_child (widget_class, EditorLanguageRow, title);
   gtk_widget_class_bind_template_child (widget_class, EditorLanguageRow, image);
 }
 
@@ -152,6 +150,7 @@ _editor_language_row_new (GtkSourceLanguage *language)
   g_return_val_if_fail (!language || GTK_SOURCE_IS_LANGUAGE (language), NULL);
 
   return g_object_new (EDITOR_TYPE_LANGUAGE_ROW,
+                       "activatable", TRUE,
                        "language", language,
                        NULL);
 }
diff --git a/src/editor-language-row.ui b/src/editor-language-row.ui
index 7a7ffd0..8da2b80 100644
--- a/src/editor-language-row.ui
+++ b/src/editor-language-row.ui
@@ -1,29 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="4.0"/>
-  <template class="EditorLanguageRow" parent="GtkListBoxRow">
-    <property name="selectable">false</property>
+  <requires lib="libadwaita" version="1.0"/>
+  <template class="EditorLanguageRow" parent="AdwActionRow">
     <child>
-      <object class="GtkBox">
-        <property name="orientation">horizontal</property>
-        <property name="margin-top">6</property>
-        <property name="margin-bottom">6</property>
-        <property name="margin-start">12</property>
-        <property name="margin-end">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkLabel" id="title">
-            <property name="halign">start</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkImage" id="image">
-            <property name="halign">start</property>
-            <property name="hexpand">true</property>
-            <property name="icon-name">object-select-symbolic</property>
-            <property name="visible">false</property>
-          </object>
-        </child>
+      <object class="GtkImage" id="image">
+        <property name="halign">start</property>
+        <property name="hexpand">false</property>
+        <property name="icon-name">object-select-symbolic</property>
+        <property name="visible">false</property>
       </object>
     </child>
   </template>


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