Commit eec1ef3e authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

GladeProjectProperties: fix target version loading

Make sure target version combo gets updated on project load.

Fix issue #480 "version field not always updated in XML"
parent c8493234
...@@ -129,7 +129,7 @@ typedef struct ...@@ -129,7 +129,7 @@ typedef struct
GtkWidget *css_filechooser; GtkWidget *css_filechooser;
GtkWidget *css_checkbutton; GtkWidget *css_checkbutton;
GHashTable *target_radios; GHashTable *target_combos;
/* License */ /* License */
GtkComboBox *license_comboboxtext; GtkComboBox *license_comboboxtext;
...@@ -169,7 +169,7 @@ glade_project_properties_init (GladeProjectProperties *properties) ...@@ -169,7 +169,7 @@ glade_project_properties_init (GladeProjectProperties *properties)
{ {
GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties); GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
priv->target_radios = g_hash_table_new_full (g_str_hash, g_str_equal, priv->target_combos = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL); g_free, NULL);
gtk_widget_init_template (GTK_WIDGET (properties)); gtk_widget_init_template (GTK_WIDGET (properties));
...@@ -262,7 +262,7 @@ glade_project_properties_finalize (GObject *object) ...@@ -262,7 +262,7 @@ glade_project_properties_finalize (GObject *object)
GladeProjectProperties *properties = GLADE_PROJECT_PROPERTIES (object); GladeProjectProperties *properties = GLADE_PROJECT_PROPERTIES (object);
GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties); GladeProjectPropertiesPrivate *priv = GLADE_PROJECT_PROPERTIES_PRIVATE(properties);
g_hash_table_destroy (priv->target_radios); g_hash_table_destroy (priv->target_combos);
G_OBJECT_CLASS (glade_project_properties_parent_class)->finalize (object); G_OBJECT_CLASS (glade_project_properties_parent_class)->finalize (object);
} }
...@@ -289,7 +289,7 @@ combobox_populate_from_catalog (GladeProjectProperties *properties, ...@@ -289,7 +289,7 @@ combobox_populate_from_catalog (GladeProjectProperties *properties,
version->major, version->major,
version->minor); version->minor);
gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT(combobox), position, name); gtk_combo_box_text_insert (GTK_COMBO_BOX_TEXT(combobox), position, name, name);
if (major == version->major && minor == version->minor) if (major == version->major && minor == version->minor)
gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), position); gtk_combo_box_set_active (GTK_COMBO_BOX(combobox), position);
...@@ -299,7 +299,7 @@ combobox_populate_from_catalog (GladeProjectProperties *properties, ...@@ -299,7 +299,7 @@ combobox_populate_from_catalog (GladeProjectProperties *properties,
(gchar *) glade_catalog_get_name (catalog)); (gchar *) glade_catalog_get_name (catalog));
} }
g_hash_table_insert (priv->target_radios, g_hash_table_insert (priv->target_combos,
g_strdup (glade_catalog_get_name (catalog)), g_strdup (glade_catalog_get_name (catalog)),
combobox); combobox);
} }
...@@ -1107,19 +1107,19 @@ project_targets_changed (GladeProject *project, ...@@ -1107,19 +1107,19 @@ project_targets_changed (GladeProject *project,
GladeCatalog *catalog = list->data; GladeCatalog *catalog = list->data;
GtkComboBox *combobox; GtkComboBox *combobox;
gint minor, major; gint minor, major;
const gchar *name;
/* Skip if theres only one option */ /* Skip if theres only one option */
if (g_list_length (glade_catalog_get_targets (catalog)) <= 1) if (g_list_length (glade_catalog_get_targets (catalog)) <= 1)
continue; continue;
/* Fetch the version for this project */ /* Fetch the version for this project */
glade_project_get_target_version (priv->project, name = glade_catalog_get_name (catalog);
glade_catalog_get_name (catalog), glade_project_get_target_version (priv->project, name, &major, &minor);
&major, &minor);
/* Fetch the radios for this catalog */ /* Fetch the radios for this catalog */
if (priv->target_radios && if (priv->target_combos &&
(combobox = g_hash_table_lookup (priv->target_radios, glade_catalog_get_name (catalog))) != NULL) (combobox = g_hash_table_lookup (priv->target_combos, name)) != NULL)
{ {
g_autofree gchar *id = NULL; g_autofree gchar *id = NULL;
id = g_strdup_printf ("%d.%d", major, minor); id = g_strdup_printf ("%d.%d", major, minor);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment