2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-07-07 21:37:19 +08:00
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdevicestatus.c
|
|
|
|
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-07-07 21:37:19 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-07-07 21:37:19 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-07-07 21:37:19 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2010-05-30 23:19:47 +08:00
|
|
|
#undef GSEAL_ENABLE
|
|
|
|
|
2012-03-18 04:59:10 +08:00
|
|
|
#include <gegl.h>
|
2003-07-07 21:37:19 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpdatafactory.h"
|
|
|
|
#include "core/gimpgradient.h"
|
2005-11-28 01:20:40 +08:00
|
|
|
#include "core/gimplist.h"
|
2003-07-07 21:37:19 +08:00
|
|
|
#include "core/gimppattern.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "gimpdnd.h"
|
|
|
|
#include "gimpdeviceinfo.h"
|
2011-02-28 21:37:00 +08:00
|
|
|
#include "gimpdevicemanager.h"
|
2003-07-07 21:37:19 +08:00
|
|
|
#include "gimpdevices.h"
|
|
|
|
#include "gimpdevicestatus.h"
|
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimppropwidgets.h"
|
2005-02-05 04:47:42 +08:00
|
|
|
#include "gimpview.h"
|
2012-01-31 06:52:59 +08:00
|
|
|
#include "gimpwindowstrategy.h"
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2004-08-25 01:16:46 +08:00
|
|
|
#define CELL_SIZE 20 /* The size of the view cells */
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_GIMP
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-07 21:37:19 +08:00
|
|
|
struct _GimpDeviceStatusEntry
|
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpDeviceInfo *device_info;
|
|
|
|
|
2011-02-28 23:43:21 +08:00
|
|
|
GtkWidget *ebox;
|
2005-11-28 01:20:40 +08:00
|
|
|
GtkWidget *tool;
|
|
|
|
GtkWidget *foreground;
|
|
|
|
GtkWidget *background;
|
|
|
|
GtkWidget *brush;
|
|
|
|
GtkWidget *pattern;
|
|
|
|
GtkWidget *gradient;
|
2003-07-07 21:37:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_device_status_constructed (GObject *object);
|
2010-10-15 19:48:36 +08:00
|
|
|
static void gimp_device_status_dispose (GObject *object);
|
2005-11-28 01:20:40 +08:00
|
|
|
static void gimp_device_status_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_device_status_device_add (GimpContainer *devices,
|
|
|
|
GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatus *status);
|
|
|
|
static void gimp_device_status_device_remove (GimpContainer *devices,
|
|
|
|
GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatus *status);
|
|
|
|
|
2011-02-28 21:37:00 +08:00
|
|
|
static void gimp_device_status_notify_device (GimpDeviceManager *manager,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpDeviceStatus *status);
|
2003-07-07 21:37:19 +08:00
|
|
|
static void gimp_device_status_update_entry (GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatusEntry *entry);
|
|
|
|
static void gimp_device_status_save_clicked (GtkWidget *button,
|
|
|
|
GimpDeviceStatus *status);
|
2006-01-17 18:08:50 +08:00
|
|
|
static void gimp_device_status_view_clicked (GtkWidget *widget,
|
2003-07-07 21:37:19 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
const gchar *identifier);
|
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpDeviceStatus, gimp_device_status, GIMP_TYPE_EDITOR)
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_device_status_parent_class
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_class_init (GimpDeviceStatusClass *klass)
|
|
|
|
{
|
2010-10-15 19:48:36 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
object_class->constructed = gimp_device_status_constructed;
|
2010-10-15 19:48:36 +08:00
|
|
|
object_class->dispose = gimp_device_status_dispose;
|
2005-11-28 01:20:40 +08:00
|
|
|
object_class->set_property = gimp_device_status_set_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_GIMP,
|
|
|
|
g_param_spec_object ("gimp", NULL, NULL,
|
|
|
|
GIMP_TYPE_GIMP,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_WRITABLE |
|
2005-11-28 01:20:40 +08:00
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_init (GimpDeviceStatus *status)
|
|
|
|
{
|
|
|
|
status->gimp = NULL;
|
|
|
|
status->current_device = NULL;
|
2005-11-28 01:20:40 +08:00
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
status->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2011-02-28 23:43:21 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (status->vbox), 2);
|
2010-10-30 21:42:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (status), status->vbox, TRUE, TRUE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (status->vbox);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void
|
|
|
|
gimp_device_status_constructed (GObject *object)
|
2005-11-28 01:20:40 +08:00
|
|
|
{
|
2011-01-14 16:38:11 +08:00
|
|
|
GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object);
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpContainer *devices;
|
|
|
|
GList *list;
|
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
g_assert (GIMP_IS_GIMP (status->gimp));
|
|
|
|
|
2011-02-28 21:37:00 +08:00
|
|
|
devices = GIMP_CONTAINER (gimp_devices_get_manager (status->gimp));
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
for (list = GIMP_LIST (devices)->list; list; list = list->next)
|
|
|
|
gimp_device_status_device_add (devices, list->data, status);
|
|
|
|
|
|
|
|
g_signal_connect_object (devices, "add",
|
|
|
|
G_CALLBACK (gimp_device_status_device_add),
|
|
|
|
status, 0);
|
|
|
|
g_signal_connect_object (devices, "remove",
|
|
|
|
G_CALLBACK (gimp_device_status_device_remove),
|
|
|
|
status, 0);
|
|
|
|
|
2011-02-28 21:37:00 +08:00
|
|
|
g_signal_connect (devices, "notify::current-device",
|
|
|
|
G_CALLBACK (gimp_device_status_notify_device),
|
|
|
|
status);
|
|
|
|
|
|
|
|
gimp_device_status_notify_device (GIMP_DEVICE_MANAGER (devices), NULL, status);
|
2005-11-28 01:20:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-15 19:48:36 +08:00
|
|
|
gimp_device_status_dispose (GObject *object)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
|
|
|
GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object);
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
if (status->devices)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GList *list;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
for (list = status->devices; list; list = list->next)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpDeviceStatusEntry *entry = list->data;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (entry->device_info,
|
2003-07-07 21:37:19 +08:00
|
|
|
gimp_device_status_update_entry,
|
|
|
|
entry);
|
2007-05-23 00:18:32 +08:00
|
|
|
|
|
|
|
g_slice_free (GimpDeviceStatusEntry, entry);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
g_list_free (status->devices);
|
|
|
|
status->devices = NULL;
|
2011-02-28 21:37:00 +08:00
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (gimp_devices_get_manager (status->gimp),
|
|
|
|
gimp_device_status_notify_device,
|
|
|
|
status);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
2010-10-15 19:48:36 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_GIMP:
|
|
|
|
status->gimp = g_value_get_object (value);
|
|
|
|
break;
|
2011-02-28 21:37:00 +08:00
|
|
|
|
2010-10-15 19:48:36 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
static void
|
|
|
|
gimp_device_status_device_add (GimpContainer *devices,
|
|
|
|
GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatus *status)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (device_info);
|
|
|
|
GimpDeviceStatusEntry *entry;
|
|
|
|
GClosure *closure;
|
2011-03-01 20:28:58 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
2005-11-28 01:20:40 +08:00
|
|
|
gchar *name;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2007-05-23 00:18:32 +08:00
|
|
|
entry = g_slice_new0 (GimpDeviceStatusEntry);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
status->devices = g_list_prepend (status->devices, entry);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
entry->device_info = device_info;
|
|
|
|
|
|
|
|
closure = g_cclosure_new (G_CALLBACK (gimp_device_status_update_entry),
|
|
|
|
entry, NULL);
|
|
|
|
g_object_watch_closure (G_OBJECT (status), closure);
|
|
|
|
g_signal_connect_closure (device_info, "changed", closure, FALSE);
|
|
|
|
|
2011-02-28 23:43:21 +08:00
|
|
|
entry->ebox = gtk_event_box_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (status->vbox), entry->ebox,
|
2005-11-28 01:20:40 +08:00
|
|
|
FALSE, FALSE, 0);
|
2011-02-28 23:43:21 +08:00
|
|
|
gtk_widget_show (entry->ebox);
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (entry->ebox), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
/* the device name */
|
|
|
|
|
2011-03-01 00:36:53 +08:00
|
|
|
if (device_info->display == NULL ||
|
|
|
|
device_info->display == gdk_display_get_default ())
|
2009-09-01 04:47:18 +08:00
|
|
|
name = g_strdup (gimp_object_get_name (device_info));
|
2005-11-28 01:20:40 +08:00
|
|
|
else
|
|
|
|
name = g_strdup_printf ("%s (%s)",
|
2009-09-01 04:47:18 +08:00
|
|
|
gimp_object_get_name (device_info),
|
2005-11-28 01:20:40 +08:00
|
|
|
gdk_display_get_name (device_info->display));
|
|
|
|
|
2011-03-01 20:28:58 +08:00
|
|
|
label = gtk_label_new (name);
|
2005-11-28 01:20:40 +08:00
|
|
|
g_free (name);
|
|
|
|
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
2005-11-28 01:20:40 +08:00
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
-1);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
/* the row of properties */
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
/* the tool */
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
entry->tool = gimp_prop_view_new (G_OBJECT (context), "tool",
|
|
|
|
context, CELL_SIZE);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->tool, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->tool);
|
|
|
|
|
|
|
|
/* 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);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->foreground, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->foreground);
|
|
|
|
|
|
|
|
/* 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);
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->background, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->background);
|
|
|
|
|
|
|
|
/* the brush */
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
entry->brush = gimp_prop_view_new (G_OBJECT (context), "brush",
|
|
|
|
context, CELL_SIZE);
|
2005-11-28 01:20:40 +08:00
|
|
|
GIMP_VIEW (entry->brush)->clickable = TRUE;
|
|
|
|
GIMP_VIEW (entry->brush)->show_popup = TRUE;
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->brush, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->brush);
|
|
|
|
|
|
|
|
g_signal_connect (entry->brush, "clicked",
|
2006-01-17 18:08:50 +08:00
|
|
|
G_CALLBACK (gimp_device_status_view_clicked),
|
2005-11-28 01:20:40 +08:00
|
|
|
"gimp-brush-grid|gimp-brush-list");
|
|
|
|
|
|
|
|
/* the pattern */
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
entry->pattern = gimp_prop_view_new (G_OBJECT (context), "pattern",
|
|
|
|
context, CELL_SIZE);
|
2005-11-28 01:20:40 +08:00
|
|
|
GIMP_VIEW (entry->pattern)->clickable = TRUE;
|
|
|
|
GIMP_VIEW (entry->pattern)->show_popup = TRUE;
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->pattern, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->pattern);
|
|
|
|
|
|
|
|
g_signal_connect (entry->pattern, "clicked",
|
2006-01-17 18:08:50 +08:00
|
|
|
G_CALLBACK (gimp_device_status_view_clicked),
|
2005-11-28 01:20:40 +08:00
|
|
|
"gimp-pattern-grid|gimp-pattern-list");
|
|
|
|
|
|
|
|
/* the gradient */
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
entry->gradient = gimp_prop_view_new (G_OBJECT (context), "gradient",
|
|
|
|
context, 2 * CELL_SIZE);
|
2005-11-28 01:20:40 +08:00
|
|
|
GIMP_VIEW (entry->gradient)->clickable = TRUE;
|
|
|
|
GIMP_VIEW (entry->gradient)->show_popup = TRUE;
|
2011-03-01 20:28:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry->gradient, FALSE, FALSE, 0);
|
2005-11-28 01:20:40 +08:00
|
|
|
gtk_widget_show (entry->gradient);
|
|
|
|
|
|
|
|
g_signal_connect (entry->gradient, "clicked",
|
2006-01-17 18:08:50 +08:00
|
|
|
G_CALLBACK (gimp_device_status_view_clicked),
|
2005-11-28 01:20:40 +08:00
|
|
|
"gimp-gradient-list|gimp-gradient-grid");
|
|
|
|
|
|
|
|
gimp_device_status_update_entry (device_info, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_device_remove (GimpContainer *devices,
|
|
|
|
GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatus *status)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = status->devices; list; list = list->next)
|
|
|
|
{
|
|
|
|
GimpDeviceStatusEntry *entry = list->data;
|
|
|
|
|
|
|
|
if (entry->device_info == device_info)
|
|
|
|
{
|
|
|
|
status->devices = g_list_remove (status->devices, entry);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (entry->device_info,
|
|
|
|
gimp_device_status_update_entry,
|
|
|
|
entry);
|
2007-05-23 00:18:32 +08:00
|
|
|
|
|
|
|
g_slice_free (GimpDeviceStatusEntry, entry);
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_device_status_new (Gimp *gimp)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_DEVICE_STATUS,
|
|
|
|
"gimp", gimp,
|
|
|
|
NULL);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
2011-02-28 21:37:00 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_notify_device (GimpDeviceManager *manager,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpDeviceStatus *status)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GList *list;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2011-02-28 21:37:00 +08:00
|
|
|
status->current_device = gimp_device_manager_get_current_device (manager);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
for (list = status->devices; list; list = list->next)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpDeviceStatusEntry *entry = list->data;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2011-02-28 23:43:21 +08:00
|
|
|
gtk_widget_set_state (entry->ebox,
|
|
|
|
entry->device_info == status->current_device ?
|
|
|
|
GTK_STATE_SELECTED : GTK_STATE_NORMAL);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_update_entry (GimpDeviceInfo *device_info,
|
|
|
|
GimpDeviceStatusEntry *entry)
|
|
|
|
{
|
2011-02-28 22:55:02 +08:00
|
|
|
if (! gimp_device_info_get_device (device_info, NULL) ||
|
|
|
|
gimp_device_info_get_mode (device_info) == GDK_MODE_DISABLED)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2011-02-28 23:43:21 +08:00
|
|
|
gtk_widget_hide (entry->ebox);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (device_info);
|
2003-07-07 21:37:19 +08:00
|
|
|
GimpRGB color;
|
|
|
|
guchar r, g, b;
|
|
|
|
gchar buf[64];
|
|
|
|
|
|
|
|
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);
|
2005-11-28 01:20:40 +08:00
|
|
|
|
2011-02-28 23:43:21 +08:00
|
|
|
gtk_widget_show (entry->ebox);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_status_save_clicked (GtkWidget *button,
|
|
|
|
GimpDeviceStatus *status)
|
|
|
|
{
|
2004-07-22 00:11:31 +08:00
|
|
|
gimp_devices_save (status->gimp, TRUE);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_device_status_view_clicked (GtkWidget *widget,
|
|
|
|
GdkModifierType state,
|
|
|
|
const gchar *identifier)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2012-01-31 06:52:59 +08:00
|
|
|
GimpDeviceStatus *status;
|
2003-07-07 21:37:19 +08:00
|
|
|
GimpDialogFactory *dialog_factory;
|
|
|
|
|
2012-01-31 06:52:59 +08:00
|
|
|
status = GIMP_DEVICE_STATUS (gtk_widget_get_ancestor (widget,
|
|
|
|
GIMP_TYPE_DEVICE_STATUS));
|
2010-03-01 06:20:57 +08:00
|
|
|
dialog_factory = gimp_dialog_factory_get_singleton ();
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2012-01-31 06:52:59 +08:00
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (status->gimp)),
|
|
|
|
status->gimp,
|
|
|
|
dialog_factory,
|
|
|
|
gtk_widget_get_screen (widget),
|
|
|
|
identifier);
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|