static void photos_error_box_constructed (GObject *object) { PhotosErrorBox *self = PHOTOS_ERROR_BOX (object); G_OBJECT_CLASS (photos_error_box_parent_class)->constructed (object); gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE); gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER); gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing (GTK_GRID (self), 12); self->image = gtk_image_new_from_icon_name ("dialog-error", GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (self->image), 128); gtk_widget_set_halign (self->image, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->image, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->image); self->primary_label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (self->primary_label), TRUE); gtk_widget_set_halign (self->primary_label, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->primary_label, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->primary_label); self->secondary_label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (self->secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (self->secondary_label), TRUE); gtk_widget_set_halign (self->secondary_label, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->secondary_label, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), self->secondary_label); gtk_widget_show_all (GTK_WIDGET (self)); }
static gboolean time_out_size_changed (XfcePanelPlugin *plugin, gint size, TimeOutPlugin *time_out) { GtkOrientation orientation; g_return_val_if_fail (plugin != NULL, FALSE); g_return_val_if_fail (time_out != NULL, FALSE); /* Get the orientation of the panel */ orientation = xfce_panel_plugin_get_orientation (plugin); /* Update icon size */ gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), size - 8); /* Update widget size */ if (orientation == GTK_ORIENTATION_HORIZONTAL) gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size); else gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1); /* We handled the orientation */ return TRUE; }
/** * gpm_applet_size_allocate_cb: * @applet: Inhibit applet instance * * resize icon when panel size changed **/ static void gpm_applet_size_allocate_cb (GtkWidget *widget, GdkRectangle *allocation) { GpmInhibitApplet *applet = GPM_INHIBIT_APPLET (widget); int size = NULL; switch (panel_applet_get_orient (PANEL_APPLET (applet))) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: size = allocation->width; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: size = allocation->height; break; } /* copied from button-widget.c in the panel */ if (size < 22) size = 16; else if (size < 24) size = 22; else if (size < 32) size = 24; else if (size < 48) size = 32; else size = 48; /* GtkImage already contains a check to do nothing if it's the same */ gtk_image_set_pixel_size (GTK_IMAGE(applet->image), size); }
static TimeOutPlugin* time_out_new (XfcePanelPlugin *plugin) { TimeOutPlugin *time_out; GtkOrientation orientation; /* Allocate memory for the plugin structure */ time_out = panel_slice_new0 (TimeOutPlugin); /* Store pointer to the plugin */ time_out->plugin = plugin; /* Create lock screen */ time_out->lock_screen = time_out_lock_screen_new (); /* Connect to 'postpone' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out); /* Connect to 'resume' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "resume", G_CALLBACK (time_out_resume), time_out); /* Create countdowns */ time_out->break_countdown = time_out_countdown_new (); time_out->lock_countdown = time_out_countdown_new (); /* Connect to break countdown signals */ g_signal_connect (G_OBJECT (time_out->break_countdown), "update", G_CALLBACK (time_out_break_countdown_update), time_out); g_signal_connect (G_OBJECT (time_out->break_countdown), "finish", G_CALLBACK (time_out_break_countdown_finish), time_out); /* Connect to lock countdown signals */ g_signal_connect (G_OBJECT (time_out->lock_countdown), "update", G_CALLBACK (time_out_lock_countdown_update), time_out); g_signal_connect (G_OBJECT (time_out->lock_countdown), "finish", G_CALLBACK (time_out_lock_countdown_finish), time_out); /* Get the current orientation */ orientation = xfce_panel_plugin_get_orientation (plugin); /* Create event box to catch user events */ time_out->ebox = gtk_event_box_new (); gtk_event_box_set_visible_window(GTK_EVENT_BOX(time_out->ebox), FALSE); gtk_widget_show (time_out->ebox); /* Create flexible box which can do both, horizontal and vertical layout */ time_out->hvbox = xfce_hvbox_new (orientation, FALSE, 2); gtk_container_add (GTK_CONTAINER (time_out->ebox), time_out->hvbox); gtk_widget_show (time_out->hvbox); /* Create time out icon */ time_out->panel_icon = gtk_image_new_from_icon_name ("xfce4-time-out-plugin", GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size (GTK_IMAGE (time_out->panel_icon), xfce_panel_plugin_get_size (time_out->plugin) - 8); gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->panel_icon, TRUE, TRUE, 0); gtk_widget_show (time_out->panel_icon); /* Create label for displaying the remaining time until the next break */ time_out->time_label = gtk_label_new (_("Inactive")); gtk_misc_set_alignment (GTK_MISC (time_out->time_label), 0.5, 0.5); gtk_box_pack_start (GTK_BOX (time_out->hvbox), time_out->time_label, TRUE, TRUE, 0); gtk_widget_show (time_out->time_label); return time_out; }
static void photos_print_notification_init (PhotosPrintNotification *self) { PhotosPrintNotificationPrivate *priv; GtkWidget *image; self->priv = photos_print_notification_get_instance_private (self); priv = self->priv; priv->ntfctn_mngr = g_object_ref_sink (photos_notification_manager_dup_singleton ()); priv->spinner = gtk_spinner_new (); gtk_widget_set_size_request (priv->spinner, 16, 16); gtk_container_add (GTK_CONTAINER (self), priv->spinner); priv->status_label = gtk_label_new (NULL); gtk_widget_set_halign (priv->status_label, GTK_ALIGN_START); gtk_container_add (GTK_CONTAINER (self), priv->status_label); image = gtk_image_new_from_icon_name (PHOTOS_ICON_PROCESS_STOP_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_widget_set_margin_bottom (image, 2); gtk_widget_set_margin_top (image, 2); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); priv->stop_button = gtk_button_new (); gtk_widget_set_valign (priv->stop_button, GTK_ALIGN_CENTER); gtk_button_set_image (GTK_BUTTON (priv->stop_button), image); gtk_container_add (GTK_CONTAINER (self), priv->stop_button); g_signal_connect_swapped (priv->stop_button, "clicked", G_CALLBACK (photos_print_notification_stop_clicked), self); }
static void populate_flowbox_images (GtkFlowBox *flowbox) { GtkWidget *widget, *image, *label; gint i; for (i = 0; i < N_ITEMS; i++) { gchar *text = g_strdup_printf ("Item %02d", i); widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_widget_set_hexpand (widget, TRUE); image = gtk_image_new_from_icon_name ("face-wink", GTK_ICON_SIZE_DIALOG); gtk_widget_set_hexpand (image, TRUE); gtk_image_set_pixel_size (GTK_IMAGE (image), 256); label = gtk_label_new (text); gtk_container_add (GTK_CONTAINER (widget), image); gtk_container_add (GTK_CONTAINER (widget), label); gtk_widget_show_all (widget); if (text_orientation == GTK_ORIENTATION_VERTICAL) gtk_label_set_angle (GTK_LABEL (widget), 90); g_object_set_data_full (G_OBJECT (widget), "id", (gpointer)g_strdup (text), g_free); gtk_container_add (GTK_CONTAINER (flowbox), widget); g_free (text); } }
static void menuitem_style_set_cb (GtkWidget *menuitem, GtkStyle *old_style, ShellStatusMenu *status) { GtkWidget *image; const char *icon_name; ShellStatusMenuPrivate *priv = status->priv; if (menuitem == priv->login_screen_item) icon_name = "system-users"; else if (menuitem == priv->lock_screen_item) icon_name = "system-lock-screen"; else if (menuitem == priv->quit_session_item) icon_name = "system-log-out"; else if (menuitem == priv->account_item) icon_name = "user-info"; else if (menuitem == priv->control_panel_item) icon_name = "preferences-desktop"; else icon_name = GTK_STOCK_MISSING_IMAGE; image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (menuitem)); gtk_image_set_pixel_size (GTK_IMAGE (image), priv->pixel_size); gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, priv->icon_size); }
static void photos_zoom_controls_update_buttons (PhotosZoomControls *self) { GtkWidget *image; gboolean zoom_best_fit_enabled; gboolean zoom_out_enabled; const gchar *icon_name; zoom_best_fit_enabled = g_action_get_enabled (self->zoom_best_fit_action); zoom_out_enabled = g_action_get_enabled (self->zoom_out_action); g_return_if_fail (zoom_best_fit_enabled == zoom_out_enabled); gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), zoom_out_enabled); gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), NULL); gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), NULL); if (zoom_out_enabled) { gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-best-fit"); } else { GVariant *target_value = NULL; target_value = photos_utils_create_zoom_target_value (1.0, PHOTOS_ZOOM_EVENT_MOUSE_CLICK); gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), target_value); gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-in"); } icon_name = zoom_out_enabled ? "zoom-fit-best-symbolic" : "zoom-in-symbolic"; image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); gtk_button_set_image (GTK_BUTTON (self->zoom_toggle_button), image); }
GtkWidget *elsa_launcher_new() { GtkWidget *icon = NULL; GMenuTree *tree = NULL; icon = gtk_image_new_from_icon_name("start-here", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_image_set_pixel_size(GTK_IMAGE(icon), 24); eventbox = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(eventbox), icon); tree = gmenu_tree_new("gnome-applications.menu", 0); if (!tree) return eventbox; g_object_connect(G_OBJECT(tree), "signal::changed", G_CALLBACK(menu_tree_changed), NULL, NULL); g_object_connect(G_OBJECT(eventbox), "signal::button-press-event", G_CALLBACK(elsa_launcher_button_press), NULL, NULL); menu_tree_changed(tree, NULL); return eventbox; }
static void panel_menu_bar_update_visibility (GSettings* settings, gchar* key, PanelMenuBar* menubar) { GtkWidget* image; gchar *str; GtkIconSize icon_size; gint icon_height; if (!GTK_IS_WIDGET (menubar)) return; gtk_widget_set_visible (GTK_WIDGET (menubar->priv->applications_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_APPLICATIONS_KEY)); gtk_widget_set_visible (GTK_WIDGET (menubar->priv->places_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_PLACES_KEY)); gtk_widget_set_visible (GTK_WIDGET (menubar->priv->desktop_item), g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_DESKTOP_KEY)); if (g_settings_get_boolean (settings, PANEL_MENU_BAR_SHOW_ICON_KEY)) { str = g_settings_get_string (settings, PANEL_MENU_BAR_ICON_NAME_KEY); icon_size = panel_menu_bar_icon_get_size (); gtk_icon_size_lookup (icon_size, NULL, &icon_height); if (str != NULL && str[0] != 0) image = gtk_image_new_from_icon_name(str, icon_size); else image = gtk_image_new_from_icon_name(PANEL_ICON_MAIN_MENU, icon_size); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item), image); gtk_image_set_pixel_size (GTK_IMAGE (image), icon_height); g_free (str); } else gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menubar->priv->applications_item), NULL); }
/** * gtk_image_menu_item_set_image: * @image_menu_item: a #GtkImageMenuItem. * @image: (allow-none): a widget to set as the image for the menu item. * * Sets the image of @image_menu_item to the given widget. * Note that it depends on the show-menu-images setting whether * the image will be displayed or not. * * Deprecated: 3.10 */ void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item, GtkWidget *image) { GtkImageMenuItemPrivate *priv; g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item)); priv = image_menu_item->priv; if (image == priv->image) return; if (priv->image) gtk_container_remove (GTK_CONTAINER (image_menu_item), priv->image); priv->image = image; if (image == NULL) return; gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item)); g_object_set (image, "visible", show_image (image_menu_item), "no-show-all", TRUE, NULL); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); g_object_notify (G_OBJECT (image_menu_item), "image"); }
GuMenuGui* menugui_init(GtkBuilder* builder) { g_return_val_if_fail(GTK_IS_BUILDER(builder), NULL); GuMenuGui* m = g_new0(GuMenuGui, 1); m->menu_projcreate = GTK_MENU_ITEM( gtk_builder_get_object(builder, "menu_projcreate")); m->menu_projopen = GTK_MENU_ITEM( gtk_builder_get_object(builder, "menu_projopen")); m->menu_projclose = GTK_MENU_ITEM( gtk_builder_get_object(builder, "menu_projclose")); m->menu_cut = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu_cut")); m->menu_copy = GTK_MENU_ITEM(gtk_builder_get_object(builder, "menu_copy")); #ifdef WIN32 // Please do NOT enable for nix, it has no place on a free OS ;) GtkWidget* donate = gtk_image_menu_item_new_with_label("Support this Project"); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(donate), GTK_WIDGET(gtk_image_new_from_stock( GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_MENU))); GtkWidget* helpmenu = GTK_WIDGET(gtk_builder_get_object(builder, "menu11")); gtk_menu_prepend(GTK_MENU(helpmenu), donate); gtk_signal_connect_object(GTK_OBJECT(donate), "activate", GTK_SIGNAL_FUNC(on_menu_donate_activate), NULL); #endif /* TODO: There has to be a better way than this.. (bug 246) GtkSettings *settings = gtk_settings_get_default(); gchar *iconsizes; g_object_get(settings, "gtk-icon-sizes", &iconsizes, NULL); if (iconsizes != NULL) { printf("%s\n", iconsizes); }*/ #ifdef WIN32 // The 2 non-stock menu items have their pixel size values set // to the default 16x16 in GLADE. The normal icon-size value is // normally set by the GTK theme in gtkrc. For themes using // non-default icon sizes or Windows, this 16x16 value will be // wrong. This code sets it to match the gtkrc file that we // supply with the Windows builds: GtkWidget* export = gtk_image_menu_item_get_image( GTK_IMAGE_MENU_ITEM(gtk_builder_get_object(builder, "menu_export"))); GtkWidget* update = gtk_image_menu_item_get_image( GTK_IMAGE_MENU_ITEM(gtk_builder_get_object(builder, "menu_update"))); gtk_image_set_pixel_size(GTK_IMAGE(export), 13); gtk_image_set_pixel_size(GTK_IMAGE(update), 13); #endif return m; }
static void panel_icon_size_cb (GpApplet *applet, GParamSpec *pspec, GpMenuButtonApplet *menu_button) { GpMenuButtonAppletPrivate *priv; guint icon_size; guint arrow_size; priv = gp_menu_button_applet_get_instance_private (menu_button); icon_size = gp_applet_get_panel_icon_size (applet); gtk_image_set_pixel_size (GTK_IMAGE (priv->image), icon_size); arrow_size = arrow_size_from_icon_size (icon_size); gtk_image_set_pixel_size (GTK_IMAGE (priv->arrow), arrow_size); }
static void image_size_value_changed (GtkSpinButton *spin_button, GtkImage *image) { gint size = gtk_spin_button_get_value_as_int (spin_button); gtk_image_set_pixel_size (GTK_IMAGE (image), size); }
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, NULL); 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_header_bar_new (); button = gtk_button_new_with_label ("Title"); g_signal_connect (button, "clicked", G_CALLBACK (change_title), footer); gtk_header_bar_pack_start (GTK_HEADER_BAR (footer), button); gtk_header_bar_set_custom_title (GTK_HEADER_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_header_bar_pack_start (GTK_HEADER_BAR (footer), button); gtk_header_bar_set_custom_title (GTK_HEADER_BAR (footer), gtk_check_button_new_with_label ("Middle")); button = gtk_button_new_with_label ("Subtitle"); g_signal_connect (button, "clicked", G_CALLBACK (change_subtitle), NULL); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button); button = gtk_button_new_with_label ("Fullscreen"); gtk_header_bar_pack_end (GTK_HEADER_BAR (footer), button); g_signal_connect (button, "clicked", G_CALLBACK (toggle_fullscreen), window); gtk_box_pack_end (GTK_BOX (box), footer, FALSE, FALSE, 0); 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, 0); gtk_widget_show_all (window); gtk_main (); gtk_widget_destroy (window); return 0; }
int main (int argc, char *argv[]) { GtkWidget *window; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif gtk_set_locale (); gtk_init (&argc, &argv); add_pixmap_directory ("/usr/share/icons/Tango/scalable/apps"); add_pixmap_directory ("/usr/share/icons/Tango/scalable/devices"); add_pixmap_directory ("."); bm.window = create_window (); bm.has_bm = g_file_test ("/usr/sbin/boot-mode", G_FILE_TEST_IS_EXECUTABLE); bm.mode = get_mode (); bm.ignore_edits = TRUE; gtk_image_set_pixel_size (GTK_IMAGE (WIDGET ("normal_image")), 128); gtk_image_set_pixel_size (GTK_IMAGE (WIDGET ("update_image")), 128); VISIBLE ("warning_box", !bm.has_bm); ENABLED ("normal_button", bm.has_bm); ENABLED ("update_button", bm.has_bm); TOGGLED ("normal_button", bm.mode == NORMAL_MODE); TOGGLED ("update_button", bm.mode == UPDATE_MODE); bm.ignore_edits = FALSE; gtk_dialog_run (GTK_DIALOG (bm.window)); if (bm.mode != (ISTOGGLED ("normal_button") ? NORMAL_MODE : UPDATE_MODE)) { update_boot_mode (); } return 0; }
static void menu_icon_size_cb (GpApplet *applet, GParamSpec *pspec, GtkImage *image) { guint icon_size; icon_size = gp_applet_get_menu_icon_size (applet); gtk_image_set_pixel_size (image, icon_size); }
static void photos_tool_filter_button_init (PhotosToolFilterButton *self) { self->overlay = gtk_overlay_new (); self->selected_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_INVALID); gtk_widget_set_halign (self->selected_image, GTK_ALIGN_CENTER); gtk_widget_set_valign (self->selected_image, GTK_ALIGN_CENTER); gtk_widget_set_no_show_all (self->selected_image, TRUE); gtk_image_set_pixel_size (GTK_IMAGE (self->selected_image), 48); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->selected_image); }
static void photos_delete_notification_constructed (GObject *object) { PhotosDeleteNotification *self = PHOTOS_DELETE_NOTIFICATION (object); gchar *msg; GtkWidget *close; GtkWidget *image; GtkWidget *label; GtkWidget *undo; guint length; G_OBJECT_CLASS (photos_delete_notification_parent_class)->constructed (object); length = g_list_length (self->items); if (length == 1) { const gchar *name; name = photos_base_item_get_name_with_fallback (PHOTOS_BASE_ITEM (self->items->data)); msg = g_strdup_printf (_("“%s” deleted"), name); } else msg = g_strdup_printf (ngettext ("%d item deleted", "%d items deleted", length), length); label = gtk_label_new (msg); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_widget_set_hexpand (label, TRUE); gtk_container_add (GTK_CONTAINER (self), label); g_free (msg); undo = gtk_button_new_with_label (_("Undo")); gtk_widget_set_valign (undo, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (self), undo); g_signal_connect_swapped (undo, "clicked", G_CALLBACK (photos_delete_notification_undo_clicked), self); image = gtk_image_new_from_icon_name (PHOTOS_ICON_WINDOW_CLOSE_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_widget_set_margin_bottom (image, 2); gtk_widget_set_margin_top (image, 2); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); close = gtk_button_new (); gtk_widget_set_valign (close, GTK_ALIGN_CENTER); gtk_button_set_focus_on_click (GTK_BUTTON (close), FALSE); gtk_button_set_relief (GTK_BUTTON (close), GTK_RELIEF_NONE); gtk_button_set_image (GTK_BUTTON (close), image); gtk_container_add (GTK_CONTAINER (self), close); g_signal_connect_swapped (close, "clicked", G_CALLBACK (photos_delete_notification_delete_items), self); photos_notification_manager_add_notification (PHOTOS_NOTIFICATION_MANAGER (self->ntfctn_mngr), GTK_WIDGET (self)); self->timeout_id = g_timeout_add_seconds (DELETE_TIMEOUT, photos_delete_notification_timeout, self); }
static GtkWidget *menu_item_new_with_icon_text(GIcon *icon, const char *text) { GtkWidget *menuitem = gtk_menu_item_new(); GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6); GtkWidget *image = gtk_image_new_from_gicon(icon, GTK_ICON_SIZE_LARGE_TOOLBAR); GtkWidget *label = gtk_label_new(text); gtk_image_set_pixel_size(GTK_IMAGE(image), 24); gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(menuitem), box); return menuitem; }
static void add_stack_page (CcBluetoothPanel *self, const char *message, const char *explanation, const char *name) { GtkWidget *label, *image, *box; char *str; box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); g_object_set (G_OBJECT (box), "margin-top", 64, "margin-bottom", 64, NULL); if (g_str_equal (name, BLUETOOTH_AIRPLANE_PAGE) || g_str_equal (name, BLUETOOTH_HW_AIRPLANE_PAGE)) { image = gtk_image_new_from_icon_name ("airplane-mode-symbolic", GTK_ICON_SIZE_DIALOG); } else { image = gtk_image_new_from_icon_name ("bluetooth-active-symbolic", GTK_ICON_SIZE_DIALOG); } gtk_image_set_pixel_size (GTK_IMAGE (image), 192); gtk_style_context_add_class (gtk_widget_get_style_context (image), "dim-label"); gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 24); str = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>", message); label = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL (label), str); g_free (str); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); label = gtk_label_new (explanation); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); if (g_str_equal (name, BLUETOOTH_AIRPLANE_PAGE)) { GtkWidget *button, *alignment; button = gtk_button_new_with_label (_("Turn Off Airplane Mode")); alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_container_add (GTK_CONTAINER (alignment), button); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (on_airplane_mode_off_clicked), self); gtk_box_pack_start (GTK_BOX (box), alignment, FALSE, FALSE, 24); } gtk_stack_add_named (GTK_STACK (self->priv->stack), box, name); gtk_widget_show_all (box); }
static void append_user_item (GpMenuButtonApplet *menu_button, GtkMenu *menu) { guint icon_size; GtkWidget *icon; gchar *user_name; GtkWidget *item; GtkWidget *user_menu; icon_size = gp_applet_get_menu_icon_size (GP_APPLET (menu_button)); icon = gtk_image_new_from_icon_name ("computer", GTK_ICON_SIZE_MENU); gtk_image_set_pixel_size (GTK_IMAGE (icon), icon_size); g_signal_connect_object (menu_button, "notify::menu-icon-size", G_CALLBACK (menu_icon_size_cb), icon, 0); user_name = gp_menu_utils_get_user_name (); item = gp_image_menu_item_new_with_label (user_name); g_free (user_name); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gp_image_menu_item_set_image (GP_IMAGE_MENU_ITEM (item), icon); gtk_widget_show (item); user_menu = gp_user_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), user_menu); g_object_bind_property (menu_button, "enable-tooltips", user_menu, "enable-tooltips", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (menu_button, "locked-down", user_menu, "locked-down", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (menu_button, "menu-icon-size", user_menu, "menu-icon-size", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (user_menu, "empty", item, "visible", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); }
static void set_icon(AnacondaDiskOverview *widget, const char *icon_name) { GError *err = NULL; GIcon *base_icon, *emblem_icon, *icon; GEmblem *emblem = NULL; gchar *file; if (!icon_name) return; if (widget->priv->kind_icon) gtk_widget_destroy(widget->priv->kind_icon); if (widget->priv->chosen) { base_icon = g_icon_new_for_string(icon_name, &err); if (!base_icon) { fprintf(stderr, "could not create icon: %s\n", err->message); g_error_free(err); return; } file = g_strdup_printf("%s/pixmaps/anaconda-selected-icon.svg", get_widgets_datadir()); emblem_icon = g_icon_new_for_string(file, &err); g_free(file); if (!emblem_icon) { fprintf(stderr, "could not create emblem: %s\n", err->message); g_error_free(err); } else { emblem = g_emblem_new(emblem_icon); } icon = g_emblemed_icon_new(base_icon, emblem); g_object_unref(base_icon); } else { icon = g_icon_new_for_string(icon_name, &err); if (!icon) { fprintf(stderr, "could not create icon: %s\n", err->message); g_error_free(err); return; } } widget->priv->kind_icon = gtk_image_new_from_gicon(icon, GTK_ICON_SIZE_DIALOG); gtk_image_set_pixel_size(GTK_IMAGE(widget->priv->kind_icon), ICON_SIZE); }
void gs_app_tile_set_app (GsAppTile *tile, GsApp *app) { GsAppTilePrivate *priv; const gchar *summary; g_return_if_fail (GS_IS_APP_TILE (tile)); g_return_if_fail (GS_IS_APP (app) || app == NULL); priv = gs_app_tile_get_instance_private (tile); gtk_image_clear (GTK_IMAGE (priv->image)); gtk_image_set_pixel_size (GTK_IMAGE (priv->image), 64); if (priv->app) g_signal_handlers_disconnect_by_func (priv->app, app_state_changed, tile); g_clear_object (&priv->app); if (!app) return; priv->app = g_object_ref (app); if (gs_app_get_rating_kind (priv->app) == GS_APP_RATING_KIND_USER) { gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars), GS_APP_RATING_KIND_USER, gs_app_get_rating (priv->app)); } else { gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars), GS_APP_RATING_KIND_KUDOS, gs_app_get_kudos_percentage (priv->app)); } gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "content"); g_signal_connect (priv->app, "notify::state", G_CALLBACK (app_state_changed), tile); app_state_changed (priv->app, NULL, tile); gs_image_set_from_pixbuf (GTK_IMAGE (priv->image), gs_app_get_pixbuf (app)); gtk_label_set_label (GTK_LABEL (priv->name), gs_app_get_name (app)); summary = gs_app_get_summary (app); gtk_label_set_label (GTK_LABEL (priv->summary), summary); gtk_widget_set_visible (priv->summary, summary && summary[0]); }
static void trash_applet_set_icon_size (TrashApplet *applet, gint size) { /* copied from button-widget.c in the panel */ if (size < 22) size = 16; else if (size < 24) size = 22; else if (size < 32) size = 24; else if (size < 48) size = 32; else size = 48; /* GtkImage already contains a check to do nothing if it's the same */ gtk_image_set_pixel_size (applet->image, size); }
void setup_menuitem (GtkWidget *menuitem, GtkIconSize icon_size, GtkWidget *image, const char *title) { GtkWidget *label; char *_title; /* this creates a label with an invisible mnemonic */ label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL); _title = menu_escape_underscores_and_prepend (title); gtk_label_set_text_with_mnemonic (GTK_LABEL (label), _title); g_free (_title); gtk_label_set_pattern (GTK_LABEL (label), ""); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuitem); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_label_set_yalign (GTK_LABEL (label), 0.5); #else gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); #endif gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (menuitem), label); if (image) { gint icon_height = PANEL_DEFAULT_MENU_ICON_SIZE; gtk_icon_size_lookup (icon_size, NULL, &icon_height); gtk_widget_show (image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); gtk_image_set_pixel_size (GTK_IMAGE(image), icon_height); } gtk_widget_show (menuitem); }
static void photos_empty_results_box_add_image (PhotosEmptyResultsBox *self) { GtkWidget *image; const gchar *icon_name = NULL; switch (self->mode) { case PHOTOS_WINDOW_MODE_COLLECTIONS: icon_name = "emblem-photos-symbolic"; break; case PHOTOS_WINDOW_MODE_FAVORITES: icon_name = "starred-symbolic"; break; /* TODO: Don't show a collection if there are no screenshots in * the relevant locations. */ case PHOTOS_WINDOW_MODE_COLLECTION_VIEW: case PHOTOS_WINDOW_MODE_IMPORT: case PHOTOS_WINDOW_MODE_OVERVIEW: icon_name = "camera-photo-symbolic"; break; case PHOTOS_WINDOW_MODE_SEARCH: icon_name = "system-search-symbolic"; break; case PHOTOS_WINDOW_MODE_NONE: case PHOTOS_WINDOW_MODE_EDIT: case PHOTOS_WINDOW_MODE_PREVIEW: default: g_assert_not_reached (); break; } image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_INVALID); gtk_widget_set_margin_bottom (GTK_WIDGET (image), 9); gtk_image_set_pixel_size (GTK_IMAGE (image), 128); gtk_container_add (GTK_CONTAINER (self), image); }
static void append_places_item (GpMenuButtonApplet *menu_button, GtkMenu *menu) { guint icon_size; GtkWidget *icon; GtkWidget *item; GtkWidget *places_menu; icon_size = gp_applet_get_menu_icon_size (GP_APPLET (menu_button)); icon = gtk_image_new_from_icon_name ("folder", GTK_ICON_SIZE_MENU); gtk_image_set_pixel_size (GTK_IMAGE (icon), icon_size); g_signal_connect_object (menu_button, "notify::menu-icon-size", G_CALLBACK (menu_icon_size_cb), icon, 0); item = gp_image_menu_item_new_with_label (_("Places")); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gp_image_menu_item_set_image (GP_IMAGE_MENU_ITEM (item), icon); gtk_widget_show (item); places_menu = gp_places_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), places_menu); g_object_bind_property (menu_button, "enable-tooltips", places_menu, "enable-tooltips", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (menu_button, "locked-down", places_menu, "locked-down", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_bind_property (menu_button, "menu-icon-size", places_menu, "menu-icon-size", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); }
static void gdict_applet_size_allocate (GtkWidget *widget, GdkRectangle *allocation) { GdictApplet *applet = GDICT_APPLET (widget); GdictAppletPrivate *priv = applet->priv; guint new_size; if (priv->orient == GTK_ORIENTATION_HORIZONTAL) new_size = allocation->height; else new_size = allocation->width; if (priv->size != new_size) { priv->size = new_size; gtk_image_set_pixel_size (GTK_IMAGE (priv->image), priv->size - 10); /* re-scale the icon, if it was found */ if (priv->icon) { GdkPixbuf *scaled; scaled = gdk_pixbuf_scale_simple (priv->icon, priv->size - 5, priv->size - 5, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled); g_object_unref (scaled); } } if (GTK_WIDGET_CLASS (gdict_applet_parent_class)->size_allocate) GTK_WIDGET_CLASS (gdict_applet_parent_class)->size_allocate (widget, allocation); }
static void do_icons_to_add (void) { while (icons_to_add) { IconToAdd *icon_to_add = icons_to_add->data; int icon_height; icons_to_add = g_list_delete_link (icons_to_add, icons_to_add); if (icon_to_add->gicon) { gtk_image_set_from_gicon ( GTK_IMAGE (icon_to_add->image), icon_to_add->gicon, icon_to_add->icon_size); } else { g_assert (icon_to_add->pixbuf); gtk_image_set_from_pixbuf ( GTK_IMAGE (icon_to_add->image), icon_to_add->pixbuf); g_signal_connect (icon_to_add->image, "style-updated", G_CALLBACK (menu_item_style_updated), GINT_TO_POINTER (icon_to_add->icon_size)); g_object_unref (icon_to_add->pixbuf); } if (gtk_icon_size_lookup (icon_to_add->icon_size, NULL, &icon_height)) gtk_image_set_pixel_size (GTK_IMAGE (icon_to_add->image), icon_height); if (icon_to_add->gicon) g_object_unref (icon_to_add->gicon); g_object_unref (icon_to_add->image); g_free (icon_to_add); } }