[balsa/gtk4: 168/311] libbalsa-misc: Install libbalsa_button_box_button




commit d45f900042770496966d12d31deac29c03e94fe5
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Fri Aug 28 17:15:13 2020 -0400

    libbalsa-misc: Install libbalsa_button_box_button
    
    Create a button widget that can be added to a GtkBox with the same
    look as a GtkButton in a GtkButtonBox
    
    modified:   libbalsa/misc.c
    modified:   libbalsa/misc.h

 libbalsa/misc.c | 35 +++++++++++------------------------
 libbalsa/misc.h |  6 +++---
 2 files changed, 14 insertions(+), 27 deletions(-)
---
diff --git a/libbalsa/misc.c b/libbalsa/misc.c
index d7a108fe3..ae143d4e7 100644
--- a/libbalsa/misc.c
+++ b/libbalsa/misc.c
@@ -1254,14 +1254,16 @@ libbalsa_parser_options(void)
 }
 
 /*
- * libbalsa_add_mnemonic_button_to_box
+ * libbalsa_button_box_button
  *
- * Create a button widget and add it to a GtkBox with the same
- * look as a regular button in a GtkButtonBox; returns the button.
+ * Create a button widget that can be added to a GtkBox with the same
+ * look as a regular button in a GtkButtonBox
  *
- * markup: mnemonic text for the button;
- * box:    the box;
- * align:  how to align the button in its allocated space.
+ * markup:     mnemonic text for the button;
+ * size_group: managed by the caller, to make buttons the same size;
+               could be created as gtk_size_group_new(GTK_SIZE_GROUP_BOTH),
+               to ensure common widths and heights;
+ * align:      how to align the button in its allocated space.
  *
  * To replace a GtkButtonBox with the default GTK_BUTTONBOX_EDGE style,
  * align should be GTK_ALIGN_START for the first button, GTK_ALIGN_END
@@ -1270,32 +1272,20 @@ libbalsa_parser_options(void)
  * align should be GTK_ALIGN_CENTER for all buttons;
  * To replace a GtkButtonBox with style GTK_BUTTONBOX_EXPAND,
  * align should be GTK_ALIGN_FILL for all buttons.
- *
- * In the EDGE case with more than three buttons, and in the SPREAD case,
- * the spacing is not identical to GtkButtonBox's.
  */
 
 /* Margin to increase the width of the button, to approximate the look
  * of a GtkButtonBox; may be a pixel or two too small: */
 #define LIBBALSA_LABEL_MARGIN 12
 
-#define LIBBALSA_SIZE_GROUP_KEY "libbalsa-size-group-key"
-
 GtkWidget *
-libbalsa_add_mnemonic_button_to_box(const gchar *markup,
-                                    GtkWidget   *box,
-                                    GtkAlign     align)
+libbalsa_button_box_button(const gchar  *markup,
+                           GtkSizeGroup *size_group,
+                           GtkAlign      align)
 {
-    GtkSizeGroup *size_group;
     GtkWidget *label;
     GtkWidget *button;
 
-    size_group = g_object_get_data(G_OBJECT(box), LIBBALSA_SIZE_GROUP_KEY);
-    if (size_group == NULL) {
-        size_group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
-        g_object_set_data_full(G_OBJECT(box), LIBBALSA_SIZE_GROUP_KEY, size_group, g_object_unref);
-    }
-
     label = gtk_label_new(NULL);
     gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), markup);
     gtk_widget_set_margin_start(label, LIBBALSA_LABEL_MARGIN);
@@ -1307,9 +1297,6 @@ libbalsa_add_mnemonic_button_to_box(const gchar *markup,
     gtk_container_add(GTK_CONTAINER(button), label);
     gtk_widget_set_hexpand(button, TRUE);
     gtk_widget_set_halign(button, align);
-    gtk_widget_show(button);
-
-    gtk_container_add(GTK_CONTAINER(box), button);
 
     return button;
 }
diff --git a/libbalsa/misc.h b/libbalsa/misc.h
index 93b9e3c22..e8d3e6491 100644
--- a/libbalsa/misc.h
+++ b/libbalsa/misc.h
@@ -163,9 +163,9 @@ gchar *libbalsa_font_string_to_css(const gchar * font_string, const gchar * name
 void libbalsa_parser_options_init(void);
 GMimeParserOptions *libbalsa_parser_options(void);
 
-GtkWidget * libbalsa_add_mnemonic_button_to_box(const gchar *markup,
-                                                GtkWidget   *box,
-                                                GtkAlign     align);
+GtkWidget * libbalsa_button_box_button(const gchar  *markup,
+                                       GtkSizeGroup *size_group,
+                                       GtkAlign      align);
 
 
 #endif                         /* __LIBBALSA_MISC_H__ */


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