gboolean dialogs_actions_toolbox_exists (Gimp *gimp) { GimpDialogFactory *factory = gimp_dialog_factory_get_singleton (); gboolean toolbox_found = FALSE; GList *iter; /* First look in session managed windows */ toolbox_found = gimp_dialog_factory_find_widget (factory, "gimp-toolbox-window") != NULL; /* Then in image windows */ if (! toolbox_found) { GList *windows = gimp ? gimp_get_image_windows (gimp) : NULL; for (iter = windows; iter; iter = g_list_next (iter)) { GimpImageWindow *window = GIMP_IMAGE_WINDOW (windows->data); if (gimp_image_window_has_toolbox (window)) { toolbox_found = TRUE; break; } } g_list_free (windows); } return toolbox_found; }
static GimpColormapEditor * context_get_colormap_editor (void) { GtkWidget *widget; g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL); widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-indexed-palette"); if (widget) return GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (widget))); return NULL; }
static GimpPaletteEditor * context_get_palette_editor (void) { GtkWidget *widget; g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (gimp_dialog_factory_get_singleton ()), NULL); widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-palette-editor"); if (widget) return GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (widget))); return NULL; }
static gboolean gui_message_error_console (Gimp *gimp, GimpMessageSeverity severity, const gchar *domain, const gchar *message) { GtkWidget *dockable = NULL; /* try to avoid raising the error console for not so severe messages */ if (severity < GIMP_MESSAGE_ERROR) { GtkWidget *widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-error-console"); if (GIMP_IS_DOCKABLE (widget)) dockable = widget; } if (! dockable) { GdkScreen *screen; gint monitor; monitor = gimp_get_monitor_at_pointer (&screen); dockable = gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)), gimp, gimp_dialog_factory_get_singleton (), screen, monitor, "gimp-error-console"); } if (dockable) { GtkWidget *child = gtk_bin_get_child (GTK_BIN (dockable)); gimp_error_console_add (GIMP_ERROR_CONSOLE (child), severity, domain, message); return TRUE; } return FALSE; }
static GtkWidget * gimp_single_window_strategy_show_dockable_dialog (GimpWindowStrategy *strategy, Gimp *gimp, GimpDialogFactory *factory, GdkMonitor *monitor, const gchar *identifiers) { GList *windows = gimp_get_image_windows (gimp); GtkWidget *widget = NULL; GimpImageWindow *window; g_return_val_if_fail (windows != NULL, NULL); /* In single-window mode, there should only be one window... */ window = GIMP_IMAGE_WINDOW (windows->data); if (strcmp ("gimp-toolbox", identifiers) == 0) { /* Only allow one toolbox... */ if (! gimp_image_window_has_toolbox (window)) { GimpDockColumns *columns; GimpUIManager *ui_manager = gimp_image_window_get_ui_manager (window); widget = gimp_dialog_factory_dialog_new (factory, monitor, ui_manager, GTK_WIDGET (window), "gimp-toolbox", -1 /*view_size*/, FALSE /*present*/); gtk_widget_show (widget); columns = gimp_image_window_get_left_docks (window); gimp_dock_columns_add_dock (columns, GIMP_DOCK (widget), -1 /*index*/); } } else if (gimp_dialog_factory_find_widget (factory, identifiers)) { /* if the dialog is already open, simply raise it */ return gimp_dialog_factory_dialog_raise (factory, monitor, GTK_WIDGET (window), identifiers, -1); } else { GtkWidget *dockbook; dockbook = gimp_image_window_get_default_dockbook (window); if (! dockbook) { GimpDockColumns *dock_columns; /* No dock, need to add one */ dock_columns = gimp_image_window_get_right_docks (window); gimp_dock_columns_prepare_dockbook (dock_columns, -1 /*index*/, &dockbook); } widget = gimp_dockbook_add_from_dialog_factory (GIMP_DOCKBOOK (dockbook), identifiers); } g_list_free (windows); return widget; }
static void gimp_color_tool_real_picked (GimpColorTool *color_tool, GimpColorPickState pick_state, gdouble x, gdouble y, const Babl *sample_format, const GimpRGB *color, gint color_index) { GimpTool *tool = GIMP_TOOL (color_tool); GimpContext *context; /* use this tool's own options here (NOT color_tool->options) */ context = GIMP_CONTEXT (gimp_tool_get_options (tool)); if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND || color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND) { GtkWidget *widget; if (babl_format_is_palette (sample_format)) { widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-indexed-palette"); if (widget) { GimpColormapEditor *editor; editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (widget))); gimp_colormap_editor_set_index (editor, color_index, NULL); } } if (TRUE) { widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-palette-editor"); if (widget) { GimpPaletteEditor *editor; gint index; editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (widget))); index = gimp_palette_editor_get_index (editor, color); if (index != -1) gimp_palette_editor_set_index (editor, index, NULL); } } } switch (color_tool->pick_mode) { case GIMP_COLOR_PICK_MODE_NONE: break; case GIMP_COLOR_PICK_MODE_FOREGROUND: gimp_context_set_foreground (context, color); break; case GIMP_COLOR_PICK_MODE_BACKGROUND: gimp_context_set_background (context, color); break; case GIMP_COLOR_PICK_MODE_PALETTE: { GimpDisplayShell *shell = gimp_display_get_shell (tool->display); GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell)); GtkWidget *dockable; dockable = gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)), tool->display->gimp, gimp_dialog_factory_get_singleton (), screen, "gimp-palette-editor"); if (dockable) { GtkWidget *palette_editor; GimpData *data; /* don't blink like mad when updating */ if (pick_state == GIMP_COLOR_PICK_STATE_UPDATE) gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable)); palette_editor = gtk_bin_get_child (GTK_BIN (dockable)); data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor)); if (! data) { data = GIMP_DATA (gimp_context_get_palette (context)); gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor), data); } gimp_palette_editor_pick_color (GIMP_PALETTE_EDITOR (palette_editor), color, pick_state); } } break; } }