void glade_gtk_action_bar_add_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox, *gchild; gint num_children; gchar *special_child_type; gbox = glade_widget_get_from_gobject (object); special_child_type = g_object_get_data (child, "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), GTK_WIDGET (child)); return; } /* Try to remove the last placeholder if any, this way GtkBox`s size will not be changed. */ if (!glade_widget_superuser () && !GLADE_IS_PLACEHOLDER (child)) { GList *l, *children; children = gtk_container_get_children (GTK_CONTAINER (object)); for (l = g_list_last (children); l; l = g_list_previous (l)) { GtkWidget *child_widget = l->data; if (GLADE_IS_PLACEHOLDER (child_widget)) { gtk_container_remove (GTK_CONTAINER (object), child_widget); break; } } g_list_free (children); } gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); num_children = glade_gtk_action_bar_get_num_children (object); glade_widget_property_set (gbox, "size", num_children); if (glade_widget_superuser ()) return; gchild = glade_widget_get_from_gobject (child); /* Packing props arent around when parenting during a glade_widget_dup() */ if (gchild && glade_widget_get_packing_properties (gchild)) glade_widget_pack_property_set (gchild, "position", num_children - 1); }
void glade_gtk_action_bar_remove_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox; gint size; gchar *special_child_type; gbox = glade_widget_get_from_gobject (object); special_child_type = g_object_get_data (child, "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { GtkWidget *w; w = glade_placeholder_new (); g_object_set_data (G_OBJECT (w), "special-child-type", "center"); gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), w); return; } gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); if (!glade_widget_superuser ()) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } }
void glade_gtk_header_bar_add_child (GladeWidgetAdaptor *adaptor, GObject *parent, GObject *child) { GladeWidget *gbox, *gchild; gint size; gchar *special_child_type; gchild = glade_widget_get_from_gobject (child); if (gchild) glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE); special_child_type = g_object_get_data (child, "special-child-type"); d(g_message ("Add %s %p (special: %s)", GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "child", child, special_child_type)); if (special_child_type && !strcmp (special_child_type, "title")) { gtk_header_bar_set_custom_title (GTK_HEADER_BAR (parent), GTK_WIDGET (child)); return; } GWA_GET_CLASS (GTK_TYPE_CONTAINER)->add (adaptor, parent, child); gbox = glade_widget_get_from_gobject (parent); if (!glade_widget_superuser ()) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } }
void glade_gtk_box_remove_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox; gint size; gchar *special_child_type; g_return_if_fail (GTK_IS_BOX (object)); g_return_if_fail (GTK_IS_WIDGET (child)); gbox = glade_widget_get_from_gobject (object); special_child_type = g_object_get_data (child, "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { GtkWidget *w; w = glade_placeholder_new (); g_object_set_data (G_OBJECT (w), "special-child-type", "center"); gtk_box_set_center_widget (GTK_BOX (object), w); return; } gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); if (glade_widget_superuser () == FALSE) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } fix_response_id_on_child (gbox, child, FALSE); }
/* Shared with other classes */ void glade_gtk_sync_use_appearance (GladeWidget *gwidget) { GladeProperty *prop; gboolean use_appearance; /* This is the kind of thing we avoid doing at project load time ;-) */ if (glade_widget_superuser ()) return; prop = glade_widget_get_property (gwidget, "use-action-appearance"); use_appearance = FALSE; glade_property_get (prop, &use_appearance); if (use_appearance) { glade_property_set (prop, FALSE); glade_property_set (prop, TRUE); } }
static void glade_gtk_entry_changed (GtkEditable * editable, GladeWidget * gentry) { const gchar *text, *text_prop; GladeProperty *prop; gboolean use_buffer; if (glade_widget_superuser ()) return; text = gtk_entry_get_text (GTK_ENTRY (editable)); glade_widget_property_get (gentry, "text", &text_prop); glade_widget_property_get (gentry, "use-entry-buffer", &use_buffer); if (use_buffer == FALSE && g_strcmp0 (text, text_prop)) { if ((prop = glade_widget_get_property (gentry, "text"))) glade_command_set_property (prop, text); } }
void glade_gtk_header_bar_replace_child (GladeWidgetAdaptor * adaptor, GObject * container, GObject * current, GObject * new_widget) { GladeWidget *gbox; gchar *special_child_type; gint size; special_child_type = g_object_get_data (G_OBJECT (current), "special-child-type"); d(g_message ("Replace %s %p (special: %s) with %s %p", GLADE_IS_PLACEHOLDER (current) ? "placeholder" : "child", current, special_child_type, GLADE_IS_PLACEHOLDER (new_widget) ? "placeholder" : "child", new_widget)); if (special_child_type && !strcmp (special_child_type, "title")) { g_object_set_data (G_OBJECT (new_widget), "special-child-type", "title"); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (container), GTK_WIDGET (new_widget)); return; } else g_object_set_data (G_OBJECT (new_widget), "special-child-type", NULL); GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor, container, current, new_widget); gbox = glade_widget_get_from_gobject (container); if (!glade_widget_superuser ()) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } }
void glade_gtk_header_bar_child_set_property (GladeWidgetAdaptor *adaptor, GObject *container, GObject *child, const gchar *property_name, const GValue *value) { GladeWidget *gbox; gint size; d(g_message ("Set child prop %s %s\n", g_type_name_from_instance (child), property_name)); gtk_container_child_set_property (GTK_CONTAINER (container), GTK_WIDGET (child), property_name, value); gbox = glade_widget_get_from_gobject (container); if (!glade_widget_superuser ()) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } }
void glade_gtk_header_bar_remove_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox; gint size; gchar *special_child_type; special_child_type = g_object_get_data (child, "special-child-type"); d(g_message ("Remove %s %p (special: %s)", GLADE_IS_PLACEHOLDER (child) ? "placeholder" : "child", child, special_child_type)); if (special_child_type && !strcmp (special_child_type, "title")) { GtkWidget *replacement = glade_placeholder_new (); g_object_set_data (G_OBJECT (replacement), "special-child-type", "title"); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (object), replacement); return; } gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); /* Synchronize number of placeholders, this should trigger the set_property method with the * correct value (not the arbitrary number of children currently in the headerbar) */ gbox = glade_widget_get_from_gobject (object); if (!glade_widget_superuser ()) { glade_widget_property_get (gbox, "size", &size); glade_widget_property_set (gbox, "size", size); } }
void glade_gtk_box_add_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GladeWidget *gbox, *gchild; gint num_children; gchar *special_child_type; g_return_if_fail (GTK_IS_BOX (object)); g_return_if_fail (GTK_IS_WIDGET (child)); gbox = glade_widget_get_from_gobject (object); special_child_type = g_object_get_data (child, "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { gtk_box_set_center_widget (GTK_BOX (object), GTK_WIDGET (child)); return; } /* Try to remove the last placeholder if any, this way GtkBox`s size will not be changed. */ if (glade_widget_superuser () == FALSE && !GLADE_IS_PLACEHOLDER (child)) { GList *l, *children; GtkBox *box = GTK_BOX (object); children = gtk_container_get_children (GTK_CONTAINER (box)); for (l = g_list_last (children); l; l = g_list_previous (l)) { GtkWidget *child_widget = l->data; if (GLADE_IS_PLACEHOLDER (child_widget)) { gtk_container_remove (GTK_CONTAINER (box), child_widget); break; } } g_list_free (children); } gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); num_children = glade_gtk_box_get_num_children (object); glade_widget_property_set (gbox, "size", num_children); gchild = glade_widget_get_from_gobject (child); /* The "Remove Slot" operation only makes sence on placeholders, * otherwise its a "Delete" operation on the child widget. */ if (gchild) glade_widget_set_pack_action_visible (gchild, "remove_slot", FALSE); fix_response_id_on_child (gbox, child, TRUE); if (glade_widget_superuser ()) return; /* Packing props arent around when parenting during a glade_widget_dup() */ if (gchild && glade_widget_get_packing_properties (gchild)) glade_widget_pack_property_set (gchild, "position", num_children - 1); }