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_action_bar_set_property (GladeWidgetAdaptor * adaptor, GObject * object, const gchar * id, const GValue * value) { if (!strcmp (id, "use-center-child")) { GtkWidget *child; if (g_value_get_boolean (value)) { child = gtk_action_bar_get_center_widget (GTK_ACTION_BAR (object)); if (!child) child = glade_placeholder_new (); g_object_set_data (G_OBJECT (child), "special-child-type", "center"); } else child = NULL; gtk_action_bar_set_center_widget (GTK_ACTION_BAR (object), child); } else if (!strcmp (id, "size")) glade_gtk_action_bar_set_size (object, value); else GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value); }
static void toggle_center (GtkCheckButton *button, GParamSpec *pspec, GtkActionBar *bar) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) { GtkWidget *button; button = gtk_button_new_with_label ("Center"); gtk_widget_show (button); gtk_action_bar_set_center_widget (bar, button); } else { gtk_action_bar_set_center_widget (bar, NULL); } }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *box; GtkWidget *footer; GtkWidget *button; GtkWidget *content; GtkCssProvider *provider; gtk_init (NULL, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_style_context_add_class (gtk_widget_get_style_context (window), "main"); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, css, -1); gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (window), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_USER); change_header (NULL, window); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box); footer = gtk_action_bar_new (); gtk_action_bar_set_center_widget (GTK_ACTION_BAR (footer), gtk_check_button_new_with_label ("Middle")); button = gtk_toggle_button_new_with_label ("Custom"); g_signal_connect (button, "clicked", G_CALLBACK (change_header), window); gtk_action_bar_pack_start (GTK_ACTION_BAR (footer), button); button = gtk_button_new_with_label ("Subtitle"); g_signal_connect (button, "clicked", G_CALLBACK (change_subtitle), NULL); gtk_action_bar_pack_end (GTK_ACTION_BAR (footer), button); button = gtk_button_new_with_label ("Fullscreen"); gtk_action_bar_pack_end (GTK_ACTION_BAR (footer), button); g_signal_connect (button, "clicked", G_CALLBACK (toggle_fullscreen), window); gtk_box_pack_end (GTK_BOX (box), footer, FALSE, FALSE); content = gtk_image_new_from_icon_name ("start-here-symbolic", GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (content), 512); gtk_box_pack_start (GTK_BOX (box), content, FALSE, TRUE); gtk_widget_show_all (window); gtk_main (); gtk_widget_destroy (window); return 0; }
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_replace_child (GladeWidgetAdaptor * adaptor, GObject * container, GObject * current, GObject * new_widget) { gint position; GtkPackType pack_type; gchar *special_child_type; special_child_type = g_object_get_data (G_OBJECT (current), "special-child-type"); if (special_child_type && !strcmp (special_child_type, "center")) { g_object_set_data (G_OBJECT (new_widget), "special-child-type", "center"); gtk_action_bar_set_center_widget (GTK_ACTION_BAR (container), GTK_WIDGET (new_widget)); return; } gtk_container_child_get (GTK_CONTAINER (container), GTK_WIDGET (current), "position", &position, "pack-type", &pack_type, NULL); gtk_container_remove (GTK_CONTAINER (container), GTK_WIDGET (current)); gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (new_widget)); gtk_container_child_set (GTK_CONTAINER (container), GTK_WIDGET (new_widget), "position", position, "pack-type", pack_type, NULL); }