[seahorse/pgp/update-listify-key-props] pgp: Use HdyExpanderRow for subkey list row




commit ee24971b4a5a57b187554dbf6902da1f4b49ad59
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Jul 31 18:28:09 2021 +0200

    pgp: Use HdyExpanderRow for subkey list row

 pgp/seahorse-pgp-subkey-list-box-row.ui | 252 +++++++++++++-------------------
 pgp/seahorse-pgp-subkey-list-box.c      |  43 +-----
 pgp/seahorse-pgp-subkey-list-box.h      |   2 +-
 3 files changed, 107 insertions(+), 190 deletions(-)
---
diff --git a/pgp/seahorse-pgp-subkey-list-box-row.ui b/pgp/seahorse-pgp-subkey-list-box-row.ui
index 9b1d0ba8..1caa65a6 100644
--- a/pgp/seahorse-pgp-subkey-list-box-row.ui
+++ b/pgp/seahorse-pgp-subkey-list-box-row.ui
@@ -17,18 +17,36 @@
       </item>
     </section>
   </menu>
-  <template class="SeahorsePgpSubkeyListBoxRow" parent="GtkListBoxRow">
+  <template class="SeahorsePgpSubkeyListBoxRow" parent="HdyExpanderRow">
     <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child type="action">
+      <object class="GtkImage" id="status_box">
+        <property name="visible">True</property>
+        <property name="icon-name">dialog-warning-symbolic</property>
+        <style>
+          <class name="pgp-subkey-status-box"/>
+        </style>
+      </object>
+      <packing>
+        <property name="top_attach">0</property>
+        <property name="left_attach">2</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkGrid">
         <property name="visible">True</property>
+        <property name="margin">12</property>
+        <property name="row-spacing">12</property>
         <property name="column-spacing">12</property>
-        <property name="margin">6</property>
         <child>
-          <object class="GtkLabel" id="keyid_label">
+          <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="selectable">True</property>
-            <property name="xalign">0</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">Usages</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
           </object>
           <packing>
             <property name="top_attach">0</property>
@@ -38,193 +56,119 @@
         <child>
           <object class="GtkBox" id="usages_box">
             <property name="visible">True</property>
-            <property name="hexpand">True</property>
             <property name="spacing">3</property>
             <property name="orientation">horizontal</property>
           </object>
           <packing>
             <property name="top_attach">0</property>
-            <property name="left_attach">2</property>
+            <property name="left_attach">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkImage" id="status_box">
+          <object class="GtkLabel">
             <property name="visible">True</property>
-            <property name="icon-name">emblem-important-symbolic</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">Fingerprint</property>
             <style>
-              <class name="pgp-subkey-status-box" />
+              <class name="dim-label"/>
             </style>
           </object>
           <packing>
-            <property name="top_attach">0</property>
+            <property name="top_attach">1</property>
+            <property name="left_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="fingerprint_label">
+            <property name="visible">True</property>
+            <property name="selectable">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="top_attach">1</property>
             <property name="left_attach">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="expires_label">
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">Type</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
+          </object>
+          <packing>
+            <property name="top_attach">2</property>
+            <property name="left_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="algo_label">
             <property name="visible">True</property>
             <property name="xalign">0</property>
           </object>
           <packing>
-            <property name="top_attach">0</property>
-            <property name="left_attach">3</property>
+            <property name="top_attach">2</property>
+            <property name="left_attach">1</property>
           </packing>
         </child>
         <child>
-          <object class="GtkRevealer" id="revealer">
+          <object class="GtkLabel">
             <property name="visible">True</property>
-            <child>
-              <object class="GtkBox">
-                <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <object class="GtkSeparator">
-                    <property name="visible">True</property>
-                    <property name="margin">12</property>
-                  </object>
-                </child>
-                <child>
-                  <object class="GtkGrid">
-                    <property name="visible">True</property>
-                    <property name="row-spacing">6</property>
-                    <property name="column-spacing">6</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Fingerprint</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="top_attach">0</property>
-                        <property name="left_attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="fingerprint_label">
-                        <property name="visible">True</property>
-                        <property name="selectable">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">0</property>
-                        <property name="left_attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Type</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="left_attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="algo_label">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="left_attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="xalign">1</property>
-                        <property name="label" translatable="yes">Created</property>
-                        <style>
-                          <class name="dim-label"/>
-                        </style>
-                      </object>
-                      <packing>
-                        <property name="top_attach">2</property>
-                        <property name="left_attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="created_label">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">2</property>
-                        <property name="left_attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkBox" id="action_box">
-                        <property name="visible">True</property>
-                        <property name="orientation">horizontal</property>
-                        <property name="spacing">3</property>
-                        <property name="margin">6</property>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Change expiry date</property>
-                            <property name="action-name">subkey.change-expires</property>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Revoke</property>
-                            <property name="action-name">subkey.revoke</property>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkButton">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Delete</property>
-                            <property name="action-name">subkey.delete</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="top_attach">3</property>
-                        <property name="left_attach">0</property>
-                        <property name="width">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
+            <property name="xalign">1</property>
+            <property name="label" translatable="yes">Created</property>
+            <style>
+              <class name="dim-label"/>
+            </style>
           </object>
           <packing>
-            <property name="top_attach">1</property>
+            <property name="top_attach">3</property>
             <property name="left_attach">0</property>
-            <property name="width">5</property>
           </packing>
         </child>
         <child>
-          <object class="GtkButton">
+          <object class="GtkLabel" id="created_label">
             <property name="visible">True</property>
-            <property name="halign">end</property>
-            <property name="action-name">subkey.toggle-reveal</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="top_attach">3</property>
+            <property name="left_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="action_box">
+            <property name="visible">True</property>
+            <property name="orientation">horizontal</property>
+            <property name="spacing">6</property>
+            <property name="margin">6</property>
             <child>
-              <object class="GtkImage" id="reveal_icon">
+              <object class="GtkButton">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="icon_name">pan-down-symbolic</property>
+                <property name="label" translatable="yes">Change expiry date</property>
+                <property name="action-name">subkey.change-expires</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Revoke</property>
+                <property name="action-name">subkey.revoke</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Delete</property>
+                <property name="action-name">subkey.delete</property>
               </object>
             </child>
-            <style>
-              <class name="flat"/>
-            </style>
           </object>
           <packing>
-            <property name="top_attach">0</property>
-            <property name="left_attach">4</property>
+            <property name="top_attach">4</property>
+            <property name="left_attach">0</property>
+            <property name="width">2</property>
           </packing>
         </child>
       </object>
diff --git a/pgp/seahorse-pgp-subkey-list-box.c b/pgp/seahorse-pgp-subkey-list-box.c
index d2ff687b..4ee2dc45 100644
--- a/pgp/seahorse-pgp-subkey-list-box.c
+++ b/pgp/seahorse-pgp-subkey-list-box.c
@@ -154,19 +154,15 @@ seahorse_pgp_subkey_list_box_get_key (SeahorsePgpSubkeyListBox *self)
 /* SeahorsePhpSubkeyListBoxRow */
 
 struct _SeahorsePgpSubkeyListBoxRow {
-    GtkListBoxRow parent_instance;
+    HdyExpanderRow parent_instance;
 
     SeahorsePgpSubkey *subkey;
 
     GSimpleActionGroup *action_group;
 
     GtkWidget *status_box;
-    GtkWidget *keyid_label;
     GtkWidget *usages_box;
-    GtkWidget *revealer;
-    GtkWidget *reveal_icon;
     GtkWidget *algo_label;
-    GtkWidget *expires_label;
     GtkWidget *created_label;
     GtkWidget *fingerprint_label;
     GtkWidget *action_box;
@@ -179,7 +175,7 @@ enum {
 };
 static GParamSpec *row_props[ROW_N_PROPS] = { NULL, };
 
-G_DEFINE_TYPE (SeahorsePgpSubkeyListBoxRow, seahorse_pgp_subkey_list_box_row, GTK_TYPE_LIST_BOX_ROW)
+G_DEFINE_TYPE (SeahorsePgpSubkeyListBoxRow, seahorse_pgp_subkey_list_box_row, HDY_TYPE_EXPANDER_ROW)
 
 static GtkWindow *
 get_toplevel_window (SeahorsePgpSubkeyListBoxRow *row)
@@ -242,24 +238,7 @@ on_subkey_change_expires (GSimpleAction *action, GVariant *param, void *user_dat
     gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
-static void
-on_subkey_toggle_reveal (GSimpleAction *action, GVariant *param, void *user_data)
-{
-    SeahorsePgpSubkeyListBoxRow *row = SEAHORSE_PGP_SUBKEY_LIST_BOX_ROW (user_data);
-    gboolean reveal;
-    const char *icon_name;
-
-    reveal = !gtk_revealer_get_reveal_child (GTK_REVEALER (row->revealer));
-    gtk_revealer_set_reveal_child (GTK_REVEALER (row->revealer), reveal);
-
-    icon_name = reveal? "pan-up-symbolic" : "pan-down-symbolic";
-    gtk_image_set_from_icon_name (GTK_IMAGE (row->reveal_icon),
-                                  icon_name,
-                                  GTK_ICON_SIZE_BUTTON);
-}
-
 static const GActionEntry SUBKEY_ACTIONS[] = {
-    { "toggle-reveal", on_subkey_toggle_reveal },
     { "delete", on_subkey_delete },
     { "revoke", on_subkey_revoke },
     { "change-expires", on_subkey_change_expires },
@@ -297,8 +276,12 @@ update_row (SeahorsePgpSubkeyListBoxRow *row)
     }
 
     /* Set the key id */
-    gtk_label_set_text (GTK_LABEL (row->keyid_label),
-                        seahorse_pgp_subkey_get_keyid (row->subkey));
+    hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (row),
+                                   seahorse_pgp_subkey_get_keyid (row->subkey));
+    expires = seahorse_pgp_subkey_get_expires (row->subkey);
+    expires_str = expires? g_date_time_format (expires, "Expires on %x")
+                         : g_strdup (_("Never expires"));
+    hdy_expander_row_set_subtitle (HDY_EXPANDER_ROW (row), expires_str);
 
     /* Add the usage tags */
     usages = seahorse_pgp_subkey_get_usages (row->subkey, &descriptions);
@@ -314,12 +297,6 @@ update_row (SeahorsePgpSubkeyListBoxRow *row)
                                      "pgp-subkey-usage-label");
     }
 
-    /* Expiration date */
-    expires = seahorse_pgp_subkey_get_expires (row->subkey);
-    expires_str = expires? g_date_time_format (expires, "Expires on %x")
-                         : g_strdup (_("Never expires"));
-    gtk_label_set_text (GTK_LABEL (row->expires_label), expires_str);
-
     /* Stuff that is hidden by default (but can be shown with the revealer) */
 
     /* Full fingerprint */
@@ -445,12 +422,8 @@ seahorse_pgp_subkey_list_box_row_class_init (SeahorsePgpSubkeyListBoxRowClass *k
     gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Seahorse/seahorse-pgp-subkey-list-box-row.ui");
 
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, status_box);
-    gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, keyid_label);
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, usages_box);
-    gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, revealer);
-    gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, reveal_icon);
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, algo_label);
-    gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, expires_label);
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, created_label);
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, fingerprint_label);
     gtk_widget_class_bind_template_child (widget_class, SeahorsePgpSubkeyListBoxRow, action_box);
diff --git a/pgp/seahorse-pgp-subkey-list-box.h b/pgp/seahorse-pgp-subkey-list-box.h
index 63ff170a..589ac98e 100644
--- a/pgp/seahorse-pgp-subkey-list-box.h
+++ b/pgp/seahorse-pgp-subkey-list-box.h
@@ -37,6 +37,6 @@ SeahorsePgpKey *     seahorse_pgp_subkey_list_box_get_key            (SeahorsePg
 #define SEAHORSE_PGP_TYPE_SUBKEY_LIST_BOX_ROW (seahorse_pgp_subkey_list_box_row_get_type ())
 G_DECLARE_FINAL_TYPE (SeahorsePgpSubkeyListBoxRow, seahorse_pgp_subkey_list_box_row,
                       SEAHORSE_PGP, SUBKEY_LIST_BOX_ROW,
-                      GtkListBoxRow)
+                      HdyExpanderRow)
 
 SeahorsePgpSubkey *   seahorse_pgp_subkey_list_box_row_get_subkey    (SeahorsePgpSubkeyListBoxRow *self);


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