Commit 439a3ff7 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 667862 - Allow mouse to optionally configure tablet devices

Add new setting GimpGuiConfig:devices-share-tool. When TRUE, we never
copy any properties between the user context and the GimpDeviceInfo's
context, so no tool or anything changes.

We do however still keep track of the active device so the setting can
be enabled/disabled at any time. Also hide GimpDeviceStatus' tool,
brush etc. indicators in "shared" mode.
parent 5cf3cf27
......@@ -50,6 +50,7 @@ enum
PROP_FILTER_TOOL_MAX_RECENT,
PROP_TRUST_DIRTY_FLAG,
PROP_SAVE_DEVICE_STATUS,
PROP_DEVICES_SHARE_TOOL,
PROP_SAVE_SESSION_INFO,
PROP_RESTORE_SESSION,
PROP_RESTORE_MONITOR,
......@@ -156,6 +157,13 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DEVICES_SHARE_TOOL,
"devices-share-tool",
"Devics share tool",
DEVICES_SHARE_TOOL_BLURB,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_SESSION_INFO,
"save-session-info",
"Save session",
......@@ -538,6 +546,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_SAVE_DEVICE_STATUS:
gui_config->save_device_status = g_value_get_boolean (value);
break;
case PROP_DEVICES_SHARE_TOOL:
gui_config->devices_share_tool = g_value_get_boolean (value);
break;
case PROP_SAVE_SESSION_INFO:
gui_config->save_session_info = g_value_get_boolean (value);
break;
......@@ -695,6 +706,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_SAVE_DEVICE_STATUS:
g_value_set_boolean (value, gui_config->save_device_status);
break;
case PROP_DEVICES_SHARE_TOOL:
g_value_set_boolean (value, gui_config->devices_share_tool);
break;
case PROP_SAVE_SESSION_INFO:
g_value_set_boolean (value, gui_config->save_session_info);
break;
......
......@@ -45,6 +45,7 @@ struct _GimpGuiConfig
gint filter_tool_max_recent;
gboolean trust_dirty_flag;
gboolean save_device_status;
gboolean devices_share_tool;
gboolean save_session_info;
gboolean restore_session;
gboolean restore_monitor;
......
......@@ -291,6 +291,11 @@ _("When enabled, GIMP will try to restore windows on the monitor they " \
_("Remember the current tool, pattern, color, and brush across GIMP " \
"sessions.")
#define DEVICES_SHARE_TOOL_BLURB \
_("When enabled, the same tool and tool options will be used for all " \
"input devices. No tool switching will occur when the input device " \
"changes.")
#define SAVE_DOCUMENT_HISTORY_BLURB \
_("Keep a permanent record of all opened and saved files in the Recent " \
"Documents list.")
......
......@@ -2609,6 +2609,10 @@ prefs_dialog_new (Gimp *gimp,
vbox2 = prefs_frame_new (_("Extended Input Devices"),
GTK_CONTAINER (vbox), FALSE);
prefs_check_button_add (object, "devices-share-tool",
_("S_hare tool and tool options between input devices"),
GTK_BOX (vbox2));
button = prefs_button_add ("preferences-system",
_("Configure E_xtended Input Devices..."),
GTK_BOX (vbox2));
......
......@@ -27,6 +27,8 @@
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpmarshal.h"
......@@ -82,6 +84,10 @@ static void gimp_device_manager_device_removed (GdkDisplay *gdk_display
GdkDevice *device,
GimpDeviceManager *manager);
static void gimp_device_manager_config_notify (GimpGuiConfig *config,
const GParamSpec *pspec,
GimpDeviceManager *manager);
G_DEFINE_TYPE (GimpDeviceManager, gimp_device_manager, GIMP_TYPE_LIST)
......@@ -158,6 +164,10 @@ gimp_device_manager_constructed (GObject *object)
private->current_device =
gimp_device_info_get_by_device (gdk_display_get_core_pointer (display));
g_signal_connect_object (private->gimp->config, "notify::devices-share-tool",
G_CALLBACK (gimp_device_manager_config_notify),
manager, 0);
}
static void
......@@ -250,22 +260,30 @@ gimp_device_manager_set_current_device (GimpDeviceManager *manager,
GimpDeviceInfo *info)
{
GimpDeviceManagerPrivate *private;
GimpContext *user_context;
GimpGuiConfig *config;
g_return_if_fail (GIMP_IS_DEVICE_MANAGER (manager));
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
private = GET_PRIVATE (manager);
gimp_context_set_parent (GIMP_CONTEXT (private->current_device), NULL);
config = GIMP_GUI_CONFIG (private->gimp->config);
if (! config->devices_share_tool)
{
gimp_context_set_parent (GIMP_CONTEXT (private->current_device), NULL);
}
private->current_device = info;
user_context = gimp_get_user_context (private->gimp);
if (! config->devices_share_tool)
{
GimpContext *user_context = gimp_get_user_context (private->gimp);
gimp_context_copy_properties (GIMP_CONTEXT (info), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (info), user_context);
gimp_context_copy_properties (GIMP_CONTEXT (info), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (info), user_context);
}
g_object_notify (G_OBJECT (manager), "current-device");
}
......@@ -361,3 +379,27 @@ gimp_device_manager_device_removed (GdkDisplay *gdk_display,
}
}
}
static void
gimp_device_manager_config_notify (GimpGuiConfig *config,
const GParamSpec *pspec,
GimpDeviceManager *manager)
{
GimpDeviceManagerPrivate *private = GET_PRIVATE (manager);
GimpDeviceInfo *current_device;
current_device = gimp_device_manager_get_current_device (manager);
if (GIMP_GUI_CONFIG (private->gimp->config)->devices_share_tool)
{
gimp_context_set_parent (GIMP_CONTEXT (current_device), NULL);
}
else
{
GimpContext *user_context = gimp_get_user_context (private->gimp);
gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context);
}
}
......@@ -26,6 +26,8 @@
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpdatafactory.h"
#include "core/gimperror.h"
......@@ -86,7 +88,6 @@ gimp_devices_restore (Gimp *gimp)
{
GimpDeviceManager *manager;
GimpContext *user_context;
GimpDeviceInfo *current_device;
GList *list;
GFile *file;
GError *error = NULL;
......@@ -130,11 +131,16 @@ gimp_devices_restore (Gimp *gimp)
g_object_unref (file);
current_device = gimp_device_manager_get_current_device (manager);
if (! GIMP_GUI_CONFIG (gimp->config)->devices_share_tool)
{
GimpDeviceInfo *current_device;
current_device = gimp_device_manager_get_current_device (manager);
gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context);
gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context);
}
}
void
......
......@@ -30,6 +30,8 @@
#include "widgets-types.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
#include "core/gimpdatafactory.h"
......@@ -67,6 +69,7 @@ struct _GimpDeviceStatusEntry
GimpDeviceInfo *device_info;
GtkWidget *ebox;
GtkWidget *options_hbox;
GtkWidget *tool;
GtkWidget *foreground;
GtkWidget *background;
......@@ -93,6 +96,9 @@ static void gimp_device_status_device_remove (GimpContainer *devices,
static void gimp_device_status_notify_device (GimpDeviceManager *manager,
const GParamSpec *pspec,
GimpDeviceStatus *status);
static void gimp_device_status_config_notify (GimpGuiConfig *config,
const GParamSpec *pspec,
GimpDeviceStatus *status);
static void gimp_device_status_update_entry (GimpDeviceInfo *device_info,
GimpDeviceStatusEntry *entry);
static void gimp_device_status_save_clicked (GtkWidget *button,
......@@ -170,6 +176,13 @@ gimp_device_status_constructed (GObject *object)
status);
gimp_device_status_notify_device (GIMP_DEVICE_MANAGER (devices), NULL, status);
g_signal_connect_object (status->gimp->config, "notify::devices-share-tool",
G_CALLBACK (gimp_device_status_config_notify),
status, 0);
gimp_device_status_config_notify (GIMP_GUI_CONFIG (status->gimp->config),
NULL, status);
}
static void
......@@ -280,7 +293,7 @@ gimp_device_status_device_add (GimpContainer *devices,
/* the row of properties */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
hbox = entry->options_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
......@@ -413,6 +426,24 @@ gimp_device_status_notify_device (GimpDeviceManager *manager,
}
}
static void
gimp_device_status_config_notify (GimpGuiConfig *config,
const GParamSpec *pspec,
GimpDeviceStatus *status)
{
gboolean show_options;
GList *list;
show_options = ! GIMP_GUI_CONFIG (status->gimp->config)->devices_share_tool;
for (list = status->devices; list; list = list->next)
{
GimpDeviceStatusEntry *entry = list->data;
gtk_widget_set_visible (entry->options_hbox, show_options);
}
}
static void
gimp_device_status_update_entry (GimpDeviceInfo *device_info,
GimpDeviceStatusEntry *entry)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment