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; }
static void create_widgets (GtkActionBar *bar, GtkPackType pack_type, gint n) { GList *children, *l; GtkWidget *child; gint i; gchar *label; children = gtk_container_get_children (GTK_CONTAINER (bar)); for (l = children; l; l = l->next) { GtkPackType type; child = l->data; gtk_container_child_get (GTK_CONTAINER (bar), child, "pack-type", &type, NULL); if (type == pack_type) gtk_container_remove (GTK_CONTAINER (bar), child); } g_list_free (children); for (i = 0; i < n; i++) { label = g_strdup_printf ("%d", i); child = gtk_button_new_with_label (label); g_free (label); gtk_widget_show (child); if (pack_type == GTK_PACK_START) gtk_action_bar_pack_start (bar, child); else gtk_action_bar_pack_end (bar, child); } }
static void photos_preview_nav_buttons_constructed (GObject *object) { PhotosPreviewNavButtons *self = PHOTOS_PREVIEW_NAV_BUTTONS (object); PhotosPreviewNavButtonsPrivate *priv = self->priv; GtkStyleContext *context; GtkWidget *button; GtkWidget *image; GtkWidget *toolbar; gboolean is_rtl; const gchar *next_icon_name; const gchar *prev_icon_name; G_OBJECT_CLASS (photos_preview_nav_buttons_parent_class)->constructed (object); is_rtl = (gtk_widget_get_direction (priv->preview_view) == GTK_TEXT_DIR_RTL); prev_icon_name = is_rtl ? PHOTOS_ICON_GO_NEXT_SYMBOLIC : PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC; next_icon_name = is_rtl ? PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC : PHOTOS_ICON_GO_NEXT_SYMBOLIC; priv->prev_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->prev_widget, GTK_ALIGN_START); gtk_widget_set_margin_start (priv->prev_widget, 30); gtk_widget_set_margin_end (priv->prev_widget, 30); gtk_widget_set_valign (priv->prev_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (priv->prev_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->prev_widget); image = gtk_image_new_from_icon_name (prev_icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->prev_widget), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (photos_preview_nav_buttons_prev_clicked), self); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->next_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->next_widget, GTK_ALIGN_END); gtk_widget_set_margin_start (priv->next_widget, 30); gtk_widget_set_margin_end (priv->next_widget, 30); gtk_widget_set_valign (priv->next_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (priv->next_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->next_widget); image = gtk_image_new_from_icon_name (next_icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), image); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->next_widget), button); g_signal_connect_swapped (button, "clicked", G_CALLBACK (photos_preview_nav_buttons_next_clicked), self); g_signal_connect_swapped (button, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (button, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->toolbar_widget = gtk_revealer_new (); gtk_widget_set_halign (priv->toolbar_widget, GTK_ALIGN_FILL); gtk_widget_set_valign (priv->toolbar_widget, GTK_ALIGN_END); gtk_revealer_set_transition_type (GTK_REVEALER (priv->toolbar_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (priv->overlay), priv->toolbar_widget); toolbar = gtk_action_bar_new (); context = gtk_widget_get_style_context (toolbar); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (priv->toolbar_widget), toolbar); g_signal_connect_swapped (toolbar, "enter-notify-event", G_CALLBACK (photos_preview_nav_buttons_enter_notify), self); g_signal_connect_swapped (toolbar, "leave-notify-event", G_CALLBACK (photos_preview_nav_buttons_leave_notify), self); priv->favorite_button = gd_header_toggle_button_new (); gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (priv->favorite_button), PHOTOS_ICON_FAVORITE_SYMBOLIC); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->favorite_button); g_signal_connect_swapped (priv->favorite_button, "clicked", G_CALLBACK (photos_preview_nav_buttons_favorite_clicked), self); g_signal_connect_swapped (priv->overlay, "motion-notify-event", G_CALLBACK (photos_preview_nav_buttons_motion_notify), self); }
static void photos_selection_toolbar_init (PhotosSelectionToolbar *self) { PhotosSelectionToolbarPrivate *priv; GtkWidget *toolbar; self->priv = photos_selection_toolbar_get_instance_private (self); priv = self->priv; priv->item_listeners = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); toolbar = gtk_action_bar_new (); gtk_container_add (GTK_CONTAINER (self), toolbar); priv->toolbar_favorite = gd_header_toggle_button_new (); gd_header_button_set_symbolic_icon_name (GD_HEADER_BUTTON (priv->toolbar_favorite), PHOTOS_ICON_FAVORITE_SYMBOLIC); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_favorite); g_signal_connect (priv->toolbar_favorite, "clicked", G_CALLBACK (photos_selection_toolbar_favorite_clicked), self); priv->toolbar_open = gd_header_simple_button_new (); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_open), _("Open")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_open); g_signal_connect (priv->toolbar_open, "clicked", G_CALLBACK (photos_selection_toolbar_open_clicked), self); priv->toolbar_print = gd_header_simple_button_new (); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_print), _("Print")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_print); g_signal_connect (priv->toolbar_print, "clicked", G_CALLBACK (photos_selection_toolbar_print_clicked), self); priv->toolbar_trash = gd_header_simple_button_new (); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_trash), _("Delete")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_trash); g_signal_connect (priv->toolbar_trash, "clicked", G_CALLBACK (photos_selection_toolbar_trash_clicked), self); priv->toolbar_properties = gd_header_simple_button_new (); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_properties), _("Properties")); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->toolbar_properties); g_signal_connect (priv->toolbar_properties, "clicked", G_CALLBACK (photos_selection_toolbar_properties_clicked), self); priv->toolbar_collection = gd_header_simple_button_new (); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_collection), _("Add to Album")); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->toolbar_collection); g_signal_connect (priv->toolbar_collection, "clicked", G_CALLBACK (photos_selection_toolbar_collection_clicked), self); gtk_widget_show_all (GTK_WIDGET (self)); priv->item_mngr = photos_item_manager_dup_singleton (); priv->sel_cntrlr = photos_selection_controller_dup_singleton (); g_signal_connect (priv->sel_cntrlr, "selection-changed", G_CALLBACK (photos_selection_toolbar_selection_changed), self); g_signal_connect (priv->sel_cntrlr, "selection-mode-changed", G_CALLBACK (photos_selection_toolbar_selection_mode_changed), self); }
static void photos_selection_toolbar_init (PhotosSelectionToolbar *self) { PhotosSelectionToolbarPrivate *priv; GApplication *app; GtkWidget *toolbar; PhotosSearchContextState *state; self->priv = photos_selection_toolbar_get_instance_private (self); priv = self->priv; app = g_application_get_default (); state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app)); priv->item_listeners = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); toolbar = gtk_action_bar_new (); gtk_container_add (GTK_CONTAINER (self), toolbar); priv->toolbar_favorite = gtk_button_new (); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_favorite); g_signal_connect (priv->toolbar_favorite, "clicked", G_CALLBACK (photos_selection_toolbar_favorite_clicked), self); priv->toolbar_open = gtk_button_new_with_label (_("Open")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_open); g_signal_connect (priv->toolbar_open, "clicked", G_CALLBACK (photos_selection_toolbar_open_clicked), self); priv->toolbar_print = gtk_button_new_with_label (_("Print")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_print); g_signal_connect (priv->toolbar_print, "clicked", G_CALLBACK (photos_selection_toolbar_print_clicked), self); priv->toolbar_trash = gtk_button_new_with_label (_("Delete")); gtk_action_bar_pack_start (GTK_ACTION_BAR (toolbar), priv->toolbar_trash); g_signal_connect (priv->toolbar_trash, "clicked", G_CALLBACK (photos_selection_toolbar_trash_clicked), self); priv->toolbar_properties = gtk_button_new_with_label (_("Properties")); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->toolbar_properties); g_signal_connect (priv->toolbar_properties, "clicked", G_CALLBACK (photos_selection_toolbar_properties_clicked), self); priv->toolbar_collection = gtk_button_new_with_label (_("Add to Album")); gtk_action_bar_pack_end (GTK_ACTION_BAR (toolbar), priv->toolbar_collection); g_signal_connect (priv->toolbar_collection, "clicked", G_CALLBACK (photos_selection_toolbar_collection_clicked), self); gtk_widget_show_all (GTK_WIDGET (self)); priv->item_mngr = g_object_ref (state->item_mngr); priv->sel_cntrlr = photos_selection_controller_dup_singleton (); g_signal_connect (priv->sel_cntrlr, "selection-changed", G_CALLBACK (photos_selection_toolbar_selection_changed), self); g_signal_connect (priv->sel_cntrlr, "selection-mode-changed", G_CALLBACK (photos_selection_toolbar_selection_mode_changed), self); }