1 #define __SP_WINDOW_C__
3 /*
4 * Generic window implementation
5 *
6 * Author:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 *
9 * This code is in public domain
10 */
12 #ifdef HAVE_CONFIG_H
13 # include <config.h>
14 #endif
15 #include <gtk/gtkwindow.h>
16 #include <gtkmm/window.h>
18 #include "inkscape.h"
19 #include "shortcuts.h"
20 #include "desktop.h"
21 #include "event-context.h"
22 #include "window.h"
24 static bool on_window_key_press(GdkEventKey* event)
25 {
26 unsigned int shortcut;
27 shortcut = get_group0_keyval (event) |
28 ( event->state & GDK_SHIFT_MASK ?
29 SP_SHORTCUT_SHIFT_MASK : 0 ) |
30 ( event->state & GDK_CONTROL_MASK ?
31 SP_SHORTCUT_CONTROL_MASK : 0 ) |
32 ( event->state & GDK_MOD1_MASK ?
33 SP_SHORTCUT_ALT_MASK : 0 );
34 return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
35 }
37 Gtk::Window *
38 Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
39 {
40 Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
41 window->set_title (title);
42 window->set_resizable (resizeable);
43 window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
45 return window;
46 }
48 static gboolean
49 sp_window_key_press(GtkWidget */*widget*/, GdkEventKey *event)
50 {
51 return on_window_key_press(event);
52 }
54 GtkWidget *
55 sp_window_new (const gchar *title, unsigned int resizeable)
56 {
57 GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
58 gtk_window_set_title ((GtkWindow *) window, title);
59 gtk_window_set_resizable ((GtkWindow *) window, resizeable);
60 g_signal_connect_after ((GObject *) window, "key_press_event", (GCallback) sp_window_key_press, NULL);
62 return window;
63 }