[gimp] app: turn the input devices dialog into a session managed toplevel
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: turn the input devices dialog into a session managed toplevel
- Date: Fri, 19 Feb 2010 19:16:25 +0000 (UTC)
commit d967852cd79a8aea8021f072e58e908d71adf7fa
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 19 17:41:26 2010 +0100
app: turn the input devices dialog into a session managed toplevel
It works exactly as the keyboard shortcuts dialog now and has its own
menu entry: Edit -> Input Devices.
app/actions/dialogs-actions.c | 6 ++
app/dialogs/Makefile.am | 2 +
app/dialogs/dialogs-constructors.c | 10 ++++
app/dialogs/dialogs-constructors.h | 4 ++
app/dialogs/dialogs.c | 2 +
app/dialogs/input-devices-dialog.c | 102 ++++++++++++++++++++++++++++++++++++
app/dialogs/input-devices-dialog.h | 25 +++++++++
app/dialogs/preferences-dialog.c | 68 ++----------------------
app/widgets/gimphelp-ids.h | 1 +
menus/image-menu.xml.in | 1 +
10 files changed, 157 insertions(+), 64 deletions(-)
---
diff --git a/app/actions/dialogs-actions.c b/app/actions/dialogs-actions.c
index 418ee6a..771961b 100644
--- a/app/actions/dialogs-actions.c
+++ b/app/actions/dialogs-actions.c
@@ -213,6 +213,12 @@ static const GimpStringActionEntry dialogs_toplevel_actions[] =
"gimp-preferences-dialog",
GIMP_HELP_PREFS_DIALOG },
+ { "dialogs-input-devices", GIMP_STOCK_DEVICE_STATUS, /* FIXME stock-id */
+ NC_("dialogs-action", "_Input Devices"), NULL,
+ NC_("dialogs-action", "Open the input devices editor"),
+ "gimp-input-devices-dialog",
+ GIMP_HELP_INPUT_DEVICES },
+
{ "dialogs-keyboard-shortcuts", GIMP_STOCK_CHAR_PICKER,
NC_("dialogs-action", "_Keyboard Shortcuts"), NULL,
NC_("dialogs-action", "Open the keyboard shortcuts editor"),
diff --git a/app/dialogs/Makefile.am b/app/dialogs/Makefile.am
index 35a3bfe..3bada42 100644
--- a/app/dialogs/Makefile.am
+++ b/app/dialogs/Makefile.am
@@ -45,6 +45,8 @@ libappdialogs_a_sources = \
image-properties-dialog.h \
image-scale-dialog.c \
image-scale-dialog.h \
+ input-devices-dialog.c \
+ input-devices-dialog.h \
keyboard-shortcuts-dialog.c \
keyboard-shortcuts-dialog.h \
layer-add-mask-dialog.c \
diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c
index 83c321c..a30f3d0 100644
--- a/app/dialogs/dialogs-constructors.c
+++ b/app/dialogs/dialogs-constructors.c
@@ -77,6 +77,7 @@
#include "file-open-location-dialog.h"
#include "file-save-dialog.h"
#include "image-new-dialog.h"
+#include "input-devices-dialog.h"
#include "keyboard-shortcuts-dialog.h"
#include "module-dialog.h"
#include "palette-import-dialog.h"
@@ -162,6 +163,15 @@ dialogs_keyboard_shortcuts_get (GimpDialogFactory *factory,
}
GtkWidget *
+dialogs_input_devices_get (GimpDialogFactory *factory,
+ GimpContext *context,
+ GimpUIManager *ui_manager,
+ gint view_size)
+{
+ return input_devices_dialog_new (context->gimp);
+}
+
+GtkWidget *
dialogs_module_get (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager,
diff --git a/app/dialogs/dialogs-constructors.h b/app/dialogs/dialogs-constructors.h
index 570c4ed..923d62d 100644
--- a/app/dialogs/dialogs-constructors.h
+++ b/app/dialogs/dialogs-constructors.h
@@ -45,6 +45,10 @@ GtkWidget * dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager,
gint view_size);
+GtkWidget * dialogs_input_devices_get (GimpDialogFactory *factory,
+ GimpContext *context,
+ GimpUIManager *ui_manager,
+ gint view_size);
GtkWidget * dialogs_keyboard_shortcuts_get (GimpDialogFactory *factory,
GimpContext *context,
GimpUIManager *ui_manager,
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index 392aeb2..84eafba 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -205,6 +205,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
/* singleton toplevels */
TOPLEVEL ("gimp-preferences-dialog",
dialogs_preferences_get, TRUE, TRUE, FALSE),
+ TOPLEVEL ("gimp-input-devices-dialog",
+ dialogs_input_devices_get, TRUE, TRUE, FALSE),
TOPLEVEL ("gimp-keyboard-shortcuts-dialog",
dialogs_keyboard_shortcuts_get, TRUE, TRUE, TRUE),
TOPLEVEL ("gimp-module-dialog",
diff --git a/app/dialogs/input-devices-dialog.c b/app/dialogs/input-devices-dialog.c
new file mode 100644
index 0000000..16797a4
--- /dev/null
+++ b/app/dialogs/input-devices-dialog.c
@@ -0,0 +1,102 @@
+/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "dialogs-types.h"
+
+#include "core/gimp.h"
+
+#include "widgets/gimpdeviceeditor.h"
+#include "widgets/gimphelp-ids.h"
+
+#include "input-devices-dialog.h"
+
+#include "gimp-intl.h"
+
+
+/* local function prototypes */
+
+static void input_devices_dialog_response (GtkWidget *dialog,
+ guint response_id,
+ Gimp *gimp);
+
+
+/* public functions */
+
+GtkWidget *
+input_devices_dialog_new (Gimp *gimp)
+{
+ GtkWidget *dialog;
+ GtkWidget *content_area;
+ GtkWidget *editor;
+
+ g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+
+ dialog = gimp_dialog_new (_("Configure Input Devices"),
+ "gimp-input-devices-dialog",
+ NULL, 0,
+ gimp_standard_help_func,
+ GIMP_HELP_INPUT_DEVICES,
+
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ GTK_STOCK_SAVE, GTK_RESPONSE_OK,
+
+ NULL);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CLOSE,
+ -1);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (input_devices_dialog_response),
+ gimp);
+
+ content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+ editor = gimp_device_editor_new (gimp);
+ gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
+ gtk_container_add (GTK_CONTAINER (content_area), editor);
+ gtk_widget_show (editor);
+
+ return dialog;
+}
+
+
+/* private functions */
+
+static void
+input_devices_dialog_response (GtkWidget *dialog,
+ guint response_id,
+ Gimp *gimp)
+{
+ switch (response_id)
+ {
+ case GTK_RESPONSE_OK:
+ gimp_devices_save (gimp, TRUE);
+ break;
+
+ default:
+ gtk_widget_destroy (dialog);
+ break;
+ }
+}
diff --git a/app/dialogs/input-devices-dialog.h b/app/dialogs/input-devices-dialog.h
new file mode 100644
index 0000000..8815900
--- /dev/null
+++ b/app/dialogs/input-devices-dialog.h
@@ -0,0 +1,25 @@
+/* GIMP - The GNU 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __INPUT_DEVICES_DIALOG_H__
+#define __INPUT_DEVICES_DIALOG_H__
+
+
+GtkWidget * input_devices_dialog_new (Gimp *gimp);
+
+
+#endif /* __INPUT_DEVICES_DIALOG_H__ */
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index f7e95eb..c062570 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -38,7 +38,6 @@
#include "widgets/gimpcontainercombobox.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpcontrollerlist.h"
-#include "widgets/gimpdeviceeditor.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpgrideditor.h"
@@ -100,8 +99,7 @@ static void prefs_resolution_calibrate_callback (GtkWidget *widget,
GtkWidget *entry);
static void prefs_input_devices_dialog (GtkWidget *widget,
Gimp *gimp);
-static void prefs_input_devices_dialog_response (GtkWidget *dialog,
- gint response_id,
+static void prefs_keyboard_shortcuts_dialog (GtkWidget *widget,
Gimp *gimp);
static void prefs_menus_save_callback (GtkWidget *widget,
Gimp *gimp);
@@ -493,67 +491,9 @@ static void
prefs_input_devices_dialog (GtkWidget *widget,
Gimp *gimp)
{
- static GtkWidget *input_dialog = NULL;
-
- GtkWidget *content_area;
- GtkWidget *editor;
-
- if (input_dialog)
- {
- gtk_window_present (GTK_WINDOW (input_dialog));
- return;
- }
-
- input_dialog = gimp_dialog_new (_("Configure Input Devices"), "preferences",
- NULL, 0,
- NULL, NULL,
-
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- GTK_STOCK_SAVE, GTK_RESPONSE_OK,
-
- NULL);
-
- gtk_dialog_set_alternative_button_order (GTK_DIALOG (input_dialog),
- GTK_RESPONSE_OK,
- GTK_RESPONSE_CLOSE,
- -1);
-
- g_object_add_weak_pointer (G_OBJECT (input_dialog),
- (gpointer) &input_dialog);
-
- gtk_window_set_transient_for (GTK_WINDOW (input_dialog),
- GTK_WINDOW (prefs_dialog));
- gtk_window_set_destroy_with_parent (GTK_WINDOW (input_dialog), TRUE);
-
- g_signal_connect (input_dialog, "response",
- G_CALLBACK (prefs_input_devices_dialog_response),
- gimp);
-
- content_area = gtk_dialog_get_content_area (GTK_DIALOG (input_dialog));
-
- editor = gimp_device_editor_new (gimp);
- gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
- gtk_container_add (GTK_CONTAINER (content_area), editor);
- gtk_widget_show (editor);
-
- gtk_widget_show (input_dialog);
-}
-
-static void
-prefs_input_devices_dialog_response (GtkWidget *dialog,
- gint response_id,
- Gimp *gimp)
-{
- switch (response_id)
- {
- case GTK_RESPONSE_OK:
- gimp_devices_save (gimp, TRUE);
- break;
-
- default:
- gtk_widget_destroy (dialog);
- break;
- }
+ gimp_dialog_factory_dialog_raise (gimp_dialog_factory_from_name ("toplevel"),
+ gtk_widget_get_screen (widget),
+ "gimp-input-devices-dialog", 0);
}
static void
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 2cf2801..8f49f7e 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -449,6 +449,7 @@
#define GIMP_HELP_PREFS_FOLDERS_ENVIRONMENT "gimp-prefs-folders-environment"
#define GIMP_HELP_PREFS_FOLDERS_THEMES "gimp-prefs-folders-themes"
+#define GIMP_HELP_INPUT_DEVICES "gimp-help-input-devices"
#define GIMP_HELP_KEYBOARD_SHORTCUTS "gimp-help-keyboard-shortcuts"
#define GIMP_HELP_INDEXED_PALETTE_DIALOG "gimp-indexed-palette-dialog"
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index c4ff6d8..628e60c 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -219,6 +219,7 @@
<separator />
<placeholder name="Preferences">
<menuitem action="dialogs-preferences" />
+ <menuitem action="dialogs-input-devices" />
<menuitem action="dialogs-keyboard-shortcuts" />
<menuitem action="dialogs-module-dialog"/>
</placeholder>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]