diff --git a/ChangeLog b/ChangeLog index d228085c3a..23895595dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2003-07-07 Michael Natterer + + * app/gui/Makefile.am + * app/gui/device-status-dialog.[ch]: removed... + + * app/widgets/Makefile.am + * app/widgets/widgets-types.h + * app/widgets/gimpdevicestatus.[ch]: ...added here as widget. The + thing is narrower now but not nicer and needs some polishing. + + * app/widgets/gimppropwidgets.[ch]: added gimp_prop_color_area_new() + and gimp_prop_stock_image_new() (the latter is still unused). + + * app/gui/dialogs-constructors.[ch] + * app/gui/dialogs.c: made the device status a dockable. + + * app/gui/dialogs-menu.c + * app/gui/image-menu.c + * app/gui/toolbox-menu.c: changed accordingly. + + * app/gui/gui.c: update the device status dialog indirectly now + using the new gui_device_change_notify() callback. + 2003-07-06 Sven Neumann * app/text/Makefile.am diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c index 6a101d15d6..0cb895eef9 100644 --- a/app/dialogs/dialogs-constructors.c +++ b/app/dialogs/dialogs-constructors.c @@ -56,6 +56,7 @@ #include "widgets/gimpimagedock.h" #include "widgets/gimpimageview.h" #include "widgets/gimpitemtreeview.h" +#include "widgets/gimpdevicestatus.h" #include "widgets/gimpdockable.h" #include "widgets/gimpdockbook.h" #include "widgets/gimpdocumentview.h" @@ -76,7 +77,6 @@ #include "about-dialog.h" #include "channels-commands.h" -#include "device-status-dialog.h" #include "dialogs.h" #include "dialogs-constructors.h" #include "file-commands.h" @@ -158,14 +158,6 @@ dialogs_file_new_new (GimpDialogFactory *factory, return file_new_dialog_new (context->gimp); } -GtkWidget * -dialogs_device_status_get (GimpDialogFactory *factory, - GimpContext *context, - gint preview_size) -{ - return device_status_dialog_create (context->gimp); -} - GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory, GimpContext *context, @@ -274,6 +266,26 @@ dialogs_tool_options_get (GimpDialogFactory *factory, NULL); } +GtkWidget * +dialogs_device_status_get (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size) +{ + static GtkWidget *view = NULL; + + if (view) + return NULL; + + view = gimp_device_status_new (context->gimp); + + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); + + return dialogs_dockable_new (view, + _("Device Status"), _("Devices"), NULL, + NULL, NULL, + NULL); +} + GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory, GimpContext *context, diff --git a/app/dialogs/dialogs-constructors.h b/app/dialogs/dialogs-constructors.h index 92bc6e98b8..843fc53b9a 100644 --- a/app/dialogs/dialogs-constructors.h +++ b/app/dialogs/dialogs-constructors.h @@ -25,9 +25,6 @@ GtkWidget * dialogs_file_new_new (GimpDialogFactory *factory, GimpContext *context, gint preview_size); -GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory, - GimpContext *context, - gint preview_size); GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); @@ -60,6 +57,9 @@ GtkWidget * dialogs_dock_new (GimpDialogFactory *factory, GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); +GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size); GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c index 066fe97547..66d6daa354 100644 --- a/app/dialogs/dialogs.c +++ b/app/dialogs/dialogs.c @@ -98,8 +98,6 @@ static const GimpDialogFactoryEntry toplevel_entries[] = 0, FALSE, TRUE, FALSE, FALSE }, /* singleton toplevels */ - { "gimp-device-status-dialog", dialogs_device_status_get, - 0, TRUE, TRUE, FALSE, TRUE }, { "gimp-preferences-dialog", dialogs_preferences_get, 0, TRUE, TRUE, FALSE, FALSE }, { "gimp-module-manager-dialog", dialogs_module_browser_get, @@ -115,6 +113,8 @@ static const GimpDialogFactoryEntry dock_entries[] = /* singleton dockables */ { "gimp-tool-options", dialogs_tool_options_get, 0, TRUE, FALSE, FALSE, TRUE }, + { "gimp-device-status", dialogs_device_status_get, + 0, TRUE, FALSE, FALSE, TRUE }, { "gimp-error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE }, diff --git a/app/gui/Makefile.am b/app/gui/Makefile.am index 4cc1fc00f9..c8fc00fcef 100644 --- a/app/gui/Makefile.am +++ b/app/gui/Makefile.am @@ -11,8 +11,6 @@ dialogs_sources = \ color-notebook.h \ convert-dialog.c \ convert-dialog.h \ - device-status-dialog.c \ - device-status-dialog.h \ dialogs.c \ dialogs.h \ dialogs-constructors.c \ diff --git a/app/gui/device-status-dialog.c b/app/gui/device-status-dialog.c deleted file mode 100644 index 70e6221d1c..0000000000 --- a/app/gui/device-status-dialog.c +++ /dev/null @@ -1,528 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "config.h" - -#include -#include - -#include - -#include "libgimpcolor/gimpcolor.h" -#include "libgimpbase/gimpbase.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "gui-types.h" - -#include "core/gimp.h" -#include "core/gimpbrush.h" -#include "core/gimpcontainer.h" -#include "core/gimpdatafactory.h" -#include "core/gimpgradient.h" -#include "core/gimppattern.h" -#include "core/gimptoolinfo.h" - -#include "widgets/gimpdnd.h" -#include "widgets/gimpdeviceinfo.h" -#include "widgets/gimpdevices.h" -#include "widgets/gimppreview.h" - -#include "device-status-dialog.h" - -#include "gimp-intl.h" - - -#define CELL_SIZE 20 /* The size of the preview cells */ - - -typedef struct _DeviceStatusDialog DeviceStatusDialog; - -struct _DeviceStatusDialog -{ - gint num_devices; - - GdkDevice *current; - GdkDevice **devices; - - GtkWidget *shell; - GtkWidget *table; - - GtkWidget **frames; - GtkWidget **tools; - GtkWidget **foregrounds; - GtkWidget **backgrounds; - GtkWidget **brushes; - GtkWidget **patterns; - GtkWidget **gradients; -}; - - -/* local functions */ - -static void device_status_destroy_callback (void); - -static void device_status_dialog_update (GimpDeviceInfo *device_info, - DeviceStatusDialog *dialog); -static void device_status_drop_tool (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void device_status_foreground_changed (GtkWidget *widget, - gpointer data); -static void device_status_background_changed (GtkWidget *widget, - gpointer data); -static void device_status_drop_brush (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void device_status_drop_pattern (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void device_status_drop_gradient (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); - - -/* local data */ - -static DeviceStatusDialog *deviceD = NULL; - - -/* public functions */ - -GtkWidget * -device_status_dialog_create (Gimp *gimp) -{ - GimpDeviceInfo *device_info; - GimpContext *context; - GtkWidget *label; - GimpRGB color; - GList *list; - gint i; - - g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); - - if (deviceD) - return deviceD->shell; - - deviceD = g_new0 (DeviceStatusDialog, 1); - - deviceD->shell = gimp_dialog_new (_("Device Status"), "device_status", - gimp_standard_help_func, - "dialogs/device_status.html", - GTK_WIN_POS_NONE, - FALSE, FALSE, TRUE, - - GTK_STOCK_CLOSE, gtk_widget_hide, - NULL, 1, NULL, TRUE, TRUE, - - GTK_STOCK_SAVE, gimp_devices_save, - NULL, gimp, NULL, FALSE, FALSE, - - NULL); - - deviceD->num_devices = g_list_length (gdk_devices_list ()); - - /* devices table */ - deviceD->table = gtk_table_new (deviceD->num_devices, 7, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (deviceD->table), 3); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (deviceD->shell)->vbox), - deviceD->table); - gtk_widget_realize (deviceD->table); - gtk_widget_show (deviceD->table); - - deviceD->devices = g_new (GdkDevice *, deviceD->num_devices); - deviceD->frames = g_new (GtkWidget *, deviceD->num_devices); - deviceD->tools = g_new (GtkWidget *, deviceD->num_devices); - deviceD->foregrounds = g_new (GtkWidget *, deviceD->num_devices); - deviceD->backgrounds = g_new (GtkWidget *, deviceD->num_devices); - deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices); - deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices); - deviceD->gradients = g_new (GtkWidget *, deviceD->num_devices); - - gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0); - - for (list = gdk_devices_list (), i = 0; - list; - list = g_list_next (list), i++) - { - device_info = gimp_device_info_get_by_device (GDK_DEVICE (list->data)); - - context = GIMP_CONTEXT (device_info); - - g_signal_connect (device_info, "changed", - G_CALLBACK (device_status_dialog_update), - deviceD); - - deviceD->devices[i] = device_info->device; - - /* the device name */ - - deviceD->frames[i] = gtk_frame_new (NULL); - - gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]), GTK_SHADOW_OUT); - gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->frames[i], - 0, 1, i, i+1, - GTK_FILL, GTK_FILL, 2, 0); - - label = gtk_label_new (GIMP_OBJECT (device_info)->name); - gtk_misc_set_padding (GTK_MISC(label), 2, 0); - gtk_container_add (GTK_CONTAINER(deviceD->frames[i]), label); - gtk_widget_show(label); - - /* the tool */ - - deviceD->tools[i] = - gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_tool (context)), - CELL_SIZE, CELL_SIZE, 0, - FALSE, FALSE, TRUE); - g_signal_connect_object (context, "tool_changed", - G_CALLBACK (gimp_preview_set_viewable), - deviceD->tools[i], - G_CONNECT_SWAPPED); - gimp_dnd_viewable_dest_add (deviceD->tools[i], - GIMP_TYPE_TOOL_INFO, - device_status_drop_tool, - device_info); - gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->tools[i], - 1, 2, i, i+1, - 0, 0, 2, 2); - - /* the foreground color */ - - deviceD->foregrounds[i] = - gimp_color_area_new (&color, - GIMP_COLOR_AREA_FLAT, - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); - gtk_widget_set_size_request (deviceD->foregrounds[i], - CELL_SIZE, CELL_SIZE); - g_signal_connect (deviceD->foregrounds[i], "color_changed", - G_CALLBACK (device_status_foreground_changed), - device_info); - gtk_table_attach (GTK_TABLE (deviceD->table), - deviceD->foregrounds[i], - 2, 3, i, i+1, - 0, 0, 2, 2); - - /* the background color */ - - deviceD->backgrounds[i] = - gimp_color_area_new (&color, - GIMP_COLOR_AREA_FLAT, - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); - gtk_widget_set_size_request (deviceD->backgrounds[i], - CELL_SIZE, CELL_SIZE); - g_signal_connect (deviceD->backgrounds[i], "color_changed", - G_CALLBACK (device_status_background_changed), - device_info); - gtk_table_attach (GTK_TABLE (deviceD->table), - deviceD->backgrounds[i], - 3, 4, i, i+1, - 0, 0, 2, 2); - - /* the brush */ - - deviceD->brushes[i] = - gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)), - CELL_SIZE, CELL_SIZE, 0, - FALSE, FALSE, TRUE); - g_signal_connect_object (context,"brush_changed", - G_CALLBACK (gimp_preview_set_viewable), - deviceD->brushes[i], - G_CONNECT_SWAPPED); - gimp_dnd_viewable_dest_add (deviceD->brushes[i], - GIMP_TYPE_BRUSH, - device_status_drop_brush, - device_info); - gtk_table_attach (GTK_TABLE (deviceD->table), deviceD->brushes[i], - 4, 5, i, i+1, - 0, 0, 2, 2); - - /* the pattern */ - - deviceD->patterns[i] = - gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)), - CELL_SIZE, CELL_SIZE, 0, - FALSE, FALSE, TRUE); - g_signal_connect_object (context, "pattern_changed", - G_CALLBACK (gimp_preview_set_viewable), - deviceD->patterns[i], - G_CONNECT_SWAPPED); - gimp_dnd_viewable_dest_add (deviceD->patterns[i], - GIMP_TYPE_PATTERN, - device_status_drop_pattern, - device_info); - gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i], - 5, 6, i, i+1, - 0, 0, 2, 2); - - /* the gradient */ - - deviceD->gradients[i] = - gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)), - CELL_SIZE * 2, CELL_SIZE, 0, - FALSE, FALSE, TRUE); - g_signal_connect_object (context, "gradient_changed", - G_CALLBACK (gimp_preview_set_viewable), - deviceD->gradients[i], - G_CONNECT_SWAPPED); - gimp_dnd_viewable_dest_add (deviceD->gradients[i], - GIMP_TYPE_GRADIENT, - device_status_drop_gradient, - device_info); - gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->gradients[i], - 6, 7, i, i+1, - 0, 0, 2, 2); - - device_status_dialog_update (device_info, deviceD); - } - - deviceD->current = NULL; - - device_status_dialog_update_current (gimp); - - g_signal_connect (deviceD->shell, "destroy", - G_CALLBACK (device_status_destroy_callback), - NULL); - - return deviceD->shell; -} - -void -device_status_dialog_update_current (Gimp *gimp) -{ - gint i; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - - if (deviceD) - { - for (i = 0; i < deviceD->num_devices; i++) - { - if (deviceD->devices[i] == deviceD->current) - { - gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]), - GTK_SHADOW_OUT); - } - else if (deviceD->devices[i] == gimp_devices_get_current (gimp)) - { - gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]), - GTK_SHADOW_IN); - } - } - - deviceD->current = gimp_devices_get_current (gimp); - } -} - - -/* private functions */ - -static void -device_status_destroy_callback (void) -{ - g_free (deviceD->devices); - g_free (deviceD->frames); - g_free (deviceD->tools); - g_free (deviceD->foregrounds); - g_free (deviceD->backgrounds); - g_free (deviceD->brushes); - g_free (deviceD->patterns); - g_free (deviceD->gradients); - - g_free (deviceD); - deviceD = NULL; -} - -static void -device_status_dialog_update (GimpDeviceInfo *device_info, - DeviceStatusDialog *dialog) -{ - GimpContext *context; - GimpRGB color; - guchar red, green, blue; - gchar ttbuf[64]; - gint i; - - context = GIMP_CONTEXT (device_info); - - for (i = 0; i < dialog->num_devices; i++) - { - if (dialog->devices[i] == device_info->device) - break; - } - - g_return_if_fail (i < dialog->num_devices); - - if (device_info->device->mode == GDK_MODE_DISABLED) - { - gtk_widget_hide (dialog->frames[i]); - gtk_widget_hide (dialog->tools[i]); - gtk_widget_hide (dialog->foregrounds[i]); - gtk_widget_hide (dialog->backgrounds[i]); - gtk_widget_hide (dialog->brushes[i]); - gtk_widget_hide (dialog->patterns[i]); - gtk_widget_hide (dialog->gradients[i]); - } - else - { - gtk_widget_show (dialog->frames[i]); - - if (gimp_context_get_tool (context)) - { - gtk_widget_show (dialog->tools[i]); - } - - /* foreground color */ - gimp_context_get_foreground (context, &color); - gimp_color_area_set_color (GIMP_COLOR_AREA (dialog->foregrounds[i]), - &color); - gtk_widget_show (dialog->foregrounds[i]); - - /* Set the tip to be the RGB value */ - gimp_rgb_get_uchar (&color, &red, &green, &blue); - g_snprintf (ttbuf, sizeof (ttbuf), _("Foreground: %d, %d, %d"), - red, green, blue); - gtk_widget_add_events (dialog->foregrounds[i], - GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - gimp_help_set_help_data (dialog->foregrounds[i], ttbuf, NULL); - - /* background color */ - gimp_context_get_background (context, &color); - gimp_color_area_set_color (GIMP_COLOR_AREA (dialog->backgrounds[i]), - &color); - gtk_widget_show (dialog->backgrounds[i]); - - /* Set the tip to be the RGB value */ - gimp_rgb_get_uchar (&color, &red, &green, &blue); - g_snprintf (ttbuf, sizeof (ttbuf), _("Background: %d, %d, %d"), - red, green, blue); - gtk_widget_add_events (dialog->backgrounds[i], - GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - gimp_help_set_help_data (dialog->backgrounds[i], ttbuf, NULL); - - if (gimp_context_get_brush (context)) - { - gtk_widget_show (dialog->brushes[i]); - } - - if (gimp_context_get_pattern (context)) - { - gtk_widget_show (dialog->patterns[i]); - } - - if (gimp_context_get_gradient (context)) - { - gtk_widget_show (dialog->gradients[i]); - } - } -} - -static void -device_status_drop_tool (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDeviceInfo *device_info; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_context_set_tool (GIMP_CONTEXT (device_info), - GIMP_TOOL_INFO (viewable)); - } -} - -static void -device_status_foreground_changed (GtkWidget *widget, - gpointer data) -{ - GimpDeviceInfo *device_info; - GimpRGB color; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color); - gimp_context_set_foreground (GIMP_CONTEXT (device_info), &color); - } -} - -static void -device_status_background_changed (GtkWidget *widget, - gpointer data) -{ - GimpDeviceInfo *device_info; - GimpRGB color; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color); - gimp_context_set_background (GIMP_CONTEXT (device_info), &color); - } -} - -static void -device_status_drop_brush (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDeviceInfo *device_info; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_context_set_brush (GIMP_CONTEXT (device_info), - GIMP_BRUSH (viewable)); - } -} - -static void -device_status_drop_pattern (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDeviceInfo *device_info; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_context_set_pattern (GIMP_CONTEXT (device_info), - GIMP_PATTERN (viewable)); - } -} - -static void -device_status_drop_gradient (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDeviceInfo *device_info; - - device_info = (GimpDeviceInfo *) data; - - if (device_info && device_info->device) - { - gimp_context_set_gradient (GIMP_CONTEXT (device_info), - GIMP_GRADIENT (viewable)); - } -} diff --git a/app/gui/device-status-dialog.h b/app/gui/device-status-dialog.h deleted file mode 100644 index e7ae40b780..0000000000 --- a/app/gui/device-status-dialog.h +++ /dev/null @@ -1,28 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __DEVICE_STATUS_DIALOG_H__ -#define __DEVICE_STATUS_DIALOG_H__ - - -GtkWidget * device_status_dialog_create (Gimp *gimp); - -void device_status_dialog_update_current (Gimp *gimp); - - -#endif /* __DEVICE_STATUS_DIALOG_H__ */ diff --git a/app/gui/dialogs-constructors.c b/app/gui/dialogs-constructors.c index 6a101d15d6..0cb895eef9 100644 --- a/app/gui/dialogs-constructors.c +++ b/app/gui/dialogs-constructors.c @@ -56,6 +56,7 @@ #include "widgets/gimpimagedock.h" #include "widgets/gimpimageview.h" #include "widgets/gimpitemtreeview.h" +#include "widgets/gimpdevicestatus.h" #include "widgets/gimpdockable.h" #include "widgets/gimpdockbook.h" #include "widgets/gimpdocumentview.h" @@ -76,7 +77,6 @@ #include "about-dialog.h" #include "channels-commands.h" -#include "device-status-dialog.h" #include "dialogs.h" #include "dialogs-constructors.h" #include "file-commands.h" @@ -158,14 +158,6 @@ dialogs_file_new_new (GimpDialogFactory *factory, return file_new_dialog_new (context->gimp); } -GtkWidget * -dialogs_device_status_get (GimpDialogFactory *factory, - GimpContext *context, - gint preview_size) -{ - return device_status_dialog_create (context->gimp); -} - GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory, GimpContext *context, @@ -274,6 +266,26 @@ dialogs_tool_options_get (GimpDialogFactory *factory, NULL); } +GtkWidget * +dialogs_device_status_get (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size) +{ + static GtkWidget *view = NULL; + + if (view) + return NULL; + + view = gimp_device_status_new (context->gimp); + + g_object_add_weak_pointer (G_OBJECT (view), (gpointer *) &view); + + return dialogs_dockable_new (view, + _("Device Status"), _("Devices"), NULL, + NULL, NULL, + NULL); +} + GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory, GimpContext *context, diff --git a/app/gui/dialogs-constructors.h b/app/gui/dialogs-constructors.h index 92bc6e98b8..843fc53b9a 100644 --- a/app/gui/dialogs-constructors.h +++ b/app/gui/dialogs-constructors.h @@ -25,9 +25,6 @@ GtkWidget * dialogs_file_new_new (GimpDialogFactory *factory, GimpContext *context, gint preview_size); -GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory, - GimpContext *context, - gint preview_size); GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); @@ -60,6 +57,9 @@ GtkWidget * dialogs_dock_new (GimpDialogFactory *factory, GtkWidget * dialogs_tool_options_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); +GtkWidget * dialogs_device_status_get (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size); GtkWidget * dialogs_error_console_get (GimpDialogFactory *factory, GimpContext *context, gint preview_size); diff --git a/app/gui/dialogs-menu.c b/app/gui/dialogs-menu.c index d8397f0e27..6c447dd8b1 100644 --- a/app/gui/dialogs-menu.c +++ b/app/gui/dialogs-menu.c @@ -55,6 +55,8 @@ GimpItemFactoryEntry dialogs_menu_entries[] = ADD_TAB (N_("/Add Tab/Tool Options..."), "gimp-tool-options", "", GIMP_STOCK_TOOL_OPTIONS), + ADD_TAB (N_("/Add Tab/Device Status..."), "gimp-device-status", + "", GIMP_STOCK_DEVICE_STATUS), MENU_SEPARATOR ("/Add Tab/---"), diff --git a/app/gui/dialogs.c b/app/gui/dialogs.c index 066fe97547..66d6daa354 100644 --- a/app/gui/dialogs.c +++ b/app/gui/dialogs.c @@ -98,8 +98,6 @@ static const GimpDialogFactoryEntry toplevel_entries[] = 0, FALSE, TRUE, FALSE, FALSE }, /* singleton toplevels */ - { "gimp-device-status-dialog", dialogs_device_status_get, - 0, TRUE, TRUE, FALSE, TRUE }, { "gimp-preferences-dialog", dialogs_preferences_get, 0, TRUE, TRUE, FALSE, FALSE }, { "gimp-module-manager-dialog", dialogs_module_browser_get, @@ -115,6 +113,8 @@ static const GimpDialogFactoryEntry dock_entries[] = /* singleton dockables */ { "gimp-tool-options", dialogs_tool_options_get, 0, TRUE, FALSE, FALSE, TRUE }, + { "gimp-device-status", dialogs_device_status_get, + 0, TRUE, FALSE, FALSE, TRUE }, { "gimp-error-console", dialogs_error_console_get, 0, TRUE, FALSE, FALSE, TRUE }, diff --git a/app/gui/gui.c b/app/gui/gui.c index 2e07ada75c..a29b53a29c 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -44,6 +44,7 @@ #include "display/gimpdisplayshell-render.h" #include "widgets/gimpdevices.h" +#include "widgets/gimpdevicestatus.h" #include "widgets/gimpdialogfactory.h" #include "widgets/gimperrorconsole.h" #include "widgets/gimphelp.h" @@ -51,7 +52,6 @@ #include "widgets/gimpmenufactory.h" #include "widgets/gimpwidgets-utils.h" -#include "device-status-dialog.h" #include "dialogs.h" #include "dialogs-commands.h" #include "gui.h" @@ -91,6 +91,8 @@ static void gui_really_quit_callback (GtkWidget *button, static void gui_show_tooltips_notify (GObject *config, GParamSpec *param_spec, Gimp *gimp); +static void gui_device_change_notify (Gimp *gimp); + static void gui_display_changed (GimpContext *context, GimpDisplay *display, Gimp *gimp); @@ -297,7 +299,7 @@ gui_init (Gimp *gimp) dialogs_init (gimp); - gimp_devices_init (gimp, device_status_dialog_update_current); + gimp_devices_init (gimp, gui_device_change_notify); session_init (gimp); } @@ -584,6 +586,18 @@ gui_show_tooltips_notify (GObject *config, gimp_help_disable_tooltips (); } +static void +gui_device_change_notify (Gimp *gimp) +{ + GimpSessionInfo *session_info; + + session_info = gimp_dialog_factory_find_session_info (global_dock_factory, + "gimp-device-status"); + + if (session_info && session_info->widget) + gimp_device_status_update (GIMP_DEVICE_STATUS (session_info->widget)); +} + #ifdef __GNUC__ #warning FIXME: this junk should mostly go to the display subsystem diff --git a/app/gui/image-menu.c b/app/gui/image-menu.c index dc6ca36289..b6724ee165 100644 --- a/app/gui/image-menu.c +++ b/app/gui/image-menu.c @@ -876,9 +876,9 @@ GimpItemFactoryEntry image_menu_entries[] = "gimp-tool-options", "dialogs/tool_options.html", NULL }, { { N_("/Dialogs/_Device Status..."), NULL, - dialogs_create_toplevel_cmd_callback, 0, + dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_DEVICE_STATUS }, - "gimp-device-status-dialog", + "gimp-device-status", "dialogs/device_status.html", NULL }, MENU_SEPARATOR ("/Dialogs/---"), diff --git a/app/gui/toolbox-menu.c b/app/gui/toolbox-menu.c index a2fed43d82..40ae7ced8d 100644 --- a/app/gui/toolbox-menu.c +++ b/app/gui/toolbox-menu.c @@ -110,9 +110,9 @@ GimpItemFactoryEntry toolbox_menu_entries[] = "gimp-tool-options", "file/dialogs/tool_options.html", NULL }, { { N_("/File/Dialogs/_Device Status..."), NULL, - dialogs_create_toplevel_cmd_callback, 0, + dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_DEVICE_STATUS }, - "gimp-device-status-dialog", + "gimp-device-status", "file/dialogs/device_status.html", NULL }, MENU_SEPARATOR ("/File/Dialogs/---"), diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c index dc6ca36289..b6724ee165 100644 --- a/app/menus/image-menu.c +++ b/app/menus/image-menu.c @@ -876,9 +876,9 @@ GimpItemFactoryEntry image_menu_entries[] = "gimp-tool-options", "dialogs/tool_options.html", NULL }, { { N_("/Dialogs/_Device Status..."), NULL, - dialogs_create_toplevel_cmd_callback, 0, + dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_DEVICE_STATUS }, - "gimp-device-status-dialog", + "gimp-device-status", "dialogs/device_status.html", NULL }, MENU_SEPARATOR ("/Dialogs/---"), diff --git a/app/menus/toolbox-menu.c b/app/menus/toolbox-menu.c index a2fed43d82..40ae7ced8d 100644 --- a/app/menus/toolbox-menu.c +++ b/app/menus/toolbox-menu.c @@ -110,9 +110,9 @@ GimpItemFactoryEntry toolbox_menu_entries[] = "gimp-tool-options", "file/dialogs/tool_options.html", NULL }, { { N_("/File/Dialogs/_Device Status..."), NULL, - dialogs_create_toplevel_cmd_callback, 0, + dialogs_create_dockable_cmd_callback, 0, "", GIMP_STOCK_DEVICE_STATUS }, - "gimp-device-status-dialog", + "gimp-device-status", "file/dialogs/device_status.html", NULL }, MENU_SEPARATOR ("/File/Dialogs/---"), diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index 4e80932c3f..7d5b23fb8d 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -67,6 +67,8 @@ libappwidgets_a_sources = \ gimpdeviceinfo.h \ gimpdevices.c \ gimpdevices.h \ + gimpdevicestatus.c \ + gimpdevicestatus.h \ gimpdialogfactory.c \ gimpdialogfactory.h \ gimpdnd.c \ diff --git a/app/widgets/gimpdevicestatus.c b/app/widgets/gimpdevicestatus.c new file mode 100644 index 0000000000..9fb583315f --- /dev/null +++ b/app/widgets/gimpdevicestatus.c @@ -0,0 +1,442 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis + * + * gimpdevicestatus.c + * Copyright (C) 2003 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include "libgimpcolor/gimpcolor.h" +#include "libgimpwidgets/gimpwidgets.h" + +#include "widgets-types.h" + +#include "core/gimp.h" +#include "core/gimpbrush.h" +#include "core/gimpcontainer.h" +#include "core/gimpdatafactory.h" +#include "core/gimpgradient.h" +#include "core/gimppattern.h" +#include "core/gimptoolinfo.h" + +#include "gimpdnd.h" +#include "gimpdeviceinfo.h" +#include "gimpdevices.h" +#include "gimpdevicestatus.h" +#include "gimpdialogfactory.h" +#include "gimppreview.h" +#include "gimppropwidgets.h" + +#include "gimp-intl.h" + + +#define CELL_SIZE 20 /* The size of the preview cells */ + + +struct _GimpDeviceStatusEntry +{ + GdkDevice *device; + + GtkWidget *separator; + GtkWidget *label; + GtkWidget *arrow; + GtkWidget *tool; + GtkWidget *foreground; + GtkWidget *background; + GtkWidget *brush; + GtkWidget *pattern; + GtkWidget *gradient; +}; + + +static void gimp_device_status_class_init (GimpDeviceStatusClass *klass); +static void gimp_device_status_init (GimpDeviceStatus *editor); + +static void gimp_device_status_destroy (GtkObject *object); +static void gimp_device_status_unmap (GtkWidget *widget); + +static void gimp_device_status_update_entry (GimpDeviceInfo *device_info, + GimpDeviceStatusEntry *entry); +static void gimp_device_status_save_clicked (GtkWidget *button, + GimpDeviceStatus *status); +static void gimp_device_status_edit_clicked (GtkWidget *button, + GimpDeviceStatus *status); +static void gimp_device_status_preview_clicked (GtkWidget *widget, + GdkModifierType state, + const gchar *identifier); + + +static GimpEditorClass *parent_class = NULL; + + +GType +gimp_device_status_get_type (void) +{ + static GType view_type = 0; + + if (! view_type) + { + static const GTypeInfo view_info = + { + sizeof (GimpDeviceStatusClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gimp_device_status_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GimpDeviceStatus), + 0, /* n_preallocs */ + (GInstanceInitFunc) gimp_device_status_init, + }; + + view_type = g_type_register_static (GIMP_TYPE_EDITOR, + "GimpDeviceStatus", + &view_info, 0); + } + + return view_type; +} + +static void +gimp_device_status_class_init (GimpDeviceStatusClass *klass) +{ + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + object_class = GTK_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + + parent_class = g_type_class_peek_parent (klass); + + object_class->destroy = gimp_device_status_destroy; + widget_class->unmap = gimp_device_status_unmap; +} + +static void +gimp_device_status_init (GimpDeviceStatus *status) +{ + GList *list; + gint i; + + status->gimp = NULL; + status->current_device = NULL; + status->num_devices = g_list_length (gdk_devices_list ()); + status->entries = g_new0 (GimpDeviceStatusEntry, + status->num_devices); + + status->table = gtk_table_new (status->num_devices * 3, 7, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (status->table), 4); + gtk_table_set_col_spacing (GTK_TABLE (status->table), 1, 4); + gtk_table_set_col_spacing (GTK_TABLE (status->table), 2, 4); + gtk_table_set_col_spacing (GTK_TABLE (status->table), 3, 4); + gtk_table_set_col_spacing (GTK_TABLE (status->table), 4, 4); + gtk_table_set_col_spacing (GTK_TABLE (status->table), 5, 4); + gtk_container_add (GTK_CONTAINER (status), status->table); + gtk_widget_show (status->table); + + for (list = gdk_devices_list (), i = 0; + list; + list = g_list_next (list), i++) + { + GimpDeviceInfo *device_info; + GimpContext *context; + GimpDeviceStatusEntry *entry = &status->entries[i]; + gint row = i * 3; + gchar *markup; + + entry->device = GDK_DEVICE (list->data); + + device_info = gimp_device_info_get_by_device (entry->device); + context = GIMP_CONTEXT (device_info); + + g_signal_connect (device_info, "changed", + G_CALLBACK (gimp_device_status_update_entry), + entry); + + /* the separator */ + + entry->separator = gtk_hbox_new (FALSE, 0); + gtk_table_attach (GTK_TABLE (status->table), entry->separator, + 0, 7, row, row + 1, + GTK_FILL, GTK_FILL, 0, 2); + + row++; + + /* the device name */ + + entry->label = gtk_label_new (NULL); + + markup = g_strdup_printf ("%s", GIMP_OBJECT (device_info)->name); + gtk_label_set_markup (GTK_LABEL (entry->label), markup); + g_free (markup); + + gtk_widget_set_size_request (entry->label, -1, CELL_SIZE); + gtk_misc_set_alignment (GTK_MISC (entry->label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (status->table), entry->label, + 1, 7, row, row + 1, + GTK_FILL, GTK_FILL, 0, 2); + + entry->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT); + gtk_widget_set_size_request (entry->arrow, CELL_SIZE, CELL_SIZE); + gtk_table_attach (GTK_TABLE (status->table), entry->arrow, + 0, 1, row, row + 1, + GTK_FILL, GTK_FILL, 0, 0); + + row++; + + /* the tool */ + + entry->tool = gimp_prop_preview_new (G_OBJECT (context), + "tool", CELL_SIZE); + GIMP_PREVIEW (entry->tool)->clickable = TRUE; + gtk_table_attach (GTK_TABLE (status->table), entry->tool, + 1, 2, row, row + 1, + 0, 0, 0, 0); + + g_signal_connect (entry->tool, "clicked", + G_CALLBACK (gimp_device_status_preview_clicked), + "gimp-tool-list"); + + /* the foreground color */ + + entry->foreground = gimp_prop_color_area_new (G_OBJECT (context), + "foreground", + CELL_SIZE, CELL_SIZE, + GIMP_COLOR_AREA_FLAT); + gtk_widget_add_events (entry->foreground, + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + gtk_table_attach (GTK_TABLE (status->table), entry->foreground, + 2, 3, row, row + 1, + 0, 0, 0, 0); + + /* the background color */ + + entry->background = gimp_prop_color_area_new (G_OBJECT (context), + "background", + CELL_SIZE, CELL_SIZE, + GIMP_COLOR_AREA_FLAT); + gtk_widget_add_events (entry->background, + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + gtk_table_attach (GTK_TABLE (status->table), entry->background, + 3, 4, row, row + 1, + 0, 0, 0, 0); + + /* the brush */ + + entry->brush = gimp_prop_preview_new (G_OBJECT (context), + "brush", CELL_SIZE); + GIMP_PREVIEW (entry->brush)->clickable = TRUE; + GIMP_PREVIEW (entry->brush)->show_popup = TRUE; + gtk_table_attach (GTK_TABLE (status->table), entry->brush, + 4, 5, row, row + 1, + 0, 0, 0, 0); + + g_signal_connect (entry->brush, "clicked", + G_CALLBACK (gimp_device_status_preview_clicked), + "gimp-brush-grid"); + + /* the pattern */ + + entry->pattern = gimp_prop_preview_new (G_OBJECT (context), + "pattern", CELL_SIZE); + GIMP_PREVIEW (entry->pattern)->clickable = TRUE; + GIMP_PREVIEW (entry->pattern)->show_popup = TRUE; + gtk_table_attach (GTK_TABLE (status->table), entry->pattern, + 5, 6, row, row + 1, + 0, 0, 0, 0); + + g_signal_connect (entry->pattern, "clicked", + G_CALLBACK (gimp_device_status_preview_clicked), + "gimp-pattern-grid"); + + /* the gradient */ + + entry->gradient = gimp_prop_preview_new (G_OBJECT (context), + "gradient", 2 * CELL_SIZE); + GIMP_PREVIEW (entry->gradient)->clickable = TRUE; + GIMP_PREVIEW (entry->gradient)->show_popup = TRUE; + gtk_table_attach (GTK_TABLE (status->table), entry->gradient, + 6, 7, row, row + 1, + 0, 0, 0, 0); + + g_signal_connect (entry->gradient, "clicked", + G_CALLBACK (gimp_device_status_preview_clicked), + "gimp-gradient-list"); + + gimp_device_status_update_entry (device_info, entry); + } + + status->save_button = + gimp_editor_add_button (GIMP_EDITOR (status), GTK_STOCK_SAVE, + _("Save device status"), NULL, + G_CALLBACK (gimp_device_status_save_clicked), + NULL, + status); + + status->edit_button = + gimp_editor_add_button (GIMP_EDITOR (status), GIMP_STOCK_EDIT, + _("Configure input devices"), NULL, + G_CALLBACK (gimp_device_status_edit_clicked), + NULL, + status); +} + +static void +gimp_device_status_destroy (GtkObject *object) +{ + GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object); + + if (status->entries) + { + gint i; + + for (i = 0; i < status->num_devices; i++) + { + GimpDeviceStatusEntry *entry = &status->entries[i]; + + g_signal_handlers_disconnect_by_func (entry->device, + gimp_device_status_update_entry, + entry); + } + + g_free (status->entries); + status->entries = NULL; + status->num_devices = 0; + } + + GTK_OBJECT_CLASS (parent_class)->destroy (object); +} + +static void +gimp_device_status_unmap (GtkWidget *widget) +{ + GimpDeviceStatus *status = GIMP_DEVICE_STATUS (widget); + + GTK_WIDGET_CLASS (parent_class)->unmap (widget); +} + +GtkWidget * +gimp_device_status_new (Gimp *gimp) +{ + GimpDeviceStatus *status; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + + status = g_object_new (GIMP_TYPE_DEVICE_STATUS, NULL); + + status->gimp = gimp; + + gimp_device_status_update (status); + + return GTK_WIDGET (status); +} + +void +gimp_device_status_update (GimpDeviceStatus *status) +{ + gint i; + + g_return_if_fail (GIMP_IS_DEVICE_STATUS (status)); + + status->current_device = gimp_devices_get_current (status->gimp); + + for (i = 0; i < status->num_devices; i++) + { + GimpDeviceStatusEntry *entry = &status->entries[i]; + + if (entry->device == status->current_device) + gtk_widget_show (entry->arrow); + else + gtk_widget_hide (entry->arrow); + } +} + + +/* private functions */ + +static void +gimp_device_status_update_entry (GimpDeviceInfo *device_info, + GimpDeviceStatusEntry *entry) +{ + if (device_info->device->mode == GDK_MODE_DISABLED) + { + gtk_widget_hide (entry->separator); + gtk_widget_hide (entry->label); + gtk_widget_hide (entry->tool); + gtk_widget_hide (entry->foreground); + gtk_widget_hide (entry->background); + gtk_widget_hide (entry->brush); + gtk_widget_hide (entry->pattern); + gtk_widget_hide (entry->gradient); + } + else + { + GimpContext *context; + GimpRGB color; + guchar r, g, b; + gchar buf[64]; + + gtk_widget_show (entry->separator); + gtk_widget_show (entry->label); + gtk_widget_show (entry->tool); + gtk_widget_show (entry->foreground); + gtk_widget_show (entry->background); + gtk_widget_show (entry->brush); + gtk_widget_show (entry->pattern); + gtk_widget_show (entry->gradient); + + context = GIMP_CONTEXT (device_info); + + gimp_context_get_foreground (context, &color); + gimp_rgb_get_uchar (&color, &r, &g, &b); + g_snprintf (buf, sizeof (buf), _("Foreground: %d, %d, %d"), r, g, b); + gimp_help_set_help_data (entry->foreground, buf, NULL); + + gimp_context_get_background (context, &color); + gimp_rgb_get_uchar (&color, &r, &g, &b); + g_snprintf (buf, sizeof (buf), _("Background: %d, %d, %d"), r, g, b); + gimp_help_set_help_data (entry->background, buf, NULL); + } +} + +static void +gimp_device_status_save_clicked (GtkWidget *button, + GimpDeviceStatus *status) +{ + gimp_devices_save (status->gimp); +} + +static void +gimp_device_status_edit_clicked (GtkWidget *button, + GimpDeviceStatus *status) +{ +} + +static void +gimp_device_status_preview_clicked (GtkWidget *widget, + GdkModifierType state, + const gchar *identifier) +{ + GimpDialogFactory *dialog_factory; + + dialog_factory = gimp_dialog_factory_from_name ("dock"); + + gimp_dialog_factory_dialog_raise (dialog_factory, identifier, -1); +} diff --git a/app/widgets/gimpdevicestatus.h b/app/widgets/gimpdevicestatus.h new file mode 100644 index 0000000000..ee3697dc99 --- /dev/null +++ b/app/widgets/gimpdevicestatus.h @@ -0,0 +1,68 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpdevicestatus.h + * Copyright (C) 2003 Michael Natterer + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_DEVICE_STATUS_H__ +#define __GIMP_DEVICE_STATUS_H__ + + +#include "gimpeditor.h" + + +#define GIMP_TYPE_DEVICE_STATUS (gimp_device_status_get_type ()) +#define GIMP_DEVICE_STATUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DEVICE_STATUS, GimpDeviceStatus)) +#define GIMP_DEVICE_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DEVICE_STATUS, GimpDeviceStatusClass)) +#define GIMP_IS_DEVICE_STATUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DEVICE_STATUS)) +#define GIMP_IS_DEVICE_STATUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DEVICE_STATUS)) +#define GIMP_DEVICE_STATUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DEVICE_STATUS, GimpDeviceStatusClass)) + + +typedef struct _GimpDeviceStatusEntry GimpDeviceStatusEntry; +typedef struct _GimpDeviceStatusClass GimpDeviceStatusClass; + +struct _GimpDeviceStatus +{ + GimpEditor parent_instance; + + Gimp *gimp; + GdkDevice *current_device; + + gint num_devices; + GimpDeviceStatusEntry *entries; + + GtkWidget *table; + + GtkWidget *save_button; + GtkWidget *edit_button; +}; + +struct _GimpDeviceStatusClass +{ + GimpEditorClass parent_class; +}; + + +GType gimp_device_status_get_type (void) G_GNUC_CONST; + +GtkWidget * gimp_device_status_new (Gimp *gimp); +void gimp_device_status_update (GimpDeviceStatus *status); + + +#endif /* __GIMP_DEVICE_STATUS_H__ */ diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c index 5e0ac8c451..41cc6c0ae8 100644 --- a/app/widgets/gimppropwidgets.c +++ b/app/widgets/gimppropwidgets.c @@ -2056,6 +2056,106 @@ gimp_prop_coordinates_notify_unit (GObject *config, } +/****************/ +/* color area */ +/****************/ + +static void gimp_prop_color_area_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_color_area_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *area); + +GtkWidget * +gimp_prop_color_area_new (GObject *config, + const gchar *property_name, + gint width, + gint height, + GimpColorAreaType type) +{ + GParamSpec *param_spec; + GtkWidget *area; + GimpRGB *value; + + param_spec = check_param_spec (config, property_name, + GIMP_TYPE_PARAM_COLOR, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &value, + NULL); + + area = gimp_color_area_new (value, type, + GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); + gtk_widget_set_size_request (area, width, height); + + g_free (value); + + set_param_spec (G_OBJECT (area), area, param_spec); + + g_signal_connect (area, "color_changed", + G_CALLBACK (gimp_prop_color_area_callback), + config); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_color_area_notify), + area); + + return area; +} + +static void +gimp_prop_color_area_callback (GtkWidget *area, + GObject *config) +{ + GParamSpec *param_spec; + GimpRGB value; + + param_spec = get_param_spec (G_OBJECT (area)); + if (! param_spec) + return; + + gimp_color_area_get_color (GIMP_COLOR_AREA (area), &value); + + g_signal_handlers_block_by_func (config, + gimp_prop_color_area_notify, + area); + + g_object_set (config, + param_spec->name, &value, + NULL); + + g_signal_handlers_unblock_by_func (config, + gimp_prop_color_area_notify, + area); +} + +static void +gimp_prop_color_area_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *area) +{ + GimpRGB *value; + + g_object_get (config, + param_spec->name, &value, + NULL); + + g_signal_handlers_block_by_func (area, + gimp_prop_color_area_callback, + config); + + gimp_color_area_set_color (GIMP_COLOR_AREA (area), value); + + g_free (value); + + g_signal_handlers_unblock_by_func (area, + gimp_prop_color_area_callback, + config); +} + + /******************/ /* color button */ /******************/ @@ -2361,6 +2461,67 @@ gimp_prop_preview_notify (GObject *config, } +/*****************/ +/* stock image */ +/*****************/ + +static void gimp_prop_stock_image_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *image); + +GtkWidget * +gimp_prop_stock_image_new (GObject *config, + const gchar *property_name, + GtkIconSize icon_size) +{ + GParamSpec *param_spec; + GtkWidget *image; + gchar *stock_id; + + param_spec = check_param_spec (config, property_name, + G_TYPE_PARAM_STRING, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &stock_id, + NULL); + + g_print ("stock_id: %s\n", stock_id); + + image = gtk_image_new_from_stock (stock_id, icon_size); + + if (stock_id) + g_free (stock_id); + + set_param_spec (G_OBJECT (image), image, param_spec); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_stock_image_notify), + image); + + return image; +} + +static void +gimp_prop_stock_image_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *image) +{ + gchar *stock_id; + + g_object_get (config, + param_spec->name, &stock_id, + NULL); + + gtk_image_set_from_stock (GTK_IMAGE (image), stock_id, + GTK_IMAGE (image)->icon_size); + + if (stock_id) + g_free (stock_id); +} + + /*******************************/ /* private utility functions */ /*******************************/ diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h index daae8af8b9..cc5280b17b 100644 --- a/app/widgets/gimppropwidgets.h +++ b/app/widgets/gimppropwidgets.h @@ -152,6 +152,11 @@ gboolean gimp_prop_size_entry_connect (GObject *config, /* GimpParamColor */ +GtkWidget * gimp_prop_color_area_new (GObject *config, + const gchar *property_name, + gint width, + gint height, + GimpColorAreaType type); GtkWidget * gimp_prop_color_button_new (GObject *config, const gchar *property_name, const gchar *title, @@ -173,4 +178,11 @@ GtkWidget * gimp_prop_preview_new (GObject *config, gint size); +/* GParamString (stock_id) */ + +GtkWidget * gimp_prop_stock_image_new (GObject *config, + const gchar *property_name, + GtkIconSize icon_size); + + #endif /* __GIMP_PROP_WIDGETS_H__ */ diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index 61940717bb..be11d0136c 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -60,6 +60,7 @@ typedef struct _GimpMenuItem GimpMenuItem; typedef struct _GimpEnumMenu GimpEnumMenu; typedef struct _GimpEditor GimpEditor; +typedef struct _GimpDeviceStatus GimpDeviceStatus; typedef struct _GimpErrorConsole GimpErrorConsole; typedef struct _GimpImageEditor GimpImageEditor; typedef struct _GimpColorEditor GimpColorEditor; diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index 5e0ac8c451..41cc6c0ae8 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -2056,6 +2056,106 @@ gimp_prop_coordinates_notify_unit (GObject *config, } +/****************/ +/* color area */ +/****************/ + +static void gimp_prop_color_area_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_color_area_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *area); + +GtkWidget * +gimp_prop_color_area_new (GObject *config, + const gchar *property_name, + gint width, + gint height, + GimpColorAreaType type) +{ + GParamSpec *param_spec; + GtkWidget *area; + GimpRGB *value; + + param_spec = check_param_spec (config, property_name, + GIMP_TYPE_PARAM_COLOR, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &value, + NULL); + + area = gimp_color_area_new (value, type, + GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); + gtk_widget_set_size_request (area, width, height); + + g_free (value); + + set_param_spec (G_OBJECT (area), area, param_spec); + + g_signal_connect (area, "color_changed", + G_CALLBACK (gimp_prop_color_area_callback), + config); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_color_area_notify), + area); + + return area; +} + +static void +gimp_prop_color_area_callback (GtkWidget *area, + GObject *config) +{ + GParamSpec *param_spec; + GimpRGB value; + + param_spec = get_param_spec (G_OBJECT (area)); + if (! param_spec) + return; + + gimp_color_area_get_color (GIMP_COLOR_AREA (area), &value); + + g_signal_handlers_block_by_func (config, + gimp_prop_color_area_notify, + area); + + g_object_set (config, + param_spec->name, &value, + NULL); + + g_signal_handlers_unblock_by_func (config, + gimp_prop_color_area_notify, + area); +} + +static void +gimp_prop_color_area_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *area) +{ + GimpRGB *value; + + g_object_get (config, + param_spec->name, &value, + NULL); + + g_signal_handlers_block_by_func (area, + gimp_prop_color_area_callback, + config); + + gimp_color_area_set_color (GIMP_COLOR_AREA (area), value); + + g_free (value); + + g_signal_handlers_unblock_by_func (area, + gimp_prop_color_area_callback, + config); +} + + /******************/ /* color button */ /******************/ @@ -2361,6 +2461,67 @@ gimp_prop_preview_notify (GObject *config, } +/*****************/ +/* stock image */ +/*****************/ + +static void gimp_prop_stock_image_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *image); + +GtkWidget * +gimp_prop_stock_image_new (GObject *config, + const gchar *property_name, + GtkIconSize icon_size) +{ + GParamSpec *param_spec; + GtkWidget *image; + gchar *stock_id; + + param_spec = check_param_spec (config, property_name, + G_TYPE_PARAM_STRING, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &stock_id, + NULL); + + g_print ("stock_id: %s\n", stock_id); + + image = gtk_image_new_from_stock (stock_id, icon_size); + + if (stock_id) + g_free (stock_id); + + set_param_spec (G_OBJECT (image), image, param_spec); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_stock_image_notify), + image); + + return image; +} + +static void +gimp_prop_stock_image_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *image) +{ + gchar *stock_id; + + g_object_get (config, + param_spec->name, &stock_id, + NULL); + + gtk_image_set_from_stock (GTK_IMAGE (image), stock_id, + GTK_IMAGE (image)->icon_size); + + if (stock_id) + g_free (stock_id); +} + + /*******************************/ /* private utility functions */ /*******************************/ diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h index daae8af8b9..cc5280b17b 100644 --- a/libgimpwidgets/gimppropwidgets.h +++ b/libgimpwidgets/gimppropwidgets.h @@ -152,6 +152,11 @@ gboolean gimp_prop_size_entry_connect (GObject *config, /* GimpParamColor */ +GtkWidget * gimp_prop_color_area_new (GObject *config, + const gchar *property_name, + gint width, + gint height, + GimpColorAreaType type); GtkWidget * gimp_prop_color_button_new (GObject *config, const gchar *property_name, const gchar *title, @@ -173,4 +178,11 @@ GtkWidget * gimp_prop_preview_new (GObject *config, gint size); +/* GParamString (stock_id) */ + +GtkWidget * gimp_prop_stock_image_new (GObject *config, + const gchar *property_name, + GtkIconSize icon_size); + + #endif /* __GIMP_PROP_WIDGETS_H__ */