summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-05 16:34:20 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-05 16:40:16 -0300
commit114124702e7ba506be754ef0cbb0c94a09153ad5 (patch)
tree4fada5056799e4a886fb401ad4ef763b6b5a1080
parentae53150aa3fad46a0b39c3a17268dd7300a5ae39 (diff)
downloadglade-114124702e7ba506be754ef0cbb0c94a09153ad5.tar.gz
GladeProjectProperties: improve toolkit target version selection
Use a combobox instead of radio buttons to select libraries target version because it was making the dialog too big.
-rw-r--r--gladeui/glade-project-properties.c160
-rw-r--r--gladeui/glade-project-properties.ui188
2 files changed, 163 insertions, 185 deletions
diff --git a/gladeui/glade-project-properties.c b/gladeui/glade-project-properties.c
index f7795a54..2763db04 100644
--- a/gladeui/glade-project-properties.c
+++ b/gladeui/glade-project-properties.c
@@ -60,7 +60,7 @@ static void verify_clicked (GtkWidget *b
GladeProjectProperties *properties);
static void on_domain_entry_changed (GtkWidget *entry,
GladeProjectProperties *properties);
-static void target_button_clicked (GtkWidget *widget,
+static void target_combobox_changed (GtkWidget *widget,
GladeProjectProperties *properties);
static void on_glade_project_properties_hide (GtkWidget *widget,
GladeProjectProperties *properties);
@@ -99,7 +99,7 @@ typedef struct
/* Properties */
GtkWidget *project_wide_radio;
GtkWidget *toplevel_contextual_radio;
- GtkWidget *toolkit_box;
+ GtkWidget *toolkit_grid;
GtkWidget *resource_default_radio;
GtkWidget *resource_relative_radio;
@@ -191,7 +191,7 @@ glade_project_properties_class_init (GladeProjectPropertiesClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, domain_entry);
gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, template_checkbutton);
gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, template_combobox);
- gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, toolkit_box);
+ gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, toolkit_grid);
gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, css_filechooser);
gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, css_checkbutton);
@@ -239,85 +239,83 @@ glade_project_properties_finalize (GObject *object)
}
static void
-target_version_box_fill (GladeProjectProperties *properties)
+combobox_populate_from_catalog (GladeProjectProperties *properties,
+ GtkWidget *combobox,
+ GladeCatalog *catalog)
{
GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
GladeProject *project = priv->project;
- GtkWidget *vbox = priv->toolkit_box;
- GtkWidget *label, *active_radio, *target_radio, *hbox;
- GList *list, *targets;
+ gint minor, major, position;
+ GList *targets;
- /* Add stuff to vbox */
- for (list = glade_app_get_catalogs (); list; list = g_list_next (list))
+ glade_project_get_target_version (project,
+ glade_catalog_get_name (catalog),
+ &major, &minor);
+
+ for (targets = glade_catalog_get_targets (catalog), position = 0;
+ targets; targets = targets->next, position++)
+ {
+ GladeTargetableVersion *version = targets->data;
+ g_autofree gchar *name = g_strdup_printf ("%d.%d",
+ version->major,
+ version->minor);
+
+ gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT(combobox), position, name);
+ if (major == version->major && minor == version->minor)
+ gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), position);
+
+ g_signal_connect (G_OBJECT (combobox), "changed",
+ G_CALLBACK (target_combobox_changed), properties);
+ g_object_set_data (G_OBJECT (combobox), "catalog",
+ (gchar *) glade_catalog_get_name (catalog));
+ }
+
+ g_hash_table_insert (priv->target_radios,
+ g_strdup (glade_catalog_get_name (catalog)),
+ combobox);
+}
+
+static void
+target_version_box_fill (GladeProjectProperties *properties)
+{
+ GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
+ GtkWidget *grid = priv->toolkit_grid;
+ GtkWidget *label, *combobox;
+ static gint n_columns = 3;
+ gint i, j, left;
+ GList *list;
+
+
+ /* Add stuff to the toolkit grid */
+ for (list = glade_app_get_catalogs (), i = 0, j = 0; list;
+ list = g_list_next (list))
{
GladeCatalog *catalog = list->data;
- gint minor, major;
/* Skip if theres only one option */
if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
continue;
- glade_project_get_target_version (project,
- glade_catalog_get_name (catalog),
- &major, &minor);
-
/* Special case to mark GTK+ in upper case */
if (strcmp (glade_catalog_get_name (catalog), "gtk+") == 0)
- label = gtk_label_new ("GTK+");
+ label = gtk_label_new ("GTK");
else
label = gtk_label_new (glade_catalog_get_name (catalog));
- gtk_widget_set_halign (label, GTK_ALIGN_START);
+ left = (i % n_columns) * 2;
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_grid_attach (GTK_GRID (grid), label, left, j, 1, 1);
gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 2);
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-
- active_radio = target_radio = NULL;
-
- for (targets = glade_catalog_get_targets (catalog);
- targets; targets = targets->next)
- {
- GladeTargetableVersion *version = targets->data;
- gchar *name = g_strdup_printf ("%d.%d",
- version->major,
- version->minor);
-
- if (!target_radio)
- target_radio = gtk_radio_button_new_with_label (NULL, name);
- else
- target_radio =
- gtk_radio_button_new_with_label_from_widget
- (GTK_RADIO_BUTTON (target_radio), name);
- g_free (name);
- g_signal_connect (G_OBJECT (target_radio), "clicked",
- G_CALLBACK (target_button_clicked), properties);
-
- g_object_set_data (G_OBJECT (target_radio), "version", version);
- g_object_set_data (G_OBJECT (target_radio), "catalog",
- (gchar *) glade_catalog_get_name (catalog));
-
- gtk_widget_show (target_radio);
- gtk_box_pack_end (GTK_BOX (hbox), target_radio, TRUE, TRUE, 2);
-
- if (major == version->major && minor == version->minor)
- active_radio = target_radio;
-
- }
+ combobox = gtk_combo_box_text_new ();
+ gtk_widget_set_margin_end (combobox, 8);
+ combobox_populate_from_catalog (properties, combobox, catalog);
+ gtk_grid_attach (GTK_GRID (grid), combobox, left + 1, j, 1, 1);
+ gtk_widget_show (combobox);
- if (active_radio)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (active_radio), TRUE);
- g_hash_table_insert (priv->target_radios,
- g_strdup (glade_catalog_get_name (catalog)),
- gtk_radio_button_get_group (GTK_RADIO_BUTTON
- (active_radio)));
- }
- else
- g_warning ("Corrupt catalog versions");
-
- gtk_widget_show (hbox);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
+ i++;
+ if (i % n_columns == 0)
+ j++;
}
}
@@ -415,19 +413,22 @@ glade_project_properties_set_property (GObject *object,
* Callbacks *
********************************************************/
static void
-target_button_clicked (GtkWidget *widget,
- GladeProjectProperties *properties)
+target_combobox_changed (GtkWidget *widget,
+ GladeProjectProperties *properties)
{
GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
- GladeTargetableVersion *version;
- gchar *catalog;
+ g_autofree gchar *version = NULL;
+ gchar *catalog;
+ gint major, minor;
if (priv->ignore_ui_cb)
return;
- version = g_object_get_data (G_OBJECT (widget), "version");
+ version = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
catalog = g_object_get_data (G_OBJECT (widget), "catalog");
- glade_command_set_project_target (priv->project, catalog, version->major, version->minor);
+
+ if (sscanf (version, "%d.%d", &major, &minor) == 2)
+ glade_command_set_project_target (priv->project, catalog, major, minor);
}
static void
@@ -981,15 +982,13 @@ project_targets_changed (GladeProject *project,
{
GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
GList *list;
- GSList *radios, *l;
-
priv->ignore_ui_cb = TRUE;
/* For each catalog */
for (list = glade_app_get_catalogs (); list; list = g_list_next (list))
{
- GladeTargetableVersion *version;
GladeCatalog *catalog = list->data;
+ GtkComboBox *combobox;
gint minor, major;
/* Skip if theres only one option */
@@ -1003,20 +1002,11 @@ project_targets_changed (GladeProject *project,
/* Fetch the radios for this catalog */
if (priv->target_radios &&
- (radios = g_hash_table_lookup (priv->target_radios, glade_catalog_get_name (catalog))) != NULL)
+ (combobox = g_hash_table_lookup (priv->target_radios, glade_catalog_get_name (catalog))) != NULL)
{
- for (l = radios; l; l = l->next)
- {
- GtkWidget *radio = l->data;
-
- /* Activate the appropriate button for the project/catalog */
- version = g_object_get_data (G_OBJECT (radio), "version");
- if (version->major == major && version->minor == minor)
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);
- break;
- }
- }
+ g_autofree gchar *id = NULL;
+ id = g_strdup_printf ("%d.%d", major, minor);
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(combobox), id);
}
}
priv->ignore_ui_cb = FALSE;
diff --git a/gladeui/glade-project-properties.ui b/gladeui/glade-project-properties.ui
index eacd2402..a04798ea 100644
--- a/gladeui/glade-project-properties.ui
+++ b/gladeui/glade-project-properties.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.0
+<!-- Generated with glade 3.22.2
libgladeui - Glade UI Designer core library
Copyright (C) 2013 Tristan Van Berkom <tvb@gnome.org>
@@ -25,7 +25,7 @@ Authors:
-->
<interface domain="glade">
- <!-- interface-requires gtk+ 3.10 -->
+ <requires lib="gtk+" version="3.20"/>
<!-- interface-license-type lgplv2 -->
<!-- interface-name libgladeui -->
<!-- interface-description Glade UI Designer core library -->
@@ -55,11 +55,58 @@ Authors:
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<signal name="hide" handler="on_glade_project_properties_hide" swapped="no"/>
<signal name="response" handler="gtk_widget_hide" swapped="no"/>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="verify_button">
+ <property name="label" translatable="yes">_Verify</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Verify that the project does not use any properties,
+signals or widgets which are not available in the target version</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="verify_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label">_Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
@@ -90,14 +137,13 @@ Authors:
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="label" translatable="yes">Translation domain:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -111,8 +157,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -138,8 +182,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -148,15 +190,13 @@ Authors:
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_template_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -170,8 +210,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -180,15 +218,13 @@ Authors:
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_css_checkbutton_toggled" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -223,7 +259,7 @@ Authors:
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="resource_default_toggled" swapped="no"/>
@@ -232,7 +268,6 @@ Authors:
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">2</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -241,7 +276,7 @@ Authors:
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">resource_default_radio</property>
@@ -250,8 +285,6 @@ Authors:
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -260,7 +293,7 @@ Authors:
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="xalign">0</property>
+ <property name="halign">start</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">resource_default_radio</property>
@@ -269,8 +302,6 @@ Authors:
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -285,8 +316,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -301,8 +330,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -331,12 +358,37 @@ Authors:
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
- <object class="GtkBox" id="toolkit_box">
+ <object class="GtkGrid" id="toolkit_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_top">6</property>
- <property name="orientation">vertical</property>
+ <property name="row_spacing">4</property>
+ <property name="column_spacing">4</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
<child>
<placeholder/>
</child>
@@ -395,28 +447,24 @@ Authors:
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Name:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Copyright:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -431,36 +479,30 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Author(s):</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">License:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -479,8 +521,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -499,23 +539,19 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">Description:</property>
<property name="max_width_chars">5</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -530,8 +566,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -556,8 +590,6 @@ Authors:
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -617,50 +649,6 @@ Authors:
<property name="position">0</property>
</packing>
</child>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="verify_button">
- <property name="label" translatable="yes">_Verify</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes">Verify that the project does not use any properties,
-signals or widgets which are not available in the target version</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="verify_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- <property name="secondary">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="close_button">
- <property name="label" translatable="yes">_Close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">6</property>
- </packing>
- </child>
</object>
</child>
<action-widgets>