Commit d967852c authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

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.
parent a8a732f7
......@@ -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"),
......
......@@ -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 \
......
......@@ -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"
......@@ -161,6 +162,15 @@ dialogs_keyboard_shortcuts_get (GimpDialogFactory *factory,
return keyboard_shortcuts_dialog_new (context->gimp);
}
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,
......
......@@ -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,
......
......@@ -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",
......
/* 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;
}
}
/* 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__ */
......@@ -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
......
......@@ -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"
......
......@@ -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>
......
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