summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 348f08f)
raw | patch | inline | side by side (parent: 348f08f)
author | joelholdsworth <joelholdsworth@users.sourceforge.net> | |
Sat, 28 Jul 2007 12:32:01 +0000 (12:32 +0000) | ||
committer | joelholdsworth <joelholdsworth@users.sourceforge.net> | |
Sat, 28 Jul 2007 12:32:01 +0000 (12:32 +0000) |
15 files changed:
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 859e15bd830280b45628042f99930dc393721f63..4cfc279ccc6933c3b1acd0adc66f17985111be69 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
_widget->setTransient (p, transient_policy);
}
-void SPDesktop::getToplevel( GtkWidget*& toplevel )
+void SPDesktop::getToplevel( Gtk::Widget*& toplevel )
{
- toplevel = GTK_WIDGET( _widget->getWindow() );
+ toplevel = (Gtk::Widget*)_widget->getWindow();
}
void
return _widget->shutdown();
}
+bool SPDesktop::onDeleteUI (GdkEventAny*)
+{
+ if(shutdown()) return true;
+ destroyWidget();
+ return false;
+}
+
+/**
+ * onWindowStateEvent
+ *
+ * Called when the window changes its maximize/fullscreen/iconify/pinned state.
+ * Since GTK doesn't have a way to query this state information directly, we
+ * record it for the desktop here, and also possibly trigger a layout.
+ */
+bool
+SPDesktop::onWindowStateEvent (GdkEventWindowState* event)
+{
+ // Record the desktop window's state
+ window_state = event->new_window_state;
+
+ // Layout may differ depending on full-screen mode or not
+ GdkWindowState changed = event->changed_mask;
+ if (changed & (GDK_WINDOW_STATE_FULLSCREEN|GDK_WINDOW_STATE_MAXIMIZED)) {
+ layoutWidget();
+ }
+
+ return false;
+}
+
void
SPDesktop::setToolboxFocusTo (gchar const *label)
{
diff --git a/src/desktop.h b/src/desktop.h
index 4c255ecbbb140f9c935c43ec9afe5e423e7534ff..3bf6fa65a99e5f6ee373fd1c520b2f3c50cdc3c7 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
#include "config.h"
#endif
+#include <gdk/gdkevents.h>
#include <gtk/gtktypeutils.h>
#include <sigc++/sigc++.h>
+
#include "libnr/nr-matrix.h"
#include "libnr/nr-matrix-fns.h"
#include "libnr/nr-rect.h"
struct SPStyle;
struct SPViewWidget;
+namespace Gtk
+{
+ class Widget;
+}
+
typedef int sp_verb_t;
+
+
namespace Inkscape {
class Application;
class MessageContext;
void setWindowPosition (NR::Point p);
void setWindowSize (gint w, gint h);
void setWindowTransient (void* p, int transient_policy=1);
- void getToplevel( GtkWidget*& toplevel );
+ void getToplevel( Gtk::Widget*& toplevel );
void presentWindow();
bool warnDialog (gchar *text);
void toggleRulers();
virtual void mouseover() {}
virtual void mouseout() {}
+ virtual bool onDeleteUI (GdkEventAny*);
+ virtual bool onWindowStateEvent (GdkEventWindowState* event);
+
private:
Inkscape::UI::View::EditWidgetInterface *_widget;
Inkscape::Application *_inkscape;
diff --git a/src/file.cpp b/src/file.cpp
index 69d6da610383ec34533bebb3554e9cb750a4e546..436cd0ee008a400045d1a1ca2a1744c0d1b0a480 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
* Can select single or multiple files for opening.
*/
void
-sp_file_open_dialog(gpointer object, gpointer data)
+sp_file_open_dialog(Gtk::Window &parentWindow, gpointer object, gpointer data)
{
//# Get the current directory for finding files
if (!openDialogInstance) {
openDialogInstance =
Inkscape::UI::Dialog::FileOpenDialog::create(
+ parentWindow,
open_path,
Inkscape::UI::Dialog::SVG_TYPES,
(char const *)_("Select file to open"));
* document; is true for normal save, false for temporary saves
*/
static bool
-file_save(SPDocument *doc, const Glib::ustring &uri,
+file_save(Gtk::Window &parentWindow, SPDocument *doc, const Glib::ustring &uri,
Inkscape::Extension::Extension *key, bool saveas, bool official)
{
if (!doc || uri.size()<1) //Safety check
g_free(safeUri);
return FALSE;
} catch (Inkscape::Extension::Output::no_overwrite &e) {
- return sp_file_save_dialog(doc);
+ return sp_file_save_dialog(parentWindow, doc);
}
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Document saved."));
* \param ascopy (optional) wether to set the documents->uri to the new filename or not
*/
bool
-sp_file_save_dialog(SPDocument *doc, bool is_copy)
+sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, bool is_copy)
{
Inkscape::XML::Node *repr = sp_document_repr_root(doc);
}
Inkscape::UI::Dialog::FileSaveDialog *saveDialog =
Inkscape::UI::Dialog::FileSaveDialog::create(
+ parentWindow,
save_loc,
Inkscape::UI::Dialog::SVG_TYPES,
(char const *) _("Select file to save to"),
Inkscape::Extension::Extension *selectionType = saveDialog->getSelectionType();
delete saveDialog;
+
saveDialog = 0;
if (fileName.size() > 0) {
else
g_warning( "Error converting save filename to UTF-8." );
- success = file_save(doc, fileName, selectionType, TRUE, !is_copy);
+ success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy);
if (success)
prefs_set_recent_file(SP_DOCUMENT_URI(doc), SP_DOCUMENT_NAME(doc));
* Save a document, displaying a SaveAs dialog if necessary.
*/
bool
-sp_file_save_document(SPDocument *doc)
+sp_file_save_document(Gtk::Window &parentWindow, SPDocument *doc)
{
bool success = true;
if ( doc->uri == NULL
|| repr->attribute("inkscape:output_extension") == NULL )
{
- return sp_file_save_dialog(doc, FALSE);
+ return sp_file_save_dialog(parentWindow, doc, FALSE);
} else {
fn = g_strdup(doc->uri);
gchar const *ext = repr->attribute("inkscape:output_extension");
- success = file_save(doc, fn, Inkscape::Extension::db.get(ext), FALSE, TRUE);
+ success = file_save(parentWindow, doc, fn, Inkscape::Extension::db.get(ext), FALSE, TRUE);
g_free((void *) fn);
}
} else {
* Save a document.
*/
bool
-sp_file_save(gpointer object, gpointer data)
+sp_file_save(Gtk::Window &parentWindow, gpointer object, gpointer data)
{
if (!SP_ACTIVE_DOCUMENT)
return false;
SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Saving document..."));
sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
- return sp_file_save_document(SP_ACTIVE_DOCUMENT);
+ return sp_file_save_document(parentWindow, SP_ACTIVE_DOCUMENT);
}
* Save a document, always displaying the SaveAs dialog.
*/
bool
-sp_file_save_as(gpointer object, gpointer data)
+sp_file_save_as(Gtk::Window &parentWindow, gpointer object, gpointer data)
{
if (!SP_ACTIVE_DOCUMENT)
return false;
sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
- return sp_file_save_dialog(SP_ACTIVE_DOCUMENT, FALSE);
+ return sp_file_save_dialog(parentWindow, SP_ACTIVE_DOCUMENT, FALSE);
}
* Save a copy of a document, always displaying a sort of SaveAs dialog.
*/
bool
-sp_file_save_a_copy(gpointer object, gpointer data)
+sp_file_save_a_copy(Gtk::Window &parentWindow, gpointer object, gpointer data)
{
if (!SP_ACTIVE_DOCUMENT)
return false;
sp_namedview_document_from_window(SP_ACTIVE_DESKTOP);
- return sp_file_save_dialog(SP_ACTIVE_DOCUMENT, TRUE);
+ return sp_file_save_dialog(parentWindow, SP_ACTIVE_DOCUMENT, TRUE);
}
* Display an Open dialog, import a resource if OK pressed.
*/
void
-sp_file_import(GtkWidget *widget)
+sp_file_import(Gtk::Window &parentWindow)
{
static Glib::ustring import_path;
if (!importDialogInstance) {
importDialogInstance =
Inkscape::UI::Dialog::FileOpenDialog::create(
- import_path,
+ parentWindow,
+ import_path,
Inkscape::UI::Dialog::IMPORT_TYPES,
(char const *)_("Select file to import"));
}
diff --git a/src/file.h b/src/file.h
index 18e4068a1535819cee2562e1acce68ce31c68cdd..9bff1ca122d4d1ef91fb01ad7aee64fb35620def 100644 (file)
--- a/src/file.h
+++ b/src/file.h
* Displays a file open dialog. Calls sp_file_open on
* an OK.
*/
-void sp_file_open_dialog (gpointer object, gpointer data);
+void sp_file_open_dialog (Gtk::Window &parentWindow, gpointer object, gpointer data);
/**
* Reverts file to disk-copy on "YES"
/**
*
*/
-bool sp_file_save (gpointer object, gpointer data);
+bool sp_file_save (Gtk::Window &parentWindow, gpointer object, gpointer data);
/**
* Saves the given document. Displays a file select dialog
* to choose the new name.
*/
-bool sp_file_save_as (gpointer object, gpointer data);
+bool sp_file_save_as (Gtk::Window &parentWindow, gpointer object, gpointer data);
/**
* Saves a copy of the given document. Displays a file select dialog
* to choose a name for the copy.
*/
-bool sp_file_save_a_copy (gpointer object, gpointer data);
+bool sp_file_save_a_copy (Gtk::Window &parentWindow, gpointer object, gpointer data);
/**
* Saves the given document. Displays a file select dialog
* if needed.
*/
-bool sp_file_save_document (SPDocument *document);
+bool sp_file_save_document (Gtk::Window &parentWindow, SPDocument *document);
/* Do the saveas dialog with a document as the parameter */
-bool sp_file_save_dialog (SPDocument *doc, bool bAsCopy = FALSE);
+bool sp_file_save_dialog (Gtk::Window &parentWindow, SPDocument *doc, bool bAsCopy = FALSE);
/*######################
* Displays a file selector dialog, to allow the
* user to import data into the current document.
*/
-void sp_file_import (GtkWidget * widget);
+void sp_file_import (Gtk::Window &parentWindow);
/**
* Imports a resource
diff --git a/src/helper/window.cpp b/src/helper/window.cpp
index 346bd19f16d617226f2354edede9bc8eea424337..6f898ee3e084c6c5a31efc9e23b5f5071a92afb4 100644 (file)
--- a/src/helper/window.cpp
+++ b/src/helper/window.cpp
# include <config.h>
#endif
#include <gtk/gtkwindow.h>
+#include <gtkmm/window.h>
#include "inkscape.h"
#include "shortcuts.h"
#include "desktop.h"
#include "event-context.h"
+#include "window.h"
-static gboolean
-sp_window_key_press (GtkWidget *widget, GdkEventKey *event)
+static bool on_window_key_press(GdkEventKey* event)
{
unsigned int shortcut;
shortcut = get_group0_keyval (event) |
return sp_shortcut_invoke (shortcut, SP_ACTIVE_DESKTOP);
}
+Gtk::Window *
+Inkscape::UI::window_new (const gchar *title, unsigned int resizeable)
+{
+ Gtk::Window *window = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
+ window->set_title (title);
+ window->set_resizable (resizeable);
+ window->signal_key_press_event().connect(sigc::ptr_fun(&on_window_key_press));
+
+ return window;
+}
+
+static gboolean
+sp_window_key_press (GtkWidget *widget, GdkEventKey *event)
+{
+ return on_window_key_press(event);
+}
+
GtkWidget *
sp_window_new (const gchar *title, unsigned int resizeable)
{
return window;
}
-
diff --git a/src/helper/window.h b/src/helper/window.h
index 764cb041315179e1dd91883fb06a277bcb8030e3..7f06fe42392f3277ff3bf63e41fc5c88713e9a93 100644 (file)
--- a/src/helper/window.h
+++ b/src/helper/window.h
*/
#include <gtk/gtkwidget.h>
+#include <gtkmm/window.h>
+/*
+ * This function is depreciated. Use Inkscape::UI::window_new instead.
+ */
GtkWidget *sp_window_new (const gchar *title, unsigned int resizeable);
+namespace Inkscape {
+namespace UI {
+
+Gtk::Window *window_new (const gchar *title, unsigned int resizeable);
+
+}
+}
+
#endif
/*
diff --git a/src/interface.cpp b/src/interface.cpp
index f43c31d301b9725cf955a76176bce70002f68afe..eada69c34ffdd5bb59f1162c036b68dd70f470cf 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
#include "widgets/desktop-widget.h"
#include "sp-item-group.h"
#include "sp-namedview.h"
+#include "ui/view/view.h"
#include "helper/action.h"
#include "helper/gnome-utils.h"
#include "desktop-style.h"
#include "style.h"
-
using Inkscape::IO::StringOutputStream;
using Inkscape::IO::Base64OutputStream;
-/* forward declaration */
-static gint sp_ui_delete(GtkWidget *widget, GdkEvent *event, Inkscape::UI::View::View *view);
-static void sp_ui_state_event(GtkWidget *widget, GdkEventWindowState *event, SPDesktop*desktop);
-
-
/* Drag and Drop */
typedef enum {
URI_LIST,
g_return_if_fail(vw != NULL);
g_return_if_fail(SP_IS_VIEW_WIDGET(vw));
- GtkWidget *win = sp_window_new("", TRUE);
-
- if (editable) {
- g_object_set_data(G_OBJECT(vw), "window", win);
- reinterpret_cast<SPDesktopWidget*>(vw)->window =
- static_cast<GtkWindow*>((void*)win);
- }
+ Gtk::Window *win = Inkscape::UI::window_new("", TRUE);
if (editable) {
- SPDesktop* desktop = SP_DESKTOP_WIDGET(vw)->desktop;
+ g_object_set_data(G_OBJECT(vw), "window", win);
+
+ SPDesktopWidget *desktop_widget = reinterpret_cast<SPDesktopWidget*>(vw);
+ SPDesktop* desktop = desktop_widget->desktop;
+
+ desktop_widget->window = win;
/* fixme: doesn't allow making window any smaller than this */
- gtk_window_set_default_size((GtkWindow *) win, 640, 480);
- g_object_set_data(G_OBJECT(win), "desktop", desktop);
- g_object_set_data(G_OBJECT(win), "desktopwidget", vw);
- g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(sp_ui_delete), vw->view);
-
- g_signal_connect(G_OBJECT(win), "window_state_event", G_CALLBACK(sp_ui_state_event), static_cast<SPDesktop*>(vw->view));
- g_signal_connect(G_OBJECT(win), "focus_in_event", G_CALLBACK(sp_desktop_widget_set_focus), vw);
-
+ win->set_default_size(640, 480);
+
+ win->set_data("desktop", desktop);
+ win->set_data("desktopwidget", desktop_widget);
+
+ win->signal_delete_event().connect(sigc::mem_fun(*(SPDesktop*)vw->view, &SPDesktop::onDeleteUI));
+ win->signal_window_state_event().connect(sigc::mem_fun(*desktop, &SPDesktop::onWindowStateEvent));
+ win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent));
+
gint prefs_geometry =
(2==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
if (prefs_geometry) {
}
}
if (maxed) {
- gtk_window_maximize(GTK_WINDOW(win));
+ win->maximize();
}
if (full) {
- gtk_window_fullscreen(GTK_WINDOW(win));
+ win->fullscreen();
}
}
} else {
- gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE);
+ gtk_window_set_policy(GTK_WINDOW(win->gobj()), TRUE, TRUE, TRUE);
}
- gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vw));
+ gtk_container_add(GTK_CONTAINER(win->gobj()), GTK_WIDGET(vw));
gtk_widget_show(GTK_WIDGET(vw));
if ( completeDropTargets == 0 || completeDropTargetsCount == 0 )
}
}
- gtk_drag_dest_set(win,
+ gtk_drag_dest_set((GtkWidget*)win->gobj(),
GTK_DEST_DEFAULT_ALL,
completeDropTargets,
completeDropTargetsCount,
GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
- g_signal_connect(G_OBJECT(win),
+ g_signal_connect(G_OBJECT(win->gobj()),
"drag_data_received",
G_CALLBACK(sp_ui_drag_data_received),
NULL);
- gtk_widget_show(win);
+ win->show();
// needed because the first ACTIVATE_DESKTOP was sent when there was no window yet
inkscape_reactivate_desktop(SP_DESKTOP_WIDGET(vw)->desktop);
return TRUE;
}
-static gint
-sp_ui_delete(GtkWidget *widget, GdkEvent *event, Inkscape::UI::View::View *view)
-{
- return view->shutdown();
-}
-
-/**
- * sp_ui_state_event
- *
- * Called when the window changes its maximize/fullscreen/iconify/pinned state.
- * Since GTK doesn't have a way to query this state information directly, we
- * record it for the desktop here, and also possibly trigger a layout.
- */
-static void
-sp_ui_state_event(GtkWidget *widget, GdkEventWindowState *event, SPDesktop* desktop)
-{
- // Record the desktop window's state
- desktop->window_state = event->new_window_state;
-
- // Layout may differ depending on full-screen mode or not
- GdkWindowState changed = event->changed_mask;
- if (changed & (GDK_WINDOW_STATE_FULLSCREEN|GDK_WINDOW_STATE_MAXIMIZED)) {
- desktop->layoutWidget();
- }
-/*
- // debug info
- g_message("State event desktop=0x%p", desktop);
- GdkWindowState state = event->new_window_state;
- GdkWindowState changed = event->changed_mask;
- if (changed & GDK_WINDOW_STATE_WITHDRAWN) {
- g_message("-- WIDTHDRAWN = %d", 0!=(state&GDK_WINDOW_STATE_WITHDRAWN));
- }
- if (changed & GDK_WINDOW_STATE_ICONIFIED) {
- g_message("-- ICONIFIED = %d", 0!=(state&GDK_WINDOW_STATE_ICONIFIED));
- }
- if (changed & GDK_WINDOW_STATE_MAXIMIZED) {
- g_message("-- MAXIMIZED = %d", 0!=(state&GDK_WINDOW_STATE_MAXIMIZED));
- }
- if (changed & GDK_WINDOW_STATE_STICKY) {
- g_message("-- STICKY = %d", 0!=(state&GDK_WINDOW_STATE_STICKY));
- }
- if (changed & GDK_WINDOW_STATE_FULLSCREEN) {
- g_message("-- FULLSCREEN = %d", 0!=(state&GDK_WINDOW_STATE_FULLSCREEN));
- }
- if (changed & GDK_WINDOW_STATE_ABOVE) {
- g_message("-- ABOVE = %d", 0!=(state&GDK_WINDOW_STATE_ABOVE));
- }
- if (changed & GDK_WINDOW_STATE_BELOW) {
- g_message("-- BELOW = %d", 0!=(state&GDK_WINDOW_STATE_BELOW));
- }
-*/
-}
-
/*
* Some day when the right-click menus are ready to start working
* smarter with the verbs, we'll need to change this NULL being
bool return_value = FALSE;
if (Inkscape::IO::file_test(filename, G_FILE_TEST_EXISTS)) {
- GtkWidget* ancestor = 0;
+ Gtk::Widget* ancestor = NULL;
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if ( desktop ) {
desktop->getToplevel( ancestor );
}
- GtkWindow *window = GTK_WIDGET_TOPLEVEL(ancestor) ? GTK_WINDOW( ancestor ) : 0;
+ Gtk::Window *window = ancestor->is_toplevel() ?
+ dynamic_cast<Gtk::Window*>( ancestor ) : 0;
gchar* baseName = g_path_get_basename( filename );
gchar* dirName = g_path_get_dirname( filename );
- GtkWidget* dialog = gtk_message_dialog_new_with_markup( window,
+ GtkWidget* dialog = gtk_message_dialog_new_with_markup( window->gobj(),
(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
index 08c0d411615c801106332b5a31816862a84cb491..4336b1f8b57b601b1088a1b3e4d493d47dcb5fa0 100644 (file)
/**
*
*/
- FileDialogBase(const Glib::ustring &title, FileDialogType type, gchar const* preferenceBase) :
- Gtk::FileChooserDialog(title),
+ FileDialogBase(Gtk::Window& parentWindow, const Glib::ustring &title,
+ FileDialogType type, gchar const* preferenceBase) :
+ Gtk::FileChooserDialog(parentWindow, title),
preferenceBase(preferenceBase ? preferenceBase : "unknown"),
dialogType(type)
{
/**
*
*/
- FileDialogBase(const Glib::ustring &title,
+ FileDialogBase(Gtk::Window& parentWindow, const Glib::ustring &title,
Gtk::FileChooserAction dialogType, FileDialogType type, gchar const* preferenceBase) :
- Gtk::FileChooserDialog(title, dialogType),
+ Gtk::FileChooserDialog(parentWindow, title, dialogType),
preferenceBase(preferenceBase ? preferenceBase : "unknown"),
dialogType(type)
{
{
public:
- FileOpenDialogImpl(const Glib::ustring &dir,
+ FileOpenDialogImpl(Gtk::Window& parentWindow,
+ const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title);
/**
* Constructor. Not called directly. Use the factory.
*/
-FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir,
+FileOpenDialogImpl::FileOpenDialogImpl(Gtk::Window& parentWindow,
+ const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title) :
- FileDialogBase(title, fileTypes, "dialogs.open")
+ FileDialogBase(parentWindow, title, fileTypes, "dialogs.open")
{
/**
* Public factory. Called by file.cpp, among others.
*/
-FileOpenDialog *FileOpenDialog::create(const Glib::ustring &path,
+FileOpenDialog *FileOpenDialog::create(Gtk::Window &parentWindow,
+ const Glib::ustring &path,
FileDialogType fileTypes,
const Glib::ustring &title)
{
- FileOpenDialog *dialog = new FileOpenDialogImpl(path, fileTypes, title);
+ FileOpenDialog *dialog = new FileOpenDialogImpl(parentWindow, path, fileTypes, title);
return dialog;
}
{
public:
- FileSaveDialogImpl(const Glib::ustring &dir,
+ FileSaveDialogImpl(Gtk::Window &parentWindow,
+ const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key);
/**
* Constructor
*/
-FileSaveDialogImpl::FileSaveDialogImpl(const Glib::ustring &dir,
+FileSaveDialogImpl::FileSaveDialogImpl(Gtk::Window &parentWindow,
+ const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key) :
- FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
+ FileDialogBase(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
{
/* One file at a time */
set_select_multiple(false);
/**
* Public factory method. Used in file.cpp
*/
-FileSaveDialog *FileSaveDialog::create(const Glib::ustring &path,
+FileSaveDialog *FileSaveDialog::create(Gtk::Window& parentWindow,
+ const Glib::ustring &path,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key)
{
- FileSaveDialog *dialog = new FileSaveDialogImpl(path, fileTypes, title, default_key);
+ FileSaveDialog *dialog = new FileSaveDialogImpl(parentWindow, path, fileTypes, title, default_key);
return dialog;
}
{
public:
- FileExportDialogImpl(const Glib::ustring &dir,
- FileDialogType fileTypes,
- const Glib::ustring &title,
- const Glib::ustring &default_key);
+ FileExportDialogImpl(Gtk::Window& parentWindow,
+ const Glib::ustring &dir,
+ FileDialogType fileTypes,
+ const Glib::ustring &title,
+ const Glib::ustring &default_key);
virtual ~FileExportDialogImpl();
/**
* Constructor
*/
-FileExportDialogImpl::FileExportDialogImpl(const Glib::ustring &dir,
+FileExportDialogImpl::FileExportDialogImpl(Gtk::Window& parentWindow,
+ const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key) :
- FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
+ FileDialogBase(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
sourceX0Spinner("X0", _("Left edge of source")),
sourceY0Spinner("Y0", _("Top edge of source")),
sourceX1Spinner("X1", _("Right edge of source")),
/**
* Public factory method. Used in file.cpp
*/
-FileExportDialog *FileExportDialog::create(const Glib::ustring &path,
- FileDialogType fileTypes,
- const Glib::ustring &title,
- const Glib::ustring &default_key)
+FileExportDialog *FileExportDialog::create(Gtk::Window& parentWindow,
+ const Glib::ustring &path,
+ FileDialogType fileTypes,
+ const Glib::ustring &title,
+ const Glib::ustring &default_key)
{
- FileExportDialog *dialog = new FileExportDialogImpl(path, fileTypes, title, default_key);
+ FileExportDialog *dialog = new FileExportDialogImpl(parentWindow, path, fileTypes, title, default_key);
return dialog;
}
index c573dbe5dd337886faed11afd13091685f08cd0b..5499603d3926a5481108a34cd907cb39a6f6606c 100644 (file)
* @param fileTypes one of FileDialogTypes
* @param title the title of the dialog
*/
- static FileOpenDialog *create(const Glib::ustring &path,
+ static FileOpenDialog *create(Gtk::Window& parentWindow,
+ const Glib::ustring &path,
FileDialogType fileTypes,
const Glib::ustring &title);
* @param title the title of the dialog
* @param key a list of file types from which the user can select
*/
- static FileSaveDialog *create(const Glib::ustring &path,
+ static FileSaveDialog *create(Gtk::Window& parentWindow,
+ const Glib::ustring &path,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key);
* @param title the title of the dialog
* @param key a list of file types from which the user can select
*/
- static FileExportDialog *create(const Glib::ustring &path,
+ static FileExportDialog *create(Gtk::Window& parentWindow,
+ const Glib::ustring &path,
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key);
index 1df0bff457be70159b44ee9c38841ade52a8d6b0..4c9ad8b023da31d6233c581a921921e6e02b6fad 100644 (file)
#ifndef INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H
#define INKSCAPE_UI_VIEW_EDIT_WIDGET_IFACE_H
-#include "gdk/gdktypes.h"
#include "libnr/nr-point.h"
#include "message.h"
+#include <gtkmm/window.h>
+
namespace Inkscape {
namespace UI {
namespace View {
virtual ~EditWidgetInterface() {}
/// Returns pointer to window UI object as void*
- virtual void *getWindow() = 0;
+ virtual Gtk::Window *getWindow() = 0;
/// Set the widget's title
virtual void setTitle (gchar const*) = 0;
index 8e423c8fbf140b5ada637cd6c30e068ada4ea29c..d5b7828653c56337c3c8988cc93fee41c7ed2760 100644 (file)
EditWidget::onActionFileOpen()
{
// g_warning("onActionFileOpen called");
- sp_file_open_dialog (NULL, NULL);
+ sp_file_open_dialog (*this, NULL, NULL);
}
void
//========================================
//----------implements EditWidgetInterface
-void *
+Gtk::Window *
EditWidget::getWindow()
{
return this;
{
case Gtk::RESPONSE_YES:
sp_document_ref(doc);
- if (sp_file_save_document(doc)) {
+ if (sp_file_save_document(*this, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
{
case Gtk::RESPONSE_YES:
sp_document_ref(doc);
- if (sp_file_save_document(doc)) {
+ if (sp_file_save_document(*this, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
index bedb94f9804a3504bedd13c17b770fad55320f2f..7f68abcf58d801037b591288ebed58ffd09a1a4a 100644 (file)
void onUriChanged();
// from EditWidgetInterface
- virtual void *getWindow();
+ virtual Gtk::Window* getWindow();
virtual void setTitle (gchar const*);
virtual void layout();
virtual void present();
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 5a05407762a7d4f3e8f262f4fad141c44345a07c..a81157ab87cb979b257f16ece7fae78e8df87e15 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
Inkscape::UI::View::View *current_view = sp_action_get_view(action);
SPDocument *current_document = current_view->doc();
#endif
+
+ SPDesktop *desktop = dynamic_cast<SPDesktop*>(sp_action_get_view(action));
+ Gtk::Window *parent = NULL;
+ if(desktop == NULL) return;
+ desktop->getToplevel((Gtk::Widget*&)parent);
+ if(parent == NULL) return;
+
switch ((long) data) {
case SP_VERB_FILE_NEW:
sp_file_new_default();
break;
case SP_VERB_FILE_OPEN:
- sp_file_open_dialog(NULL, NULL);
+ sp_file_open_dialog(*parent, NULL, NULL);
break;
case SP_VERB_FILE_REVERT:
sp_file_revert_dialog();
break;
case SP_VERB_FILE_SAVE:
- sp_file_save(NULL, NULL);
+ sp_file_save(*parent, NULL, NULL);
break;
case SP_VERB_FILE_SAVE_AS:
- sp_file_save_as(NULL, NULL);
+ sp_file_save_as(*parent, NULL, NULL);
break;
case SP_VERB_FILE_SAVE_A_COPY:
- sp_file_save_a_copy(NULL, NULL);
+ sp_file_save_a_copy(*parent, NULL, NULL);
break;
case SP_VERB_FILE_PRINT:
sp_file_print();
sp_file_print_preview(NULL, NULL);
break;
case SP_VERB_FILE_IMPORT:
- sp_file_import(NULL);
+ sp_file_import(*parent);
break;
case SP_VERB_FILE_EXPORT:
sp_file_export_dialog(NULL);
default:
break;
}
+
} // end of sp_verb_action_file_perform()
index 9716191ed6b65b61c665ab42bb8bad6bd1bac269..4dca563aa83d670fc362f5b5f4225e055c71a81b 100644 (file)
void
SPDesktopWidget::updateTitle(gchar const* uri)
{
- GtkWindow *window = GTK_WINDOW (gtk_object_get_data (GTK_OBJECT(this), "window"));
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
if (window) {
gchar const *fname = ( TRUE
? uri
g_string_printf (name, _("%s - Inkscape"), fname);
}
}
- gtk_window_set_title (window, name->str);
+ window->set_title (name->str);
g_string_free (name, TRUE);
}
}
switch (response) {
case GTK_RESPONSE_YES:
- sp_document_ref(doc);
- if (sp_file_save_document(doc)) {
+ {
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
+ sp_document_ref(doc);
+ if (sp_file_save_document(*window, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
return TRUE;
}
+
break;
+ }
case GTK_RESPONSE_NO:
break;
default: // cancel pressed, or dialog was closed
switch (response) {
case GTK_RESPONSE_YES:
- sp_document_ref(doc);
- if (sp_file_save_dialog(doc)) {
+ {
+ sp_document_ref(doc);
+
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
+ if (sp_file_save_dialog(*window, doc)) {
sp_document_unref(doc);
} else { // save dialog cancelled or save failed
sp_document_unref(doc);
return TRUE;
}
+
break;
+ }
case GTK_RESPONSE_NO:
allow_data_loss = TRUE;
break;
{
gboolean vis = GTK_WIDGET_VISIBLE (this);
- GtkWindow *window = GTK_WINDOW (gtk_object_get_data (GTK_OBJECT(this), "window"));
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
if (window)
{
- gtk_window_get_size (window, &w, &h);
- gtk_window_get_position (window, &x, &y);
+ window->get_size (w, h);
+ window->get_position (x, y);
}
}
void
SPDesktopWidget::setWindowPosition (NR::Point p)
{
- GtkWindow *window = GTK_WINDOW (gtk_object_get_data (GTK_OBJECT(this), "window"));
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
if (window)
{
- gtk_window_move (window, gint(round(p[NR::X])), gint(round(p[NR::Y])));
+ window->move (gint(round(p[NR::X])), gint(round(p[NR::Y])));
}
}
void
SPDesktopWidget::setWindowSize (gint w, gint h)
{
- GtkWindow *window = GTK_WINDOW (gtk_object_get_data (GTK_OBJECT(this), "window"));
+ Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
+
if (window)
{
- gtk_window_set_default_size (window, w, h);
- gtk_window_reshow_with_initial_size (window);
+ window->set_default_size (w, h);
+ window->reshow_with_initial_size ();
}
}
@@ -1131,16 +1146,14 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment *adj, SPDesktopWidget
}
/* we make the desktop window with focus active, signal is connected in interface.c */
-
-gint
-sp_desktop_widget_set_focus (GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
+bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
{
- inkscape_activate_desktop (dtw->desktop);
+ inkscape_activate_desktop (desktop);
/* give focus to canvas widget */
- gtk_widget_grab_focus (GTK_WIDGET (dtw->canvas));
-
- return FALSE;
+ gtk_widget_grab_focus (GTK_WIDGET (canvas));
+
+ return false;
}
static gdouble
index ef70a21d1a2a81070225bd59f7523a6c9103de46..fbd350b12f5e6e12148ceb388471008e963b71c7 100644 (file)
void sp_desktop_widget_destroy (SPDesktopWidget* dtw);
-gint sp_desktop_widget_set_focus(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw);
-
void sp_desktop_widget_show_decorations(SPDesktopWidget *dtw, gboolean show);
void sp_desktop_widget_iconify(SPDesktopWidget *dtw);
void sp_desktop_widget_maximize(SPDesktopWidget *dtw);
SPDesktop *desktop;
- GtkWindow *window;
+ Gtk::Window *window;
// The root vbox of the window layout.
GtkWidget *vbox;
virtual void setTitle (gchar const *uri)
{ _dtw->updateTitle (uri); }
- virtual void* getWindow()
+ virtual Gtk::Window* getWindow()
{ return _dtw->window; }
virtual void layout()
{ sp_desktop_widget_layout (_dtw); }
virtual bool shutdown()
{ return _dtw->shutdown(); }
virtual void destroy()
- { gtk_widget_destroy (static_cast<GtkWidget*>((void*)(_dtw->window)));}
+ {
+ if(_dtw->window != NULL)
+ delete _dtw->window;
+ _dtw->window = NULL;
+ }
virtual void requestCanvasUpdate()
{ _dtw->requestCanvasUpdate(); }
void enableInteraction();
void disableInteraction();
void updateTitle(gchar const *uri);
+
+ bool onFocusInEvent(GdkEventFocus*);
};
/// The SPDesktopWidget vtable