static void nemo_toolbar_constructed (GObject *obj) { NemoToolbar *self = NEMO_TOOLBAR (obj); GtkToolItem *item; GtkBox *hbox; GtkToolbar *toolbar, *secondary_toolbar; GtkWidget *search; GtkStyleContext *context; GtkWidget *sep_space; G_OBJECT_CLASS (nemo_toolbar_parent_class)->constructed (obj); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_JUNCTION_BOTTOM); /* add the UI */ self->priv->ui_manager = gtk_ui_manager_new (); gtk_ui_manager_add_ui_from_resource (self->priv->ui_manager, "/org/nemo/nemo-toolbar-ui.xml", NULL); gtk_ui_manager_insert_action_group (self->priv->ui_manager, self->priv->action_group, 0); toolbar = GTK_TOOLBAR (gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar")); self->priv->toolbar = toolbar; secondary_toolbar = GTK_TOOLBAR (gtk_ui_manager_get_widget (self->priv->ui_manager, "/SecondaryToolbar")); self->priv->secondary_toolbar = secondary_toolbar; gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON); gtk_toolbar_set_icon_size (GTK_TOOLBAR (secondary_toolbar), GTK_ICON_SIZE_MENU); context = gtk_widget_get_style_context (GTK_WIDGET(toolbar)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); context = gtk_widget_get_style_context (GTK_WIDGET(secondary_toolbar)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); //search = gtk_ui_manager_get_widget (self->priv->ui_manager, "/Toolbar/Search"); //gtk_style_context_add_class (gtk_widget_get_style_context (search), GTK_STYLE_CLASS_RAISED); //gtk_widget_set_name (search, "nemo-search-button"); hbox = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); gtk_box_pack_start (hbox, GTK_WIDGET(self->priv->toolbar), TRUE, TRUE, 0); gtk_widget_show_all (GTK_WIDGET(self->priv->toolbar)); gtk_toolbar_set_show_arrow (self->priv->secondary_toolbar, FALSE); gtk_box_pack_start (hbox, GTK_WIDGET(self->priv->secondary_toolbar), FALSE, TRUE, 0); gtk_widget_show_all (GTK_WIDGET(self->priv->secondary_toolbar)); gtk_box_pack_start (GTK_BOX (self), GTK_WIDGET(hbox), TRUE, TRUE, 0); gtk_widget_show_all (GTK_WIDGET(hbox)); hbox = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); gtk_widget_show (GTK_WIDGET(hbox)); /* regular path bar */ self->priv->path_bar = g_object_new (NEMO_TYPE_PATH_BAR, NULL); /* entry-like location bar */ self->priv->location_bar = nemo_location_bar_new (); gtk_box_pack_start (GTK_BOX (hbox), self->priv->location_bar, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), self->priv->path_bar, TRUE, TRUE, 0); item = gtk_tool_item_new (); gtk_tool_item_set_expand (item, TRUE); gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET(hbox)); /* append to the end of the toolbar so navigation buttons are at the beginning */ gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 8); gtk_widget_show (GTK_WIDGET (item)); setup_root_info_bar (self); /* search bar */ self->priv->search_bar = nemo_search_bar_new (); gtk_box_pack_start (GTK_BOX (self), self->priv->search_bar, TRUE, TRUE, 0); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); /* nemo patch */ g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_SHOW_LABEL_SEARCH_ICON_TOOLBAR, G_CALLBACK (toolbar_update_appearance), self); toolbar_update_appearance (self); }
static void add_route_row (CEPageIP6 *page, const gchar *address, gint prefix, const gchar *gateway, gint metric) { GtkWidget *row; GtkWidget *row_grid; GtkWidget *label; GtkWidget *widget; GtkWidget *delete_button; GtkWidget *image; row = gtk_list_box_row_new (); row_grid = gtk_grid_new (); label = gtk_label_new (_("Address")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "address", widget); gtk_entry_set_text (GTK_ENTRY (widget), address); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1); label = gtk_label_new (_("Prefix")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "prefix", widget); if (prefix > 0) { gchar *s = g_strdup_printf ("%d", prefix); gtk_entry_set_text (GTK_ENTRY (widget), s); g_free (s); } gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1); label = gtk_label_new (_("Gateway")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "gateway", widget); gtk_entry_set_text (GTK_ENTRY (widget), gateway); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1); /* Translators: Please see https://en.wikipedia.org/wiki/Metrics_(networking) */ label = gtk_label_new (C_("network parameters", "Metric")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 4, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "metric", widget); if (metric > 0) { gchar *s = g_strdup_printf ("%d", metric); gtk_entry_set_text (GTK_ENTRY (widget), s); g_free (s); } gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 4, 1, 1); delete_button = gtk_button_new (); gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button"); g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page); image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU); atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Route")); gtk_button_set_image (GTK_BUTTON (delete_button), image); gtk_widget_set_halign (delete_button, GTK_ALIGN_CENTER); gtk_widget_set_valign (delete_button, GTK_ALIGN_CENTER); gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 1, 1, 4); g_object_set_data (G_OBJECT (row), "delete-button", delete_button); gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10); gtk_widget_set_margin_start (row_grid, 10); gtk_widget_set_margin_end (row_grid, 10); gtk_widget_set_margin_top (row_grid, 10); gtk_widget_set_margin_bottom (row_grid, 10); gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL); gtk_container_add (GTK_CONTAINER (row), row_grid); gtk_widget_show_all (row); gtk_container_add (GTK_CONTAINER (page->routes_list), row); update_row_sensitivity (page, page->routes_list); }
static void bjb_empty_results_box_constructed (GObject *object) { BjbEmptyResultsBox *self; BjbEmptyResultsBoxPrivate *priv; GtkStyleContext *context; GdkPixbuf *pixbuf; GtkWidget *labels_grid; gchar *label, *icons_path, *note_icon_path, *markup; GError *error; G_OBJECT_CLASS (bjb_empty_results_box_parent_class)->constructed (object); self = BJB_EMPTY_RESULTS_BOX (object); priv = self->priv; 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_HORIZONTAL); gtk_grid_set_column_spacing (GTK_GRID (self), 12); context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, "dim-label"); icons_path = (gchar*) bijiben_get_bijiben_dir (); note_icon_path = g_build_filename (icons_path, "bijiben", "icons", "hicolor", "scalable", "actions", "note.svg", NULL); error = NULL; pixbuf = gdk_pixbuf_new_from_file_at_size (note_icon_path, 64, 64, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); } priv->image = gtk_image_new_from_pixbuf (pixbuf); g_free (note_icon_path); gtk_container_add (GTK_CONTAINER (self), priv->image); labels_grid = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (labels_grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing (GTK_GRID (labels_grid), 0); gtk_widget_set_valign (labels_grid, GTK_ALIGN_START); gtk_container_add (GTK_CONTAINER (self), labels_grid); label = _("No notes"); markup = g_markup_printf_escaped ("<big><b>%s</b></big>", label); priv->primary_label = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (priv->primary_label), markup); g_free (markup); gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START); gtk_widget_set_vexpand (priv->primary_label, TRUE); gtk_label_set_use_markup (GTK_LABEL (priv->primary_label), TRUE); gtk_container_add (GTK_CONTAINER (labels_grid), priv->primary_label); self->priv->type = BJB_EMPTY_RESULTS_TYPE; label = ""; self->priv->details_label = GTK_LABEL (gtk_label_new (label)); gtk_label_set_use_markup (GTK_LABEL (self->priv->details_label), TRUE); gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START); // xalign: 0, // max_width_chars: 24, // wrap: true gtk_container_add (GTK_CONTAINER (labels_grid), GTK_WIDGET (self->priv->details_label)); gtk_widget_set_valign (priv->primary_label, GTK_ALIGN_CENTER); gtk_widget_show_all (GTK_WIDGET (self)); }
static void photos_preview_nav_buttons_constructed (GObject *object) { PhotosPreviewNavButtons *self = PHOTOS_PREVIEW_NAV_BUTTONS (object); GtkStyleContext *context; GtkWidget *button; GtkWidget *image; G_OBJECT_CLASS (photos_preview_nav_buttons_parent_class)->constructed (object); self->prev_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->prev_widget, GTK_ALIGN_START); gtk_widget_set_margin_start (self->prev_widget, 30); gtk_widget_set_margin_end (self->prev_widget, 30); gtk_widget_set_valign (self->prev_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->prev_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->prev_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_PREVIOUS_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-previous"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->prev_widget), button); 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); self->next_widget = g_object_ref_sink (gtk_revealer_new ()); gtk_widget_set_halign (self->next_widget, GTK_ALIGN_END); gtk_widget_set_margin_start (self->next_widget, 30); gtk_widget_set_margin_end (self->next_widget, 30); gtk_widget_set_valign (self->next_widget, GTK_ALIGN_CENTER); gtk_revealer_set_transition_type (GTK_REVEALER (self->next_widget), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); gtk_overlay_add_overlay (GTK_OVERLAY (self->overlay), self->next_widget); image = gtk_image_new_from_icon_name (PHOTOS_ICON_GO_NEXT_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 16); button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (button), image); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "app.load-next"); context = gtk_widget_get_style_context (button); gtk_style_context_add_class (context, "osd"); gtk_container_add (GTK_CONTAINER (self->next_widget), button); 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); g_signal_connect_swapped (self->overlay, "motion-notify-event", G_CALLBACK (photos_preview_nav_buttons_motion_notify), self); self->long_press_gesture = gtk_gesture_long_press_new (self->preview_view); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->long_press_gesture), TRUE); g_signal_connect_swapped (self->long_press_gesture, "pressed", G_CALLBACK (photos_preview_nav_buttons_long_press_pressed), self); self->tap_gesture = gtk_gesture_multi_press_new (self->preview_view); gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->tap_gesture), TRUE); gtk_gesture_group (self->long_press_gesture, self->tap_gesture); g_signal_connect_swapped (self->tap_gesture, "end", G_CALLBACK (photos_preview_nav_buttons_multi_press_end), self); /* We will not need them any more */ self->overlay = NULL; self->preview_view = NULL; }
static GtkWidget * create_extensions_row (GthExtensionDescription *description, BrowserData *browser_data) { GtkWidget *row; GtkWidget *row_box; RowData *row_data; GtkWidget *button; GtkWidget *label_box; GtkWidget *label; GthExtension *extension; row = gtk_list_box_row_new (); row_data = row_data_new (browser_data, description); g_object_set_data_full (G_OBJECT (row), "extension-row-data", row_data, (GDestroyNotify) row_data_free); row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_set_border_width (GTK_CONTAINER (row_box), 10); gtk_container_add (GTK_CONTAINER (row), row_box); button = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (button), gth_extension_description_is_active (description)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "notify::active", G_CALLBACK (extension_switch_activated_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 3); label_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); label = gtk_label_new (description->name); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_style_context_add_class (gtk_widget_get_style_context (label), "extension-name"); gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, FALSE, 0); label = gtk_label_new (description->description); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_style_context_add_class (gtk_widget_get_style_context (label), "extension-description"); gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (row_box), label_box, TRUE, TRUE, 3); extension = gth_extension_description_get_extension (description); if ((extension != NULL) && gth_extension_is_configurable (extension)) { button = gtk_button_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text (button, _("Preferences")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "clicked", G_CALLBACK (extension_preferences_button_clicked_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 0); } if ((extension != NULL) && (g_strcmp0 (description->authors[0], _("gthumb development team")) != 0)) { button = gtk_button_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "clicked", G_CALLBACK (extension_information_button_clicked_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 0); } gtk_widget_show_all (row); return row; }
/** * gd_embed_surface_in_frame: * @source_image: * @frame_image_url: * @slice_width: * @border_width: * * Returns: (transfer full): */ cairo_surface_t * gd_embed_surface_in_frame (cairo_surface_t *source_image, const gchar *frame_image_url, GtkBorder *slice_width, GtkBorder *border_width) { cairo_surface_t *surface; cairo_t *cr; int source_width, source_height; gchar *css_str; GtkCssProvider *provider; GtkStyleContext *context; GError *error = NULL; GdkPixbuf *retval; GtkWidgetPath *path; gdouble scale_x, scale_y; cairo_surface_get_device_scale (source_image, &scale_x, &scale_y); source_width = cairo_image_surface_get_width (source_image) / (gint) floor (scale_x), source_height = cairo_image_surface_get_height (source_image) / (gint) floor (scale_y); css_str = g_strdup_printf (".embedded-image { border-image: url(\"%s\") %d %d %d %d / %dpx %dpx %dpx %dpx }", frame_image_url, slice_width->top, slice_width->right, slice_width->bottom, slice_width->left, border_width->top, border_width->right, border_width->bottom, border_width->left); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, css_str, -1, &error); if (error != NULL) { g_warning ("Unable to create the thumbnail frame image: %s", error->message); g_error_free (error); g_free (css_str); return g_object_ref (source_image); } surface = cairo_surface_create_similar (source_image, CAIRO_CONTENT_COLOR_ALPHA, source_width, source_height); cr = cairo_create (surface); context = gtk_style_context_new (); path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW); gtk_style_context_set_path (context, path); gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), 600); cairo_save (cr); cairo_rectangle (cr, border_width->left, border_width->top, source_width - border_width->left - border_width->right, source_height - border_width->top - border_width->bottom); cairo_clip (cr); gtk_render_icon_surface (context, cr, source_image, 0, 0); cairo_restore (cr); gtk_style_context_save (context); gtk_style_context_add_class (context, "embedded-image"); gtk_render_frame (context, cr, 0, 0, source_width, source_height); gtk_style_context_restore (context); cairo_destroy (cr); gtk_widget_path_unref (path); g_object_unref (provider); g_object_unref (context); g_free (css_str); return surface; }
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, cairo_t *cr) { GtkCheckMenuItemPrivate *priv = check_menu_item->priv; GtkWidget *widget; gint x, y; widget = GTK_WIDGET (check_menu_item); if (gtk_widget_is_drawable (widget)) { GtkAllocation allocation; GtkStyleContext *context; guint border_width; guint offset; guint toggle_size; guint toggle_spacing; guint horizontal_padding; guint indicator_size; GtkStateFlags state; GtkBorder padding; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get_padding (context, state, &padding); gtk_widget_get_allocation (widget, &allocation); gtk_widget_style_get (widget, "toggle-spacing", &toggle_spacing, "horizontal-padding", &horizontal_padding, "indicator-size", &indicator_size, NULL); toggle_size = GTK_MENU_ITEM (check_menu_item)->priv->toggle_size; border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); offset = border_width + padding.left + 2; if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) { x = offset + horizontal_padding + (toggle_size - toggle_spacing - indicator_size) / 2; } else { x = allocation.width - offset - horizontal_padding - toggle_size + toggle_spacing + (toggle_size - toggle_spacing - indicator_size) / 2; } y = (allocation.height - indicator_size) / 2; gtk_style_context_save (context); if (priv->inconsistent) state |= GTK_STATE_FLAG_INCONSISTENT; else if (priv->active) state |= GTK_STATE_FLAG_ACTIVE; gtk_style_context_set_state (context, state); if (priv->draw_as_radio) { gtk_style_context_add_class (context, GTK_STYLE_CLASS_RADIO); gtk_render_option (context, cr, x, y, indicator_size, indicator_size); } else { gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK); gtk_render_check (context, cr, x, y, indicator_size, indicator_size); } gtk_style_context_restore (context); } }
static void gb_editor_view_actions_save (GSimpleAction *action, GVariant *param, gpointer user_data) { GbEditorView *self = user_data; IdeContext *context; IdeBufferManager *buffer_manager; IdeFile *file; IdeProgress *progress = NULL; IdeVcs *vcs; GFile *workdir; g_assert (GB_IS_EDITOR_VIEW (self)); file = ide_buffer_get_file (IDE_BUFFER (self->document)); context = ide_buffer_get_context (IDE_BUFFER (self->document)); buffer_manager = ide_context_get_buffer_manager (context); vcs = ide_context_get_vcs (context); workdir = ide_vcs_get_working_directory (vcs); if (ide_file_get_is_temporary (file)) { GtkDialog *dialog; GtkWidget *toplevel; GtkWidget *suggested; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self)); dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG, "action", GTK_FILE_CHOOSER_ACTION_SAVE, "do-overwrite-confirmation", TRUE, "local-only", FALSE, "modal", TRUE, "select-multiple", FALSE, "show-hidden", FALSE, "transient-for", toplevel, "title", _("Save Document"), NULL); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), workdir, NULL); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Cancel"), GTK_RESPONSE_CANCEL, _("Save"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_style_context_add_class (gtk_widget_get_style_context (suggested), GTK_STYLE_CLASS_SUGGESTED_ACTION); g_signal_connect (dialog, "response", G_CALLBACK (save_temp_response), g_object_ref (self)); gtk_window_present (GTK_WINDOW (dialog)); return; } ide_buffer_manager_save_file_async (buffer_manager, IDE_BUFFER (self->document), file, &progress, NULL, save_file_cb, g_object_ref (self)); g_object_bind_property (progress, "fraction", self->progress_bar, "fraction", G_BINDING_SYNC_CREATE); gtk_widget_show (GTK_WIDGET (self->progress_bar)); g_clear_object (&progress); }
static void photos_properties_dialog_constructed (GObject *object) { PhotosPropertiesDialog *self = PHOTOS_PROPERTIES_DIALOG (object); PhotosPropertiesDialogPrivate *priv = self->priv; GDateTime *date_modified; GtkStyleContext *context; GtkWidget *author_w = NULL; GtkWidget *content_area; GtkWidget *date_created_w = NULL; GtkWidget *date_modified_data; GtkWidget *date_modified_w; GtkWidget *exposure_time_w = NULL; GtkWidget *flash_w = NULL; GtkWidget *fnumber_w = NULL; GtkWidget *focal_length_w = NULL; GtkWidget *height_w = NULL; GtkWidget *iso_speed_w = NULL; GtkWidget *item_type; GtkWidget *item_type_data; GtkWidget *source; GtkWidget *source_data; GtkWidget *title; GtkWidget *width_w = NULL; GQuark equipment; GQuark flash; PhotosBaseItem *item; const gchar *author; const gchar *name; const gchar *type_description; gchar *date_created_str = NULL; gchar *date_modified_str; gdouble exposure_time; gdouble fnumber; gdouble focal_length; gdouble iso_speed; gint64 ctime; gint64 height; gint64 mtime; gint64 width; G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object); item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, priv->urn)); mtime = photos_base_item_get_mtime (item); date_modified = g_date_time_new_from_unix_local (mtime); date_modified_str = g_date_time_format (date_modified, "%c"); g_date_time_unref (date_modified); ctime = photos_base_item_get_date_created (item); if (ctime != -1) { GDateTime *date_created; date_created = g_date_time_new_from_unix_local (ctime); date_created_str = g_date_time_format (date_created, "%c"); g_date_time_unref (date_created); } priv->grid = gtk_grid_new (); gtk_widget_set_halign (priv->grid, GTK_ALIGN_CENTER); gtk_widget_set_margin_start (priv->grid, 24); gtk_widget_set_margin_end (priv->grid, 24); gtk_widget_set_margin_bottom (priv->grid, 12); gtk_widget_set_margin_top (priv->grid, 12); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_column_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_column_spacing (GTK_GRID (priv->grid), 24); gtk_grid_set_row_homogeneous (GTK_GRID (priv->grid), TRUE); gtk_grid_set_row_spacing (GTK_GRID (priv->grid), 6); content_area = gtk_dialog_get_content_area (GTK_DIALOG (self)); gtk_box_pack_start (GTK_BOX (content_area), priv->grid, TRUE, TRUE, 2); /* Translators: this is the label next to the photo title in the * properties dialog */ title = gtk_label_new (C_("Document Title", "Title")); gtk_widget_set_halign (title, GTK_ALIGN_END); context = gtk_widget_get_style_context (title); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), title); author = photos_base_item_get_author (item); if (author != NULL && author[0] != '\0') { /* Translators: this is the label next to the photo author in * the properties dialog */ author_w = gtk_label_new (C_("Document Author", "Author")); gtk_widget_set_halign (author_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (author_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), author_w); } source = gtk_label_new (_("Source")); gtk_widget_set_halign (source, GTK_ALIGN_END); context = gtk_widget_get_style_context (source); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), source); date_modified_w = gtk_label_new (_("Date Modified")); gtk_widget_set_halign (date_modified_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_modified_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_modified_w); if (date_created_str != NULL) { date_created_w = gtk_label_new (_("Date Created")); gtk_widget_set_halign (date_created_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (date_created_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), date_created_w); } /* Translators: this is the label next to the photo type in the * properties dialog */ item_type = gtk_label_new (C_("Document Type", "Type")); gtk_widget_set_halign (item_type, GTK_ALIGN_END); context = gtk_widget_get_style_context (item_type); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), item_type); width = photos_base_item_get_width (item); if (width > 0) { width_w = gtk_label_new (_("Width")); gtk_widget_set_halign (width_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (width_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), width_w); } height = photos_base_item_get_height (item); if (height > 0) { height_w = gtk_label_new (_("Height")); gtk_widget_set_halign (height_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (height_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), height_w); } equipment = photos_base_item_get_equipment (item); photos_camera_cache_get_camera_async (priv->camera_cache, equipment, priv->cancellable, photos_properties_dialog_get_camera, self); if (equipment != 0) { priv->camera_w = gtk_label_new (_("Camera")); gtk_widget_set_halign (priv->camera_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (priv->camera_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), priv->camera_w); } exposure_time = photos_base_item_get_exposure_time (item); if (exposure_time > 0.0) { exposure_time_w = gtk_label_new (_("Exposure")); gtk_widget_set_halign (exposure_time_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (exposure_time_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), exposure_time_w); } fnumber = photos_base_item_get_fnumber (item); if (fnumber > 0.0) { fnumber_w = gtk_label_new (_("Aperture")); gtk_widget_set_halign (fnumber_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (fnumber_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), fnumber_w); } focal_length = photos_base_item_get_focal_length (item); if (focal_length > 0.0) { focal_length_w = gtk_label_new (_("Focal Length")); gtk_widget_set_halign (focal_length_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (focal_length_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), focal_length_w); } iso_speed = photos_base_item_get_iso_speed (item); if (iso_speed > 0.0) { iso_speed_w = gtk_label_new (_("ISO Speed")); gtk_widget_set_halign (iso_speed_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (iso_speed_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), iso_speed_w); } flash = photos_base_item_get_flash (item); if (flash != 0) { flash_w = gtk_label_new (_("Flash")); gtk_widget_set_halign (flash_w, GTK_ALIGN_END); context = gtk_widget_get_style_context (flash_w); gtk_style_context_add_class (context, "dim-label"); gtk_container_add (GTK_CONTAINER (priv->grid), flash_w); } name = photos_base_item_get_name (item); if (PHOTOS_IS_LOCAL_ITEM (item)) { priv->title_entry = gtk_entry_new (); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); gtk_widget_set_hexpand (priv->title_entry, TRUE); gtk_entry_set_activates_default (GTK_ENTRY (priv->title_entry), TRUE); gtk_entry_set_text (GTK_ENTRY (priv->title_entry), name); gtk_entry_set_width_chars (GTK_ENTRY (priv->title_entry), 40); gtk_editable_set_editable (GTK_EDITABLE (priv->title_entry), TRUE); g_signal_connect (priv->title_entry, "changed", G_CALLBACK (photos_properties_dialog_title_entry_changed), self); } else { priv->title_entry = gtk_label_new (name); gtk_widget_set_halign (priv->title_entry, GTK_ALIGN_START); } gtk_grid_attach_next_to (GTK_GRID (priv->grid), priv->title_entry, title, GTK_POS_RIGHT, 2, 1); if (author_w != NULL) { GtkWidget *author_data; author_data = gtk_label_new (author); gtk_widget_set_halign (author_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), author_data, author_w, GTK_POS_RIGHT, 2, 1); } source_data = photos_base_item_get_source_widget (item); gtk_grid_attach_next_to (GTK_GRID (priv->grid), source_data, source, GTK_POS_RIGHT, 2, 1); date_modified_data = gtk_label_new (date_modified_str); gtk_widget_set_halign (date_modified_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_modified_data, date_modified_w, GTK_POS_RIGHT, 2, 1); if (date_created_w != NULL) { GtkWidget *date_created_data; date_created_data = gtk_label_new (date_created_str); gtk_widget_set_halign (date_created_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), date_created_data, date_created_w, GTK_POS_RIGHT, 2, 1); } type_description = photos_base_item_get_type_description (item); item_type_data = gtk_label_new (type_description); gtk_widget_set_halign (item_type_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1); if (width_w != NULL) { GtkWidget *width_data; gchar *width_str; width_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", width); width_data = gtk_label_new (width_str); gtk_widget_set_halign (width_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), width_data, width_w, GTK_POS_RIGHT, 2, 1); g_free (width_str); } if (height_w != NULL) { GtkWidget *height_data; gchar *height_str; height_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", height); height_data = gtk_label_new (height_str); gtk_widget_set_halign (height_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), height_data, height_w, GTK_POS_RIGHT, 2, 1); g_free (height_str); } if (exposure_time_w != NULL) { GtkWidget *exposure_time_data; gchar *exposure_time_str; exposure_time_str = g_strdup_printf ("%.3lf sec", exposure_time); exposure_time_data = gtk_label_new (exposure_time_str); gtk_widget_set_halign (exposure_time_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), exposure_time_data, exposure_time_w, GTK_POS_RIGHT, 2, 1); g_free (exposure_time_str); } if (fnumber_w != NULL) { GtkWidget *fnumber_data; gchar *fnumber_str; fnumber_str = g_strdup_printf ("f/%.1lf", fnumber); fnumber_data = gtk_label_new (fnumber_str); gtk_widget_set_halign (fnumber_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), fnumber_data, fnumber_w, GTK_POS_RIGHT, 2, 1); g_free (fnumber_str); } if (focal_length_w != NULL) { GtkWidget *focal_length_data; gchar *focal_length_str; focal_length_str = g_strdup_printf ("%.0lf mm", focal_length); focal_length_data = gtk_label_new (focal_length_str); gtk_widget_set_halign (focal_length_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), focal_length_data, focal_length_w, GTK_POS_RIGHT, 2, 1); g_free (focal_length_str); } if (iso_speed_w != NULL) { GtkWidget *iso_speed_data; gchar *iso_speed_str; iso_speed_str = g_strdup_printf ("%.0lf", iso_speed); iso_speed_data = gtk_label_new (iso_speed_str); gtk_widget_set_halign (iso_speed_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), iso_speed_data, iso_speed_w, GTK_POS_RIGHT, 2, 1); g_free (iso_speed_str); } if (flash_w != NULL) { GtkWidget *flash_data; gchar *flash_str; if (flash == PHOTOS_FLASH_OFF) flash_str = g_strdup (_("Off, did not fire")); else if (flash == PHOTOS_FLASH_ON) flash_str = g_strdup (_("On, fired")); else { const gchar *str; str = g_quark_to_string (flash); g_warning ("Unknown value for nmm:flash: %s", str); g_assert_not_reached (); } flash_data = gtk_label_new (flash_str); gtk_widget_set_halign (flash_data, GTK_ALIGN_START); gtk_grid_attach_next_to (GTK_GRID (priv->grid), flash_data, flash_w, GTK_POS_RIGHT, 2, 1); g_free (flash_str); } g_free (date_created_str); g_free (date_modified_str); }
static gboolean gtk_switch_draw (GtkWidget *widget, cairo_t *cr) { GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv; GtkStyleContext *context; GdkRectangle handle; PangoLayout *layout; PangoRectangle rect; gint label_x, label_y; GtkStateFlags state; GtkBorder padding; gint focus_width, focus_pad; gint x, y, width, height; gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); if (priv->is_active) state |= GTK_STATE_FLAG_ACTIVE; gtk_style_context_get_padding (context, state, &padding); x = 0; y = 0; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); if (gtk_widget_has_focus (widget)) gtk_render_focus (context, cr, x, y, width, height); gtk_style_context_save (context); gtk_style_context_set_state (context, state); x += focus_width + focus_pad; y += focus_width + focus_pad; width -= 2 * (focus_width + focus_pad); height -= 2 * (focus_width + focus_pad); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); gtk_render_background (context, cr, x, y, width, height); gtk_render_frame (context, cr, x, y, width, height); /* XXX the +1/-1 it's pixel wriggling after checking with the default * theme and xmag */ handle.y = y + padding.top + 1; handle.width = (width - padding.left - padding.right) / 2; handle.height = (height - padding.top - padding.bottom) - 1; /* Translators: if the "on" state label requires more than three * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for * the state */ layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON")); pango_layout_get_extents (layout, NULL, &rect); pango_extents_to_pixels (&rect, NULL); label_x = x + padding.left + ((width / 2) - rect.width - padding.left - padding.right) / 2; label_y = y + padding.top + (height - rect.height - padding.top - padding.bottom) / 2; gtk_render_layout (context, cr, label_x, label_y, layout); g_object_unref (layout); /* Translators: if the "off" state label requires more than three * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state */ layout = gtk_widget_create_pango_layout (widget, C_("switch", "OFF")); pango_layout_get_extents (layout, NULL, &rect); pango_extents_to_pixels (&rect, NULL); label_x = x + padding.left + (width / 2) + ((width / 2) - rect.width - padding.left - padding.right) / 2; label_y = y + padding.top + (height - rect.height - padding.top - padding.bottom) / 2; gtk_render_layout (context, cr, label_x, label_y, layout); g_object_unref (layout); if (priv->is_dragging) handle.x = x + priv->handle_x; else if (priv->is_active) handle.x = x + width - handle.width - padding.right; else handle.x = x + padding.left; gtk_style_context_restore (context); gtk_switch_paint_handle (widget, cr, &handle); return FALSE; }
static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMiniFrame* win) #endif { #ifdef __WXGTK3__ if (!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget))) return false; GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_BUTTON); gtk_render_frame(sc, cr, 0, 0, win->m_width, win->m_height); gtk_style_context_restore(sc); wxGTKCairoDC dc(cr); #else if (gdk_event->count > 0 || gdk_event->window != gtk_widget_get_window(widget)) { return false; } gtk_paint_shadow (gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, NULL, NULL, // FIXME: No clipping? 0, 0, win->m_width, win->m_height); wxClientDC dc(win); wxDCImpl *impl = dc.GetImpl(); wxClientDCImpl *gtk_impl = wxDynamicCast( impl, wxClientDCImpl ); gtk_impl->m_gdkwindow = gtk_widget_get_window(widget); // Hack alert #endif int style = win->GetWindowStyle(); if (style & wxRESIZE_BORDER) { dc.SetBrush( *wxGREY_BRUSH ); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( win->m_width - 14, win->m_height-14, 14, 14 ); } if (win->m_miniTitle && !win->GetTitle().empty()) { dc.SetFont( *wxSMALL_FONT ); wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.SetBrush( brush ); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( win->m_miniEdge-1, win->m_miniEdge-1, win->m_width - (2*(win->m_miniEdge-1)), 15 ); const wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); dc.SetTextForeground(textColor); dc.DrawText( win->GetTitle(), 6, 4 ); if (style & wxCLOSE_BOX) { dc.SetTextBackground(textColor); dc.DrawBitmap( win->m_closeButton, win->m_width-18, 3, true ); } } return false; }
static void ring_welcome_view_init(RingWelcomeView *self) { RingWelcomeViewPrivate *priv = RING_WELCOME_VIEW_GET_PRIVATE(self); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); auto box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15); gtk_container_add(GTK_CONTAINER(self), box); gtk_box_set_baseline_position(GTK_BOX(box), GTK_BASELINE_POSITION_CENTER); gtk_widget_set_vexpand(GTK_WIDGET(box), TRUE); gtk_widget_set_hexpand(GTK_WIDGET(box), FALSE); gtk_widget_set_valign(GTK_WIDGET(box), GTK_ALIGN_CENTER); gtk_widget_set_halign(GTK_WIDGET(box), GTK_ALIGN_CENTER); /* get logo */ GError *error = NULL; GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-logo-blue", 350, -1, TRUE, &error); if (logo == NULL) { g_debug("Could not load logo: %s", error->message); g_clear_error(&error); } else { auto image_ring_logo = gtk_image_new_from_pixbuf(logo); gtk_box_pack_start(GTK_BOX(box), image_ring_logo, FALSE, TRUE, 0); } /* welcome text */ auto label_welcome_text = gtk_label_new(_("Ring is a secure and distributed voice, video, and chat communication platform that requires no centralized server and leaves the power of privacy in the hands of the user.")); gtk_label_set_justify(GTK_LABEL(label_welcome_text), GTK_JUSTIFY_CENTER); gtk_widget_override_font(label_welcome_text, pango_font_description_from_string("12")); gtk_label_set_line_wrap(GTK_LABEL(label_welcome_text), TRUE); /* the max width chars is to limit how much the text expands */ gtk_label_set_max_width_chars(GTK_LABEL(label_welcome_text), 50); gtk_label_set_selectable(GTK_LABEL(label_welcome_text), TRUE); gtk_box_pack_start(GTK_BOX(box), label_welcome_text, FALSE, TRUE, 0); /* RingID explanation */ auto label_explanation = gtk_label_new(C_("Do not translate \"RingID\"", "This is your RingID.\nCopy and share it with your friends!")); auto context = gtk_widget_get_style_context(label_explanation); gtk_style_context_add_class(context, GTK_STYLE_CLASS_DIM_LABEL); gtk_label_set_justify(GTK_LABEL(label_explanation), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label_explanation), TRUE); gtk_widget_set_margin_top(label_explanation, 20); /* we migth need to hide the label if a RING account doesn't exist */ gtk_widget_set_no_show_all(label_explanation, TRUE); gtk_box_pack_start(GTK_BOX(box), label_explanation, FALSE, TRUE, 0); /* RingID label */ auto label_ringid = gtk_label_new(NULL); gtk_label_set_selectable(GTK_LABEL(label_ringid), TRUE); gtk_widget_override_font(label_ringid, pango_font_description_from_string("monospace 12")); show_ring_id(GTK_LABEL(label_ringid), get_active_ring_account()); gtk_widget_set_no_show_all(label_ringid, TRUE); gtk_box_pack_start(GTK_BOX(box), label_ringid, FALSE, TRUE, 0); gtk_label_set_ellipsize(GTK_LABEL(label_ringid), PANGO_ELLIPSIZE_END); if (get_active_ring_account()) { gtk_widget_show(label_explanation); gtk_widget_show(label_ringid); } priv-> ringaccount_updated = QObject::connect( &AccountModel::instance(), &AccountModel::dataChanged, [label_explanation, label_ringid] () { /* check if the active ring account has changed, * eg: if it was deleted */ auto account = get_active_ring_account(); show_ring_id(GTK_LABEL(label_ringid), get_active_ring_account()); if (account) { gtk_widget_show(label_explanation); gtk_widget_show(label_ringid); } else { gtk_widget_hide(label_explanation); gtk_widget_hide(label_ringid); } } ); gtk_widget_show_all(GTK_WIDGET(self)); }
GtkWidget * mate_panel_applet_create_menu (AppletInfo *info) { GtkWidget *menu; GtkWidget *menuitem; GList *l; PanelWidget *panel_widget; gboolean added_anything = FALSE; panel_widget = mate_panel_applet_get_panel_widget (info); menu = g_object_ref_sink (gtk_menu_new ()); /* connect the show & deactivate signal, so that we can "disallow" and * "re-allow" autohide when the menu is shown/deactivated. */ g_signal_connect (menu, "show", G_CALLBACK (applet_menu_show), info); g_signal_connect (menu, "deactivate", G_CALLBACK (applet_menu_deactivate), info); for (l = info->user_menu; l; l = l->next) { AppletUserMenu *user_menu = l->data; if (user_menu->is_enabled_func && !user_menu->is_enabled_func ()) continue; add_to_submenus (info, "", user_menu->name, user_menu, menu, info->user_menu); added_anything = TRUE; } if (!panel_lockdown_get_locked_down ()) { GtkWidget *image; gboolean locked; gboolean lockable; gboolean movable; gboolean removable; lockable = mate_panel_applet_lockable (info); movable = mate_panel_applet_can_freely_move (info); removable = panel_profile_id_lists_are_writable (); locked = panel_widget_get_applet_locked (panel_widget, info->widget); if (added_anything) { menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); } menuitem = gtk_image_menu_item_new_with_mnemonic (_("_Remove From Panel")); image = gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_signal_connect (menuitem, "activate", G_CALLBACK (applet_remove_callback), info); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_set_sensitive (menuitem, (!locked || lockable) && removable); menuitem = gtk_menu_item_new_with_mnemonic (_("_Move")); g_signal_connect (menuitem, "activate", G_CALLBACK (move_applet_callback), info); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_set_sensitive (menuitem, !locked && movable); g_assert (info->move_item == NULL); info->move_item = menuitem; g_object_add_weak_pointer (G_OBJECT (menuitem), (gpointer *) &info->move_item); menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); menuitem = gtk_check_menu_item_new_with_mnemonic (_("Loc_k To Panel")); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), locked); g_signal_connect (menuitem, "toggled", G_CALLBACK (mate_panel_applet_lock), info); gtk_widget_show (menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_set_sensitive (menuitem, lockable); added_anything = TRUE; } if ( ! added_anything) { g_object_unref (menu); return NULL; } /* Set up theme and transparency support */ #if GTK_CHECK_VERSION (3, 0, 0) GtkWidget *toplevel = gtk_widget_get_toplevel (menu); /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */ GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); /* Set menu and it's toplevel window to follow panel theme */ GtkStyleContext *context; context = gtk_widget_get_style_context (GTK_WIDGET(toplevel)); gtk_style_context_add_class(context,"gnome-panel-menu-bar"); gtk_style_context_add_class(context,"mate-panel-menu-bar"); #endif return menu; }
static GtkWidget * create_search_widget (GeditViewFrame *frame) { GtkWidget *search_widget; GtkStyleContext *context; search_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); context = gtk_widget_get_style_context (search_widget); gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED); gtk_widget_show (search_widget); g_signal_connect (search_widget, "key-press-event", G_CALLBACK (search_widget_key_press_event), frame); g_signal_connect (search_widget, "scroll-event", G_CALLBACK (search_widget_scroll_event), frame); /* add entry */ frame->priv->search_entry = gtk_entry_new (); gtk_widget_show (frame->priv->search_entry); gtk_entry_set_width_chars (GTK_ENTRY (frame->priv->search_entry), 25); g_signal_connect (frame->priv->search_entry, "populate-popup", G_CALLBACK (search_entry_populate_popup), frame); g_signal_connect (frame->priv->search_entry, "icon-release", G_CALLBACK (search_entry_icon_release), frame); g_signal_connect (frame->priv->search_entry, "activate", G_CALLBACK (search_entry_activate), frame); g_signal_connect (frame->priv->search_entry, "insert_text", G_CALLBACK (search_entry_insert_text), frame); frame->priv->search_entry_changed_id = g_signal_connect (frame->priv->search_entry, "changed", G_CALLBACK (search_init), frame); frame->priv->search_entry_focus_out_id = g_signal_connect (frame->priv->search_entry, "focus-out-event", G_CALLBACK (search_entry_focus_out_event), frame); gtk_container_add (GTK_CONTAINER (search_widget), frame->priv->search_entry); /* Up/Down buttons */ frame->priv->go_up_button = create_button_from_symbolic ("go-up-symbolic"); gtk_box_pack_start (GTK_BOX (search_widget), frame->priv->go_up_button, FALSE, FALSE, 0); g_signal_connect (frame->priv->go_up_button, "clicked", G_CALLBACK (on_go_up_button_clicked), frame); frame->priv->go_down_button = create_button_from_symbolic ("go-down-symbolic"); gtk_box_pack_start (GTK_BOX (search_widget), frame->priv->go_down_button, FALSE, FALSE, 0); g_signal_connect (frame->priv->go_down_button, "clicked", G_CALLBACK (on_go_down_button_clicked), frame); return search_widget; }
static void nautilus_toolbar_constructed (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); GtkWidget *toolbar; GtkWidget *button; GtkWidget *menu; GtkWidget *box; GtkWidget *separator; GtkUIManager *ui_manager; gboolean rtl; G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "header-bar"); self->priv->toolbar = toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); g_object_set (toolbar, "margin", 8, NULL); gtk_container_add (GTK_CONTAINER (self), toolbar); rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; ui_manager = nautilus_window_get_ui_manager (self->priv->window); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_JUNCTION_BOTTOM); /* Back and Forward */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Back */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_BACK, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_BACK); gtk_container_add (GTK_CONTAINER (box), button); /* Forward */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_FORWARD, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-next-rtl-symbolic" : "go-next-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_FORWARD); gtk_container_add (GTK_CONTAINER (box), button); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_box_pack_start (GTK_BOX (toolbar), box, FALSE, FALSE, 0); if (rtl) { gtk_widget_set_margin_left (box, 12); } else { gtk_widget_set_margin_right (box, 12); } /* regular path bar */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL); gtk_box_pack_start (GTK_BOX (box), self->priv->path_bar, TRUE, TRUE, 0); /* entry-like location bar */ self->priv->location_entry = nautilus_location_entry_new (); gtk_box_pack_start (GTK_BOX (box), self->priv->location_entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (toolbar), box, TRUE, TRUE, 0); /* search */ button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_SEARCH, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 76); } else { gtk_widget_set_margin_left (button, 76); } /* View buttons */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_LIST, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_GRID, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, TRUE, FALSE, "go-down-symbolic", _("View options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); menu = gtk_ui_manager_get_widget (ui_manager, "/ViewMenu"); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_container_add (GTK_CONTAINER (toolbar), box); if (rtl) { gtk_widget_set_margin_right (box, 12); } else { gtk_widget_set_margin_left (box, 12); } /* Action Menu */ button = toolbar_create_toolbutton (self, TRUE, FALSE, "emblem-system-symbolic", _("Location options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu"); gtk_widget_set_halign (menu, GTK_ALIGN_END); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.gear-menu"); g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 12); } else { gtk_widget_set_margin_left (button, 12); } /* Separator and Close */ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (toolbar), separator); if (rtl) { gtk_widget_set_margin_right (separator, 8); } else { gtk_widget_set_margin_left (separator, 8); } button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); g_signal_connect (button, "clicked", G_CALLBACK (close_button_clicked), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 6); } else { gtk_widget_set_margin_left (button, 6); } g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); gtk_widget_show_all (toolbar); toolbar_update_appearance (self); }
static void photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self) { PhotosSelectionToolbarPrivate *priv = self->priv; GList *apps = NULL; GList *l; GList *selection; GtkStyleContext *context; gboolean has_selection; gboolean show_collection; gboolean show_favorite; gboolean show_open; gboolean show_print; gboolean show_properties; gboolean show_trash; gchar *favorite_label; gchar *open_label; guint fav_count = 0; guint apps_length; guint sel_length; priv->inside_refresh = TRUE; selection = photos_selection_controller_get_selection (priv->sel_cntrlr); sel_length = g_list_length (selection); has_selection = sel_length > 0; show_collection = has_selection; show_favorite = has_selection; show_open = has_selection; show_print = has_selection; show_properties = has_selection; show_trash = has_selection; for (l = selection; l != NULL; l = g_list_next (l)) { PhotosBaseItem *item; const gchar *default_app_name; const gchar *urn = (gchar *) l->data; item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, urn)); if (photos_base_item_is_favorite (item)) fav_count++; default_app_name = photos_base_item_get_default_app_name (item); if (default_app_name != NULL && g_list_find (apps, default_app_name) == NULL) apps = g_list_prepend (apps, (gpointer) g_strdup (default_app_name)); show_trash = show_trash && photos_base_item_can_trash (item); show_print = show_print && !photos_base_item_is_collection (item); } show_favorite = show_favorite && ((fav_count == 0) || (fav_count == sel_length)); apps_length = g_list_length (apps); show_open = (apps_length > 0); if (sel_length > 1) { show_print = FALSE; show_properties = FALSE; } if (apps_length == 1) /* Translators: this is the Open action in a context menu */ open_label = g_strdup_printf (_("Open with %s"), (gchar *) apps->data); else /* Translators: this is the Open action in a context menu */ open_label = g_strdup (_("Open")); gd_header_button_set_label (GD_HEADER_BUTTON (priv->toolbar_open), open_label); g_free (open_label); g_list_free_full (apps, g_free); context = gtk_widget_get_style_context (priv->toolbar_favorite); if (show_favorite && fav_count == sel_length) { favorite_label = g_strdup (_("Remove from favorites")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->toolbar_favorite), TRUE); gtk_style_context_add_class (context, "documents-favorite"); } else { favorite_label = g_strdup (_("Add to favorites")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->toolbar_favorite), FALSE); gtk_style_context_remove_class (context, "documents-favorite"); } gtk_widget_reset_style (priv->toolbar_favorite); gtk_widget_set_tooltip_text (priv->toolbar_favorite, favorite_label); g_free (favorite_label); gtk_widget_set_sensitive (priv->toolbar_collection, show_collection); gtk_widget_set_sensitive (priv->toolbar_print, show_print); gtk_widget_set_sensitive (priv->toolbar_properties, show_properties); gtk_widget_set_sensitive (priv->toolbar_trash, show_trash); gtk_widget_set_sensitive (priv->toolbar_open, show_open); gtk_widget_set_sensitive (priv->toolbar_favorite, show_favorite); priv->inside_refresh = FALSE; }
sys_result_t ui_window_init(ui_widget_t** widget) { ui_widget_t *ui_widget = ui_widget_defaults(*widget, "Application Window", 800, 600); ui_window = ui_widget->widget; GError *error = NULL; if(!ui_window) ui_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(ui_window), ui_widget->title); gtk_window_set_default_size(GTK_WINDOW(ui_window), ui_widget->width, ui_widget->height); g_signal_connect(ui_window, "delete-event", G_CALLBACK(ui_window_delete_event_cb), NULL); //setting up app vbox ui_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(ui_window), ui_vbox); //gtk_widget_show(ui_vbox); ui_manager = gtk_ui_manager_new(); ui_action_group = gtk_action_group_new("Actions"); gtk_action_group_add_actions(ui_action_group, entries, n_entries, NULL); gtk_ui_manager_add_ui_from_string(ui_manager, ui_definition,-1, &error); //Populating menus with operations ui_histogram_add_action_entries(ui_action_group, ui_window); if( ui_histogram_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding histogram menus failed"); } ui_curves_add_action_entries(ui_action_group, ui_window); if( ui_curves_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding curves menus failed"); } ui_convolutions_add_action_entries(ui_action_group, ui_window); if( ui_convolutions_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding convolutions menu failed"); } ui_binarization_add_action_entries(ui_action_group, ui_window); if( ui_binarization_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding binarization menu failed"); } ui_colorspaces_add_action_entries(ui_action_group, ui_window); if( ui_colorspaces_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding colorspaces menu entries failed"); } ui_morphology_add_action_entries(ui_action_group, ui_window); if( ui_morphology_add_ui_string(ui_manager) != CLIPT_OK ) { g_warning("Adding morphology menu entry failed"); } gtk_ui_manager_insert_action_group(ui_manager, ui_action_group, 0); if(error) { g_error("Building menus failed: %s", error->message); g_error_free(error); return CLIPT_ERROR; } ui_menu_bar = gtk_ui_manager_get_widget(ui_manager,"/MainMenu"); gtk_box_pack_start(GTK_BOX(ui_vbox), ui_menu_bar, FALSE, FALSE, 2); ui_toolbar = gtk_ui_manager_get_widget(ui_manager, "/MainToolbar"); GtkStyleContext* style_ctx = gtk_widget_get_style_context(ui_toolbar); gtk_style_context_add_class(style_ctx, GTK_STYLE_CLASS_PRIMARY_TOOLBAR); gtk_box_pack_start(GTK_BOX(ui_vbox), ui_toolbar, FALSE, FALSE, 2); gtk_window_add_accel_group(GTK_WINDOW(ui_window), gtk_ui_manager_get_accel_group(ui_manager)); //Drawing area ui_drawing_area = ui_widget_init(NULL, "Drawing area", 100, 100); ui_drawing_area->widget = gtk_drawing_area_new(); g_signal_connect_after(ui_drawing_area->widget, "realize", G_CALLBACK(ui_drawing_area_after_realize_cb), ui_drawing_area); g_signal_connect_after(ui_drawing_area->widget, "draw", G_CALLBACK(ui_drawing_area_draw_cb), ui_drawing_area); gtk_box_pack_end(GTK_BOX(ui_vbox), ui_drawing_area->widget, TRUE, TRUE, 0); gtk_widget_set_double_buffered(ui_drawing_area->widget, FALSE); //gtk_widget_show(ui_drawing_area->widget); //signal emitted when image gets changed somehow ui_new_image_signal = g_signal_new("image-changed", G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); g_signal_connect(G_OBJECT(ui_window), "image-changed", G_CALLBACK(ui_window_image_changed_cb), NULL); gtk_widget_show_all(ui_window); ui_widget->widget = ui_window; return CLIPT_OK; }
static gboolean swatch_draw (GtkWidget *widget, cairo_t *cr) { GtkColorSwatch *swatch = (GtkColorSwatch*)widget; GtkThemingBackground background; gdouble width, height; GtkStyleContext *context; GtkStateFlags state; GtkIconTheme *theme; GtkIconInfo *icon_info = NULL; theme = gtk_icon_theme_get_default (); context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); cairo_save (cr); gtk_style_context_save (context); gtk_style_context_set_state (context, state); _gtk_theming_background_init_from_context (&background, context, 0, 0, width, height, GTK_JUNCTION_NONE); if (swatch->priv->has_color) { cairo_pattern_t *pattern; cairo_matrix_t matrix; if (swatch->priv->use_alpha) { cairo_save (cr); _gtk_rounded_box_path (&background.padding_box, cr); cairo_clip_preserve (cr); cairo_set_source_rgb (cr, 0.33, 0.33, 0.33); cairo_fill_preserve (cr); pattern = _gtk_color_chooser_get_checkered_pattern (); cairo_matrix_init_scale (&matrix, 0.125, 0.125); cairo_pattern_set_matrix (pattern, &matrix); cairo_set_source_rgb (cr, 0.66, 0.66, 0.66); cairo_mask (cr, pattern); cairo_pattern_destroy (pattern); cairo_restore (cr); background.bg_color = swatch->priv->color; } else { background.bg_color = swatch->priv->color; background.bg_color.alpha = 1.0; } _gtk_theming_background_render (&background, cr); } else _gtk_theming_background_render (&background, cr); gtk_render_frame (context, cr, 0, 0, width, height); if (gtk_widget_has_visible_focus (widget)) { cairo_set_line_width (cr, 2); if (swatch->priv->has_color && INTENSITY (swatch->priv->color.red, swatch->priv->color.green, swatch->priv->color.blue) < 0.5) cairo_set_source_rgba (cr, 1., 1., 1., 0.4); else cairo_set_source_rgba (cr, 0., 0., 0., 0.4); _gtk_rounded_box_shrink (&background.padding_box, 3, 3, 3, 3); _gtk_rounded_box_path (&background.padding_box, cr); cairo_stroke (cr); } if (swatch->priv->icon) { icon_info = gtk_icon_theme_lookup_icon (theme, swatch->priv->icon, 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_USE_BUILTIN); } else if ((state & GTK_STATE_FLAG_SELECTED) != 0) { GdkRGBA bg, border; GtkBorder border_width; GIcon *gicon; gtk_style_context_add_class (context, "color-active-badge"); _gtk_theming_background_init_from_context (&background, context, (width - 2 * ACTIVE_BADGE_RADIUS) / 2, (height - 2 * ACTIVE_BADGE_RADIUS) / 2, 2 * ACTIVE_BADGE_RADIUS, 2* ACTIVE_BADGE_RADIUS, GTK_JUNCTION_NONE); if (_gtk_theming_background_has_background_image (&background)) { _gtk_theming_background_render (&background, cr); } else { gtk_style_context_get_background_color (context, state, &bg); gtk_style_context_get_border_color (context, state, &border); gtk_style_context_get_border (context, state, &border_width); cairo_new_sub_path (cr); cairo_arc (cr, width / 2, height / 2, ACTIVE_BADGE_RADIUS, 0, 2 * G_PI); cairo_close_path (cr); gdk_cairo_set_source_rgba (cr, &bg); cairo_fill_preserve (cr); gdk_cairo_set_source_rgba (cr, &border); cairo_set_line_width (cr, border_width.left); cairo_stroke (cr); gicon = g_themed_icon_new ("object-select-symbolic"); /* fallback for themes that don't have object-select-symbolic */ g_themed_icon_append_name (G_THEMED_ICON (gicon), "gtk-apply"); icon_info = gtk_icon_theme_lookup_by_gicon (theme, gicon, 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK | GTK_ICON_LOOKUP_USE_BUILTIN); g_object_unref (gicon); } } if (icon_info != NULL) { GdkPixbuf *pixbuf; pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, context, NULL, NULL); if (pixbuf != NULL) { gtk_render_icon (context, cr, pixbuf, (width - gdk_pixbuf_get_width (pixbuf)) / 2, (height - gdk_pixbuf_get_height (pixbuf)) / 2); g_object_unref (pixbuf); } g_object_unref (icon_info); } cairo_restore (cr); gtk_style_context_restore (context); return FALSE; }
static void ephy_toolbar_constructed (GObject *object) { EphyToolbarPrivate *priv = EPHY_TOOLBAR (object)->priv; GtkActionGroup *action_group; GtkAction *action; GtkToolItem *back_forward, *location_stop_reload, *tool_item; GtkWidget *tool_button, *box, *location, *toolbar; GtkSizeGroup *size; G_OBJECT_CLASS (ephy_toolbar_parent_class)->constructed (object); toolbar = GTK_WIDGET (object); /* Create a GtkSizeGroup to sync the height of the location entry, and * the stop/reload button. */ size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); /* Set the MENUBAR style class so it's possible to drag the app * using the toolbar. */ gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_MENUBAR); /* Back and Forward */ back_forward = gtk_tool_item_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Back */ tool_button = ephy_middle_clickable_button_new (); /* FIXME: apparently we need an image inside the button for the action * icon to appear. */ gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ()); action_group = ephy_window_get_toolbar_action_group (priv->window); action = gtk_action_group_get_action (action_group, "NavigationBack"); gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button), action); gtk_button_set_label (GTK_BUTTON (tool_button), NULL); gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button)); /* Forward */ tool_button = ephy_middle_clickable_button_new (); /* FIXME: apparently we need an image inside the button for the action * icon to appear. */ gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ()); action = gtk_action_group_get_action (action_group, "NavigationForward"); gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button), action); gtk_button_set_label (GTK_BUTTON (tool_button), NULL); gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button)); gtk_style_context_add_class (gtk_widget_get_style_context (box), "raised"); gtk_style_context_add_class (gtk_widget_get_style_context (box), "linked"); gtk_container_add (GTK_CONTAINER (back_forward), box); gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (back_forward)); gtk_widget_show_all (GTK_WIDGET (back_forward)); gtk_widget_set_margin_right (GTK_WIDGET (back_forward), 12); /* Location and Reload/Stop */ location_stop_reload = gtk_tool_item_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Location */ priv->entry = location = ephy_location_entry_new (); gtk_box_pack_start (GTK_BOX (box), location, TRUE, TRUE, 0); gtk_style_context_add_class (gtk_widget_get_style_context (box), "location-entry"); /* Reload/Stop */ tool_button = gtk_button_new (); /* FIXME: apparently we need an image inside the button for the action * icon to appear. */ gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ()); action = gtk_action_group_get_action (action_group, "ViewCombinedStopReload"); gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button), action); gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (tool_button)); gtk_container_add (GTK_CONTAINER (location_stop_reload), box); gtk_container_child_set (GTK_CONTAINER (toolbar), GTK_WIDGET (location_stop_reload), "expand", TRUE, NULL); gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (location_stop_reload)); gtk_size_group_add_widget (size, tool_button); gtk_size_group_add_widget (size, location); g_object_unref (size); gtk_widget_set_margin_right (GTK_WIDGET (location_stop_reload), 12); gtk_widget_show_all (GTK_WIDGET (location_stop_reload)); /* Page Menu */ tool_item = gtk_tool_item_new (); tool_button = gtk_button_new (); gtk_widget_set_name (GTK_WIDGET (tool_button), "ephy-page-menu-button"); /* FIXME: apparently we need an image inside the button for the action * icon to appear. */ gtk_button_set_image (GTK_BUTTON (tool_button), gtk_image_new ()); action = gtk_action_group_get_action (action_group, "PageMenu"); gtk_activatable_set_related_action (GTK_ACTIVATABLE (tool_button), action); gtk_container_add (GTK_CONTAINER (tool_item), tool_button); gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (tool_item)); gtk_widget_show_all (GTK_WIDGET (tool_item)); }
/** * main * @argc: number of arguments * @argv: arguments * * Description: * main * * Returns: * exit code **/ int main (int argc, char *argv[]) { GtkWidget *errordialog; GtkWidget *vbox, *menubar, *toolbar, *statusbar, *gridframe; GtkUIManager *ui_manager; GOptionContext *context; struct timeval tv; gint i; gchar *config; gboolean retval; GError *error = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); games_scores_startup (); gettimeofday (&tv, NULL); srand (tv.tv_usec); context = g_option_context_new (NULL); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); retval = g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (!retval) { g_print ("%s", error->message); g_error_free (error); exit (1); } g_set_application_name (_("Robots")); highscores = games_scores_new ("gnome-robots", scorecats, G_N_ELEMENTS (scorecats), NULL, NULL, 0 /* default category */, GAMES_SCORES_STYLE_PLAIN_DESCENDING); settings = g_settings_new ("org.gnome.robots"); gtk_window_set_default_icon_name ("gnome-robots"); app = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (app), _("Robots")); g_signal_connect (GTK_WINDOW (app), "configure-event", G_CALLBACK (window_configure_event_cb), NULL); g_signal_connect (GTK_WINDOW (app), "window-state-event", G_CALLBACK (window_state_event_cb), NULL); gtk_window_set_default_size (GTK_WINDOW (app), g_settings_get_int (settings, "window-width"), g_settings_get_int (settings, "window-height")); if (g_settings_get_boolean (settings, "window-is-fullscreen")) gtk_window_fullscreen (GTK_WINDOW (app)); if (g_settings_get_boolean (settings, "window-is-maximized")) gtk_window_maximize (GTK_WINDOW (app)); g_signal_connect (G_OBJECT (app), "delete_event", G_CALLBACK (quit_game), NULL); statusbar = gnobots_statusbar_new (); ui_manager = gtk_ui_manager_new (); games_stock_prepare_for_statusbar_tooltips (ui_manager, statusbar); create_game_menus (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (app), gtk_ui_manager_get_accel_group (ui_manager)); menubar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); toolbar = gtk_ui_manager_get_widget (ui_manager, "/Toolbar"); gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR); make_cursors (); game_area = gtk_drawing_area_new (); gtk_widget_add_events (game_area, GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK); g_signal_connect (G_OBJECT (game_area), "button-press-event", G_CALLBACK (mouse_cb), NULL); g_signal_connect (G_OBJECT (game_area), "motion-notify-event", G_CALLBACK (move_cb), NULL); g_signal_connect (G_OBJECT (game_area), "configure-event", G_CALLBACK (resize_cb), NULL); g_signal_connect (G_OBJECT (game_area), "draw", G_CALLBACK (draw_cb), NULL); gridframe = games_grid_frame_new (GAME_WIDTH, GAME_HEIGHT); gtk_container_add (GTK_CONTAINER (gridframe), game_area); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), gridframe, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (app), vbox); gtk_widget_set_size_request (GTK_WIDGET (game_area), MINIMUM_TILE_WIDTH * GAME_WIDTH, MINIMUM_TILE_HEIGHT * GAME_HEIGHT); /* Set the window position if it was set by the session manager */ if (session_xpos >= 0 && session_ypos >= 0) { gtk_window_move (GTK_WINDOW (app), session_xpos, session_ypos); } gtk_widget_show_all (app); if (!load_game_configs ()) { /* Oops, no configs, we probably haven't been installed properly. */ errordialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "<b>%s</b>\n\n%s", _("No game data could be found."), _ ("The program Robots was unable to find any valid game configuration files. Please check that the program is installed correctly.")); gtk_window_set_resizable (GTK_WINDOW (errordialog), FALSE); gtk_dialog_run (GTK_DIALOG (errordialog)); exit (1); } load_properties (); if (!load_game_graphics ()) { /* Oops, no graphics, we probably haven't been installed properly. */ errordialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (app), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "<b>%s</b>\n\n%s", _ ("Some graphics files are missing or corrupt."), _ ("The program Robots was unable to load all the necessary graphics files. Please check that the program is installed correctly.")); gtk_dialog_run (GTK_DIALOG (errordialog)); exit (1); } connect_toolbar_toggle (toolbar); init_sound (); init_game (); if (cmdline_scenario) { set_game_graphics (cmdline_scenario); } if (cmdline_config) { for (i = 0; i < num_game_configs (); ++i) { config = game_config_name (i); if (!strcmp (cmdline_config, config)) { properties_set_config (i); g_free (config); break; } g_free (config); } } gtk_main (); g_settings_sync(); return 0; }
/** * gd_embed_image_in_frame: * @source_image: * @frame_image_path: * @slice_width: * @border_width: * * Returns: (transfer full): */ GdkPixbuf * gd_embed_image_in_frame (GdkPixbuf *source_image, const gchar *frame_image_path, GtkBorder *slice_width, GtkBorder *border_width) { cairo_surface_t *surface; cairo_t *cr; int source_width, source_height; int dest_width, dest_height; gchar *css_str; GtkCssProvider *provider; GtkStyleContext *context; GError *error = NULL; GdkPixbuf *retval; GtkWidgetPath *path; source_width = gdk_pixbuf_get_width (source_image); source_height = gdk_pixbuf_get_height (source_image); dest_width = source_width + border_width->left + border_width->right; dest_height = source_height + border_width->top + border_width->bottom; css_str = g_strdup_printf (".embedded-image { border-image: url(\"%s\") %d %d %d %d / %dpx %dpx %dpx %dpx }", frame_image_path, slice_width->top, slice_width->right, slice_width->bottom, slice_width->left, border_width->top, border_width->right, border_width->bottom, border_width->left); provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, css_str, -1, &error); if (error != NULL) { g_warning ("Unable to create the thumbnail frame image: %s", error->message); g_error_free (error); g_free (css_str); return g_object_ref (source_image); } surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dest_width, dest_height); cr = cairo_create (surface); context = gtk_style_context_new (); path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW); gtk_style_context_set_path (context, path); gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), 600); gtk_style_context_save (context); gtk_style_context_add_class (context, "embedded-image"); gtk_render_frame (context, cr, 0, 0, dest_width, dest_height); gtk_style_context_restore (context); gtk_render_icon (context, cr, source_image, border_width->left, border_width->top); retval = gdk_pixbuf_get_from_surface (surface, 0, 0, dest_width, dest_height); cairo_surface_destroy (surface); cairo_destroy (cr); gtk_widget_path_unref (path); g_object_unref (provider); g_object_unref (context); g_free (css_str); return retval; }
/** * gd_create_symbolic_icon_for_scale: * @name: * @base_size: * @scale: * * Returns: (transfer full): */ GIcon * gd_create_symbolic_icon_for_scale (const gchar *name, gint base_size, gint scale) { gchar *symbolic_name; GIcon *icon, *retval = NULL; cairo_surface_t *icon_surface; cairo_surface_t *surface; cairo_t *cr; GtkStyleContext *style; GtkWidgetPath *path; GdkPixbuf *pixbuf; GtkIconTheme *theme; GtkIconInfo *info; gint bg_size; gint emblem_size; gint total_size; gint total_size_scaled; total_size = base_size / 2; total_size_scaled = total_size * scale; bg_size = MAX (total_size / 2, _BG_MIN_SIZE); emblem_size = MAX (bg_size - 8, _EMBLEM_MIN_SIZE); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, total_size_scaled, total_size_scaled); cairo_surface_set_device_scale (surface, (gdouble) scale, (gdouble) scale); cr = cairo_create (surface); style = gtk_style_context_new (); path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW); gtk_style_context_set_path (style, path); gtk_widget_path_unref (path); gtk_style_context_add_class (style, "documents-icon-bg"); gtk_render_background (style, cr, (total_size - bg_size) / 2, (total_size - bg_size) / 2, bg_size, bg_size); symbolic_name = g_strconcat (name, "-symbolic", NULL); icon = g_themed_icon_new_with_default_fallbacks (symbolic_name); g_free (symbolic_name); theme = gtk_icon_theme_get_default(); info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, emblem_size, scale, GTK_ICON_LOOKUP_FORCE_SIZE); g_object_unref (icon); if (info == NULL) goto out; pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, NULL, NULL); g_object_unref (info); if (pixbuf == NULL) goto out; icon_surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL); g_object_unref (pixbuf); gtk_render_icon_surface (style, cr, icon_surface, (total_size - emblem_size) / 2, (total_size - emblem_size) / 2); cairo_surface_destroy (icon_surface); retval = G_ICON (gdk_pixbuf_get_from_surface (surface, 0, 0, total_size_scaled, total_size_scaled)); out: g_object_unref (style); cairo_surface_destroy (surface); cairo_destroy (cr); return retval; }
/** * gd_create_collection_icon: * @base_size: * @pixbufs: (element-type GdkPixbuf): * * Returns: (transfer full): */ GIcon * gd_create_collection_icon (gint base_size, GList *pixbufs) { cairo_surface_t *surface; GIcon *retval; cairo_t *cr; GtkStyleContext *context; GtkWidgetPath *path; gint padding, tile_size, scale_size; gint pix_width, pix_height; gint idx, cur_x, cur_y; GList *l; GdkPixbuf *pix; /* TODO: do not hardcode 4, but scale to another layout if more * pixbufs are provided. */ padding = MAX (floor (base_size / 10), 4); tile_size = (base_size - (3 * padding)) / 2; context = gtk_style_context_new (); gtk_style_context_add_class (context, "documents-collection-icon"); path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW); gtk_style_context_set_path (context, path); gtk_widget_path_unref (path); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, base_size, base_size); cr = cairo_create (surface); gtk_render_background (context, cr, 0, 0, base_size, base_size); l = pixbufs; idx = 0; cur_x = padding; cur_y = padding; while (l != NULL && idx < 4) { pix = l->data; pix_width = gdk_pixbuf_get_width (pix); pix_height = gdk_pixbuf_get_height (pix); scale_size = MIN (pix_width, pix_height); cairo_save (cr); cairo_translate (cr, cur_x, cur_y); cairo_rectangle (cr, 0, 0, tile_size, tile_size); cairo_clip (cr); cairo_scale (cr, (gdouble) tile_size / (gdouble) scale_size, (gdouble) tile_size / (gdouble) scale_size); gdk_cairo_set_source_pixbuf (cr, pix, 0, 0); cairo_paint (cr); cairo_restore (cr); if ((idx % 2) == 0) { cur_x += tile_size + padding; } else { cur_x = padding; cur_y += tile_size + padding; } idx++; l = l->next; } retval = G_ICON (gdk_pixbuf_get_from_surface (surface, 0, 0, base_size, base_size)); cairo_surface_destroy (surface); cairo_destroy (cr); g_object_unref (context); return retval; }
static void photos_empty_results_box_constructed (GObject *object) { PhotosEmptyResultsBox *self = PHOTOS_EMPTY_RESULTS_BOX (object); PhotosEmptyResultsBoxPrivate *priv = self->priv; GtkStyleContext *context; GtkWidget *image; GtkWidget *title_label; gchar *label; G_OBJECT_CLASS (photos_empty_results_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_HORIZONTAL); gtk_grid_set_column_spacing (GTK_GRID (self), 12); context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, "dim-label"); image = gtk_image_new_from_icon_name (PHOTOS_ICON_PHOTOS_SYMBOLIC, GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size (GTK_IMAGE (image), 64); gtk_container_add (GTK_CONTAINER (self), image); priv->labels_grid = gtk_grid_new (); gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->labels_grid), GTK_ORIENTATION_VERTICAL); gtk_grid_set_row_spacing (GTK_GRID (priv->labels_grid), 12); gtk_container_add (GTK_CONTAINER (self), priv->labels_grid); switch (priv->mode) { case PHOTOS_WINDOW_MODE_COLLECTIONS: label = g_strconcat ("<b><span size=\"large\">", _("No Albums Found"), "</span></b>", NULL); break; case PHOTOS_WINDOW_MODE_FAVORITES: label = g_strconcat ("<b><span size=\"large\">", _("No Favorites Found"), "</span></b>", NULL); break; case PHOTOS_WINDOW_MODE_OVERVIEW: case PHOTOS_WINDOW_MODE_SEARCH: label = g_strconcat ("<b><span size=\"large\">", _("No Photos Found"), "</span></b>", NULL); break; default: g_assert_not_reached (); break; } title_label = gtk_label_new (label); gtk_widget_set_halign (title_label, GTK_ALIGN_START); gtk_widget_set_vexpand (title_label, TRUE); gtk_label_set_use_markup (GTK_LABEL (title_label), TRUE); gtk_container_add (GTK_CONTAINER (priv->labels_grid), title_label); g_free (label); switch (priv->mode) { case PHOTOS_WINDOW_MODE_COLLECTIONS: gtk_widget_set_valign (title_label, GTK_ALIGN_START); photos_empty_results_box_add_collections_label (self); break; case PHOTOS_WINDOW_MODE_FAVORITES: case PHOTOS_WINDOW_MODE_SEARCH: gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER); break; case PHOTOS_WINDOW_MODE_OVERVIEW: if (photos_source_manager_has_online_sources (PHOTOS_SOURCE_MANAGER (self->priv->src_mngr))) gtk_widget_set_valign (title_label, GTK_ALIGN_CENTER); else { gtk_widget_set_valign (title_label, GTK_ALIGN_START); photos_empty_results_box_add_system_settings_label (self); } break; default: g_assert_not_reached (); break; } gtk_widget_show_all (GTK_WIDGET (self)); }
static void add_address_row (CEPageIP6 *page, const gchar *address, const gchar *network, const gchar *gateway) { GtkWidget *row; GtkWidget *row_grid; GtkWidget *label; GtkWidget *widget; GtkWidget *delete_button; GtkWidget *image; row = gtk_list_box_row_new (); row_grid = gtk_grid_new (); label = gtk_label_new (_("Address")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "address", widget); gtk_entry_set_text (GTK_ENTRY (widget), address); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1); label = gtk_label_new (_("Prefix")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "prefix", widget); gtk_entry_set_text (GTK_ENTRY (widget), network); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1); label = gtk_label_new (_("Gateway")); gtk_widget_set_halign (label, GTK_ALIGN_END); gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1); widget = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page); g_object_set_data (G_OBJECT (row), "gateway", widget); gtk_entry_set_text (GTK_ENTRY (widget), gateway); gtk_widget_set_margin_start (widget, 10); gtk_widget_set_margin_end (widget, 10); gtk_widget_set_hexpand (widget, TRUE); gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1); delete_button = gtk_button_new (); gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button"); g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page); image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU); atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Address")); gtk_button_set_image (GTK_BUTTON (delete_button), image); gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 2, 1, 1); g_object_set_data (G_OBJECT (row), "delete-button", delete_button); gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10); gtk_widget_set_margin_start (row_grid, 10); gtk_widget_set_margin_end (row_grid, 10); gtk_widget_set_margin_top (row_grid, 10); gtk_widget_set_margin_bottom (row_grid, 10); gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL); gtk_container_add (GTK_CONTAINER (row), row_grid); gtk_widget_show_all (row); gtk_container_add (GTK_CONTAINER (page->address_list), row); update_row_sensitivity (page, page->address_list); }
static void gcal_event_widget_update_style (GcalEventWidget *self) { GtkStyleContext *context; gboolean slanted_start; gboolean slanted_end; gboolean timed; context = gtk_widget_get_style_context (GTK_WIDGET (self)); slanted_start = FALSE; slanted_end = FALSE; /* Clear previous style classes */ gtk_style_context_remove_class (context, "slanted"); gtk_style_context_remove_class (context, "slanted-start"); gtk_style_context_remove_class (context, "slanted-end"); /* * If the event's dates differs from the widget's dates, * add a slanted edge class at the widget. */ if (self->dt_start) slanted_start = g_date_time_compare (gcal_event_get_date_start (self->event), self->dt_start) != 0; if (self->dt_end) slanted_end = g_date_time_compare (gcal_event_get_date_end (self->event), self->dt_end) != 0; if (slanted_start && slanted_end) gtk_style_context_add_class (context, "slanted"); else if (slanted_start) gtk_style_context_add_class (context, "slanted-start"); else if (slanted_end) gtk_style_context_add_class (context, "slanted-end"); /* TODO: adjust margins based on the CSS gradients sizes, not hardcoded */ gtk_widget_set_margin_start (self->stack, slanted_start ? 20 : 4); gtk_widget_set_margin_end (self->stack, slanted_end ? 20 : 4); /* Add style classes for orientation selectors */ if (self->orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_style_context_add_class (context, "horizontal"); gtk_style_context_remove_class (context, "vertical"); } else { gtk_style_context_add_class (context, "vertical"); gtk_style_context_remove_class (context, "horizontal"); } /* * If the event is a timed, single-day event, draw it differently * from all-day or multi-day events. */ timed = !gcal_event_get_all_day (self->event) && !gcal_event_is_multiday (self->event); gtk_widget_set_visible (self->color_box, timed); if (timed) { GtkStyleContext *context; context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, "timed"); if (self->orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_set_margin_start (self->stack, 0); gtk_widget_set_margin_end (self->stack, 2); } else { gtk_widget_set_visible (self->color_box, FALSE); } } }
static void budgie_session_dialog_init(BudgieSessionDialog *self) { GtkWidget *main_layout, *layout, *button; GtkWidget *top; GtkWidget *image; GtkWidget *label; autofree gchar *txt = NULL; GError *error = NULL; GtkStyleContext *style; gboolean can_reboot = FALSE; gboolean can_poweroff = FALSE; gboolean can_systemd = TRUE; autofree gchar *result = NULL; SdResponse response; init_styles(self); /* Let's set up some systemd logic eh? */ self->proxy = sd_login_manager_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.freedesktop.login1", "/org/freedesktop/login1", NULL, &error); if (error) { g_error_free(error); can_systemd = FALSE; } else { can_systemd = TRUE; } if (can_systemd) { /* Can we reboot? */ if (!sd_login_manager_call_can_reboot_sync(self->proxy, &result, NULL, NULL)) { can_reboot = FALSE; } else { response = get_response(result); if (response == SD_YES || response == SD_CHALLENGE) { can_reboot = TRUE; } } /* Can we shutdown? */ if (!sd_login_manager_call_can_power_off_sync(self->proxy, &result, NULL, NULL)) { can_poweroff = FALSE; } else { response = get_response(result); if (response == SD_YES || response == SD_CHALLENGE) { can_poweroff = TRUE; } } } gtk_window_set_position(GTK_WINDOW(self), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_title(GTK_WINDOW(self), "End your session?"); gtk_window_set_default_size(GTK_WINDOW(self), 300, -1); main_layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10); gtk_container_set_border_width(GTK_CONTAINER(main_layout), 10); gtk_container_add(GTK_CONTAINER(self), main_layout); top = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(main_layout), top, FALSE, FALSE, 0); layout = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_halign(layout, GTK_ALIGN_CENTER); gtk_box_pack_start(GTK_BOX(main_layout), layout, TRUE, TRUE, 0); /* Nice side image.. because why not */ image = gtk_image_new_from_icon_name("system-shutdown-symbolic", GTK_ICON_SIZE_INVALID); gtk_image_set_pixel_size(GTK_IMAGE(image), 48); gtk_box_pack_start(GTK_BOX(top), image, FALSE, FALSE, 0); /* And a helpful label */ txt = g_strdup_printf("<big>Goodbye, %s!</big>", g_get_user_name()); label = gtk_label_new(txt); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(top), label, TRUE, TRUE, 0); /* Add some buttons to uh.. logout, etc. :) */ button = gtk_button_new_with_label("Logout"); g_object_set_data(G_OBJECT(button), "action", "logout"); g_signal_connect(button, "clicked", G_CALLBACK(clicked), self); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0); button = gtk_button_new_with_label("Reboot"); g_object_set_data(G_OBJECT(button), "action", "reboot"); g_signal_connect(button, "clicked", G_CALLBACK(clicked), self); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0); if (!can_reboot) { gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); } button = gtk_button_new_with_label("Poweroff"); g_object_set_data(G_OBJECT(button), "action", "poweroff"); g_signal_connect(button, "clicked", G_CALLBACK(clicked), self); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0); if (!can_poweroff) { gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); } button = gtk_button_new_with_label("Cancel"); g_object_set_data(G_OBJECT(button), "action", "cancel"); g_signal_connect(button, "clicked", G_CALLBACK(clicked), self); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_box_pack_start(GTK_BOX(layout), button, FALSE, FALSE, 0); /* Cheat, shadow + styling, but no titlebar */ gtk_window_set_titlebar(GTK_WINDOW(self), gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); /* Can haz style? */ style = gtk_widget_get_style_context(GTK_WIDGET(self)); gtk_style_context_add_class(style, GTK_STYLE_CLASS_OSD); }