static void glade_eprop_string_list_finalize (GObject * object) { GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (object); GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object)); if (eprop_string_list->update_id) { g_source_remove (eprop_string_list->update_id); eprop_string_list->update_id = 0; } if (eprop_string_list->changed_id) { g_source_remove (eprop_string_list->changed_id); eprop_string_list->changed_id = 0; } if (eprop_string_list->pending_string_list) { glade_string_list_free (eprop_string_list->pending_string_list); eprop_string_list->pending_string_list = NULL; } /* Chain up */ G_OBJECT_CLASS (parent_class)->finalize (object); }
static void glade_gtk_widget_read_style_classes (GladeWidget * widget, GladeXmlNode * node) { GladeXmlNode *style_node; GladeXmlNode *class_node; GList *string_list = NULL; if ((style_node = glade_xml_search_child (node, GLADE_TAG_STYLE)) != NULL) { for (class_node = glade_xml_node_get_children (style_node); class_node; class_node = glade_xml_node_next (class_node)) { gchar *name; if (!glade_xml_node_verify (class_node, GLADE_TAG_CLASS)) continue; name = glade_xml_get_property_string (class_node, GLADE_TAG_NAME); string_list = glade_string_list_append (string_list, name, NULL, NULL, FALSE, NULL); g_free (name); } glade_widget_property_set (widget, "glade-style-classes", string_list); glade_string_list_free (string_list); } }
static void i18n_icon_activate (GtkCellRenderer *renderer, const gchar *path, GladeEditorProperty *eprop) { GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (eprop); GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); GtkTreeIter iter; guint index; GladeProperty *property = glade_editor_property_get_property (eprop); GList *string_list = NULL; GladeString *string; gtk_tree_model_get_iter (eprop_string_list->model, &iter, tree_path); gtk_tree_model_get (eprop_string_list->model, &iter, COLUMN_INDEX, &index, -1); glade_property_get (property, &string_list); string_list = glade_string_list_copy (string_list); string = g_list_nth_data (string_list, index); if (glade_editor_property_show_i18n_dialog (NULL, &string->string, &string->context, &string->comment, &string->translatable)) { eprop_string_list->editing_index = index; if (eprop_string_list->pending_string_list) glade_string_list_free (eprop_string_list->pending_string_list); eprop_string_list->pending_string_list = string_list; if (eprop_string_list->update_id == 0) eprop_string_list->update_id = g_idle_add ((GSourceFunc) update_string_list_idle, eprop); } else glade_string_list_free (string_list); gtk_tree_path_free (tree_path); }
static void glade_gtk_filter_read_strings (GladeWidget *widget, GladeXmlNode *node, FilterType type, const gchar *property_name) { GladeXmlNode *items_node; GladeXmlNode *item_node; GList *string_list = NULL; const gchar *string_group_tag; const gchar *string_tag; switch (type) { case FILTER_PATTERN: string_group_tag = GLADE_TAG_PATTERNS; string_tag = GLADE_TAG_PATTERN; break; case FILTER_MIME: string_group_tag = GLADE_TAG_MIME_TYPES; string_tag = GLADE_TAG_MIME_TYPE; break; case FILTER_APPLICATION: string_group_tag = GLADE_TAG_APPLICATIONS; string_tag = GLADE_TAG_APPLICATION; break; default: g_assert_not_reached (); break; } if ((items_node = glade_xml_search_child (node, string_group_tag)) != NULL) { for (item_node = glade_xml_node_get_children (items_node); item_node; item_node = glade_xml_node_next (item_node)) { gchar *str; if (!glade_xml_node_verify (item_node, string_tag)) continue; if ((str = glade_xml_get_content (item_node)) == NULL) continue; string_list = glade_string_list_append (string_list, str, NULL, NULL, FALSE, NULL); g_free (str); } glade_widget_property_set (widget, property_name, string_list); glade_string_list_free (string_list); } }
static void id_edited (GtkCellRendererText *renderer, gchar *path, gchar *new_text, GladeEditorProperty *eprop) { GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (eprop); GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); GtkTreeIter iter; guint index; GladeProperty *property = glade_editor_property_get_property (eprop); GList *string_list = NULL; GladeString *string; gtk_tree_model_get_iter (eprop_string_list->model, &iter, tree_path); gtk_tree_model_get (eprop_string_list->model, &iter, COLUMN_INDEX, &index, -1); glade_property_get (property, &string_list); if (string_list) string_list = glade_string_list_copy (string_list); string = g_list_nth_data (string_list, index); g_free (string->id); if (new_text && new_text[0]) string->id = g_strdup (new_text); else string->id = NULL; eprop_string_list->editing_index = index; if (eprop_string_list->pending_string_list) glade_string_list_free (eprop_string_list->pending_string_list); eprop_string_list->pending_string_list = string_list; if (eprop_string_list->update_id == 0) eprop_string_list->update_id = g_idle_add ((GSourceFunc) update_string_list_idle, eprop); gtk_tree_path_free (tree_path); }
static gboolean data_changed_idle (GladeEditorProperty *eprop) { GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (eprop); GladeProperty *property = glade_editor_property_get_property (eprop); GladeString *string, *copy; GList *string_list = NULL; GList *new_list = NULL; GtkTreeIter iter; guint index; /* Create a new list based on the order and contents * of the model state */ glade_property_get (property, &string_list); if (gtk_tree_model_get_iter_first (eprop_string_list->model, &iter)) { do { gtk_tree_model_get (eprop_string_list->model, &iter, COLUMN_INDEX, &index, -1); if ((string = g_list_nth_data (string_list, index)) != NULL) { copy = glade_string_copy (string); new_list = g_list_prepend (new_list, copy); } } while (gtk_tree_model_iter_next (eprop_string_list->model, &iter)); } new_list = g_list_reverse (new_list); if (eprop_string_list->pending_string_list) glade_string_list_free (eprop_string_list->pending_string_list); eprop_string_list->pending_string_list = new_list; /* We're already in an idle, just call it directly here */ update_string_list_idle (eprop); eprop_string_list->changed_id = 0; return FALSE; }
static void glade_gtk_combo_box_text_read_items (GladeWidget *widget, GladeXmlNode *node) { GladeXmlNode *items_node; GladeXmlNode *item_node; GList *string_list = NULL; if ((items_node = glade_xml_search_child (node, GLADE_TAG_ITEMS)) != NULL) { for (item_node = glade_xml_node_get_children (items_node); item_node; item_node = glade_xml_node_next (item_node)) { gchar *str, *comment, *context; gchar *id; gboolean translatable; if (!glade_xml_node_verify (item_node, GLADE_TAG_ITEM)) continue; if ((str = glade_xml_get_content (item_node)) == NULL) continue; id = glade_xml_get_property_string (item_node, GLADE_TAG_ID); context = glade_xml_get_property_string (item_node, GLADE_TAG_CONTEXT); comment = glade_xml_get_property_string (item_node, GLADE_TAG_COMMENT); translatable = glade_xml_get_property_boolean (item_node, GLADE_TAG_TRANSLATABLE, FALSE); string_list = glade_string_list_append (string_list, str, comment, context, translatable, id); g_free (str); g_free (context); g_free (comment); g_free (id); } glade_widget_property_set (widget, "glade-items", string_list); glade_string_list_free (string_list); } }
static void string_edited (GtkCellRendererText *renderer, gchar *path, gchar *new_text, GladeEditorProperty *eprop) { GladeEPropStringList *eprop_string_list = GLADE_EPROP_STRING_LIST (eprop); GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); GtkTreeIter iter; gboolean dummy; guint index; GladeProperty *property = glade_editor_property_get_property (eprop); GList *string_list = NULL; gtk_tree_model_get_iter (eprop_string_list->model, &iter, tree_path); gtk_tree_model_get (eprop_string_list->model, &iter, COLUMN_INDEX, &index, COLUMN_DUMMY, &dummy, -1); glade_property_get (property, &string_list); if (string_list) string_list = glade_string_list_copy (string_list); if (dummy) { if (new_text && new_text[0] && strcmp (new_text, _("<Type Here>")) != 0) string_list = glade_string_list_append (string_list, new_text, NULL, NULL, eprop_string_list->translatable, NULL); } else if (new_text && new_text[0]) { GladeString *string = g_list_nth_data (string_list, index); g_free (string->string); string->string = g_strdup (new_text); } else { GList *node = g_list_nth (string_list, index); glade_string_free (node->data); string_list = g_list_delete_link (string_list, node); } eprop_string_list->editing_index = index; if (eprop_string_list->pending_string_list) glade_string_list_free (eprop_string_list->pending_string_list); eprop_string_list->pending_string_list = string_list; if (eprop_string_list->update_id == 0) eprop_string_list->update_id = g_idle_add ((GSourceFunc) update_string_list_idle, eprop); gtk_tree_path_free (tree_path); }