void gimp_editor_create_menu (GimpEditor *editor, GimpMenuFactory *menu_factory, const gchar *menu_identifier, const gchar *ui_path, gpointer popup_data) { g_return_if_fail (GIMP_IS_EDITOR (editor)); g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory)); g_return_if_fail (menu_identifier != NULL); g_return_if_fail (ui_path != NULL); if (editor->menu_factory) g_object_unref (editor->menu_factory); editor->menu_factory = g_object_ref (menu_factory); if (editor->ui_manager) g_object_unref (editor->ui_manager); editor->ui_manager = gimp_menu_factory_manager_new (menu_factory, menu_identifier, popup_data, FALSE); if (editor->ui_path) g_free (editor->ui_path); editor->ui_path = g_strdup (ui_path); editor->popup_data = popup_data; }
void gimp_editor_set_show_name (GimpEditor *editor, gboolean show) { g_return_if_fail (GIMP_IS_EDITOR (editor)); g_object_set (editor, "show-name", show, NULL); }
void gimp_editor_set_name (GimpEditor *editor, const gchar *name) { g_return_if_fail (GIMP_IS_EDITOR (editor)); gtk_label_set_text (GTK_LABEL (editor->name_label), name ? name : _("(None)")); }
static void gimp_container_popup_create_view (GimpContainerPopup *popup) { GimpEditor *editor; GtkWidget *button; popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL); gimp_container_editor_construct (popup->editor, popup->view_type, popup->container, popup->context, popup->view_size, popup->view_border_width, NULL, NULL, NULL); gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view), FALSE); gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view), 6 * (popup->default_view_size + 2 * popup->view_border_width), 10 * (popup->default_view_size + 2 * popup->view_border_width)); if (GIMP_IS_EDITOR (popup->editor->view)) gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE); gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor)); gtk_widget_show (GTK_WIDGET (popup->editor)); editor = GIMP_EDITOR (popup->editor->view); gimp_editor_add_button (editor, GTK_STOCK_ZOOM_OUT, _("Smaller Previews"), NULL, G_CALLBACK (gimp_container_popup_smaller_clicked), NULL, popup); gimp_editor_add_button (editor, GTK_STOCK_ZOOM_IN, _("Larger Previews"), NULL, G_CALLBACK (gimp_container_popup_larger_clicked), NULL, popup); button = gimp_editor_add_stock_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp", G_CALLBACK (gimp_container_popup_view_type_toggled), popup); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type); if (popup->dialog_factory) gimp_editor_add_button (editor, popup->dialog_stock_id, popup->dialog_tooltip, NULL, G_CALLBACK (gimp_container_popup_dialog_clicked), NULL, popup); gtk_widget_grab_focus (GTK_WIDGET (popup->editor)); }
void gimp_editor_set_box_style (GimpEditor *editor, GtkBox *box) { GtkIconSize button_icon_size; gint button_spacing; GtkReliefStyle button_relief; GList *children; GList *list; g_return_if_fail (GIMP_IS_EDITOR (editor)); g_return_if_fail (GTK_IS_BOX (box)); gtk_widget_style_get (GTK_WIDGET (editor), "button-icon-size", &button_icon_size, "button-spacing", &button_spacing, "button-relief", &button_relief, NULL); gtk_box_set_spacing (box, button_spacing); children = gtk_container_get_children (GTK_CONTAINER (box)); for (list = children; list; list = g_list_next (list)) { if (GTK_IS_BUTTON (list->data)) { GtkWidget *child; gtk_button_set_relief (GTK_BUTTON (list->data), button_relief); child = gtk_bin_get_child (GTK_BIN (list->data)); if (GTK_IS_IMAGE (child)) { GtkIconSize old_size; gchar *stock_id; gtk_image_get_stock (GTK_IMAGE (child), &stock_id, &old_size); if (button_icon_size != old_size) gtk_image_set_from_stock (GTK_IMAGE (child), stock_id, button_icon_size); } } } g_list_free (children); }
GtkWidget * gimp_editor_add_stock_box (GimpEditor *editor, GType enum_type, const gchar *stock_prefix, GCallback callback, gpointer callback_data) { GtkWidget *hbox; GtkWidget *first_button; GtkIconSize button_icon_size; GtkReliefStyle button_relief; GList *children; GList *list; g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL); g_return_val_if_fail (g_type_is_a (enum_type, G_TYPE_ENUM), NULL); g_return_val_if_fail (stock_prefix != NULL, NULL); button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief); hbox = gimp_enum_stock_box_new (enum_type, stock_prefix, button_icon_size, callback, callback_data, &first_button); children = gtk_container_get_children (GTK_CONTAINER (hbox)); for (list = children; list; list = g_list_next (list)) { GtkWidget *button = list->data; g_object_ref (button); gtk_button_set_relief (GTK_BUTTON (button), button_relief); gtk_container_remove (GTK_CONTAINER (hbox), button); gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0); g_object_unref (button); } g_list_free (children); g_object_ref_sink (hbox); g_object_unref (hbox); return first_button; }
GtkWidget * gimp_editor_add_button (GimpEditor *editor, const gchar *stock_id, const gchar *tooltip, const gchar *help_id, GCallback callback, GCallback extended_callback, gpointer callback_data) { GtkWidget *button; GtkWidget *image; GtkIconSize button_icon_size; GtkReliefStyle button_relief; g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL); g_return_val_if_fail (stock_id != NULL, NULL); button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief); button = g_object_new (GIMP_TYPE_BUTTON, "use-stock", TRUE, NULL); gtk_button_set_relief (GTK_BUTTON (button), button_relief); gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0); gtk_widget_show (button); if (tooltip || help_id) gimp_help_set_help_data (button, tooltip, help_id); if (callback) g_signal_connect (button, "clicked", callback, callback_data); if (extended_callback) g_signal_connect (button, "extended-clicked", extended_callback, callback_data); image = gtk_image_new_from_stock (stock_id, button_icon_size); gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_show (image); return button; }
gboolean gimp_editor_popup_menu (GimpEditor *editor, GimpMenuPositionFunc position_func, gpointer position_data) { g_return_val_if_fail (GIMP_IS_EDITOR (editor), FALSE); if (editor->ui_manager && editor->ui_path) { gimp_ui_manager_update (editor->ui_manager, editor->popup_data); gimp_ui_manager_ui_popup (editor->ui_manager, editor->ui_path, GTK_WIDGET (editor), position_func, position_data, NULL, NULL); return TRUE; } return FALSE; }
GtkWidget * gimp_editor_add_action_button (GimpEditor *editor, const gchar *group_name, const gchar *action_name, ...) { GimpActionGroup *group; GtkAction *action; GtkWidget *button; GtkWidget *old_child; GtkWidget *image; GtkIconSize button_icon_size; GtkReliefStyle button_relief; const gchar *stock_id; gchar *tooltip; const gchar *help_id; GList *extended = NULL; va_list args; g_return_val_if_fail (GIMP_IS_EDITOR (editor), NULL); g_return_val_if_fail (action_name != NULL, NULL); g_return_val_if_fail (editor->ui_manager != NULL, NULL); group = gimp_ui_manager_get_action_group (editor->ui_manager, group_name); g_return_val_if_fail (group != NULL, NULL); action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name); g_return_val_if_fail (action != NULL, NULL); button_icon_size = gimp_editor_ensure_button_box (editor, &button_relief); if (GTK_IS_TOGGLE_ACTION (action)) button = gtk_toggle_button_new (); else button = gimp_button_new (); gtk_button_set_relief (GTK_BUTTON (button), button_relief); stock_id = gtk_action_get_stock_id (action); tooltip = g_strdup (gtk_action_get_tooltip (action)); old_child = gtk_bin_get_child (GTK_BIN (button)); if (old_child) gtk_container_remove (GTK_CONTAINER (button), old_child); image = gtk_image_new_from_stock (stock_id, button_icon_size); gtk_container_add (GTK_CONTAINER (button), image); gtk_widget_show (image); gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action); gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0); gtk_widget_show (button); va_start (args, action_name); action_name = va_arg (args, const gchar *); while (action_name) { GdkModifierType mod_mask; mod_mask = va_arg (args, GdkModifierType); action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name); if (action && mod_mask) { ExtendedAction *ext = g_slice_new (ExtendedAction); ext->mod_mask = mod_mask; ext->action = action; extended = g_list_prepend (extended, ext); if (tooltip) { const gchar *ext_tooltip = gtk_action_get_tooltip (action); if (ext_tooltip) { gchar *tmp = g_strconcat (tooltip, "\n<b>", gimp_get_mod_string (mod_mask), "</b> ", ext_tooltip, NULL); g_free (tooltip); tooltip = tmp; } } } action_name = va_arg (args, const gchar *); } va_end (args); if (extended) { g_object_set_data_full (G_OBJECT (button), "extended-actions", extended, (GDestroyNotify) gimp_editor_button_extended_actions_free); g_signal_connect (button, "extended-clicked", G_CALLBACK (gimp_editor_button_extended_clicked), NULL); } help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID); if (tooltip || help_id) gimp_help_set_help_data_with_markup (button, tooltip, help_id); g_free (tooltip); return button; }
static void gimp_container_popup_create_view (GimpContainerPopup *popup) { GimpEditor *editor; GtkWidget *button; popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, "view-type", popup->view_type, "container", popup->container, "context", popup->context, "view-size", popup->view_size, "view-border-width", popup->view_border_width, NULL); gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (popup->editor->view), FALSE); if (popup->view_type == GIMP_VIEW_TYPE_LIST) { GtkWidget *search_entry; search_entry = gtk_entry_new (); gtk_box_pack_end (GTK_BOX (popup->editor->view), search_entry, FALSE, FALSE, 0); gtk_tree_view_set_search_entry (GTK_TREE_VIEW (GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_VIEW (popup->editor->view))->view), GTK_ENTRY (search_entry)); gtk_widget_show (search_entry); } gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (popup->editor->view), 6 * (popup->default_view_size + 2 * popup->view_border_width), 10 * (popup->default_view_size + 2 * popup->view_border_width)); if (GIMP_IS_EDITOR (popup->editor->view)) gimp_editor_set_show_name (GIMP_EDITOR (popup->editor->view), FALSE); gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor)); gtk_widget_show (GTK_WIDGET (popup->editor)); editor = GIMP_EDITOR (popup->editor->view); gimp_editor_add_button (editor, "zoom-out", _("Smaller Previews"), NULL, G_CALLBACK (gimp_container_popup_smaller_clicked), NULL, popup); gimp_editor_add_button (editor, "zoom-in", _("Larger Previews"), NULL, G_CALLBACK (gimp_container_popup_larger_clicked), NULL, popup); button = gimp_editor_add_icon_box (editor, GIMP_TYPE_VIEW_TYPE, "gimp", G_CALLBACK (gimp_container_popup_view_type_toggled), popup); gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), popup->view_type); if (popup->dialog_factory) gimp_editor_add_button (editor, popup->dialog_icon_name, popup->dialog_tooltip, NULL, G_CALLBACK (gimp_container_popup_dialog_clicked), NULL, popup); gtk_widget_grab_focus (GTK_WIDGET (popup->editor)); }