interface.cpp revision e6e8713c2de5853516c287e78b41d2ab5459457c
f69d245bb21be88752420e834a6b6be37e9b525fTripp * Main UI stuff.
f69d245bb21be88752420e834a6b6be37e9b525fTripp * Lauris Kaplinski <lauris@kaplinski.com>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Frank Felfe <innerspace@iname.com>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * bulia byak <buliabyak@users.sf.net>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Jon A. Cruz <jon@joncruz.org>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Abhishek Sharma
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Copyright (C) 2010 authors
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Copyright (C) 1999-2005 authors
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Copyright (C) 2001-2002 Ximian, Inc.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Copyright (C) 2004 David Turner
f69d245bb21be88752420e834a6b6be37e9b525fTripp * Released under GNU GPL, read the file 'COPYING' for more information
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp/* Drag and Drop */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripptypedef enum {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {(gchar *)"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp#endif // ENABLE_MAGIC_COLORS
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {(gchar *)"application/x-oswb-color", 0, APP_OSWB_COLOR },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippstatic bool temporarily_block_actions = false;
f69d245bb21be88752420e834a6b6be37e9b525fTripp#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
f69d245bb21be88752420e834a6b6be37e9b525fTrippstatic guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippstatic void sp_ui_import_one_file(char const *filename);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippstatic void sp_ui_import_one_file_with_check(gpointer filename, gpointer unused);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippstatic void sp_ui_drag_data_received(GtkWidget *widget,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippstatic void sp_recent_open(GtkRecentChooser *, gpointer);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Gtk::Window *win = Inkscape::UI::window_new("", TRUE);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp gtk_container_add(GTK_CONTAINER(win->gobj()), GTK_WIDGET(vw));
f69d245bb21be88752420e834a6b6be37e9b525fTripp SPDesktopWidget *desktop_widget = reinterpret_cast<SPDesktopWidget*>(vw);
f69d245bb21be88752420e834a6b6be37e9b525fTripp win->signal_delete_event().connect(sigc::mem_fun(*(SPDesktop*)vw->view, &SPDesktop::onDeleteUI));
f69d245bb21be88752420e834a6b6be37e9b525fTripp win->signal_window_state_event().connect(sigc::mem_fun(*desktop, &SPDesktop::onWindowStateEvent));
f69d245bb21be88752420e834a6b6be37e9b525fTripp win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent));
f69d245bb21be88752420e834a6b6be37e9b525fTripp Inkscape::Preferences *prefs = Inkscape::Preferences::get();
f69d245bb21be88752420e834a6b6be37e9b525fTripp (2==prefs->getInt("/options/savewindowgeometry/value", 0));
f69d245bb21be88752420e834a6b6be37e9b525fTripp gint pw = prefs->getInt("/desktop/geometry/width", -1);
f69d245bb21be88752420e834a6b6be37e9b525fTripp gint ph = prefs->getInt("/desktop/geometry/height", -1);
f69d245bb21be88752420e834a6b6be37e9b525fTripp gint full = prefs->getBool("/desktop/geometry/fullscreen");
f69d245bb21be88752420e834a6b6be37e9b525fTripp gint maxed = prefs->getBool("/desktop/geometry/maximized");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, px);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, py);
if (maxed) {
if (full) {
while ( list ) {
for ( i = 0; typesXX[i]; i++ ) {
for ( int i = 0; i < (int)nui_drop_target_entries; i++ ) {
pos++;
NULL);
NULL);
NULL);
if (!document) return;
void sp_ui_new_view_preview()
if ( document ) {
// Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP,
sp_ui_close_all(void)
while (SP_ACTIVE_DESKTOP) {
return FALSE;
// Shutdown can proceed; use the stored reference to the desktop here instead of the current SP_ACTIVE_DESKTOP,
return TRUE;
if (!temporarily_block_actions) {
Inkscape::UI::View::View *view = static_cast<Inkscape::UI::View::View*> (g_object_get_data(G_OBJECT(object), "view"));
Inkscape::UI::View::View *view = static_cast<Inkscape::UI::View::View*> (g_object_get_data(G_OBJECT(object), "view"));
static bool iconsInjected = false;
if ( !iconsInjected ) {
iconsInjected = true;
static GtkWidget *
if (stock) {
} else if (label) {
if (callback) {
return item;
unsigned int shortcut;
gchar *s;
if (!action)
static GtkWidget *
sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::UI::View::View *view, bool radio = false, GSList *group = NULL)
unsigned int shortcut;
if (radio) {
g_free(c);
if (radio) {
item));
item));
return item;
return prefPath;
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
static gboolean
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
g_signal_handlers_block_by_func(G_OBJECT(menuitem), (gpointer)(GCallback)checkitem_toggled, user_data);
g_signal_handlers_unblock_by_func(G_OBJECT(menuitem), (gpointer)(GCallback)checkitem_toggled, user_data);
return FALSE;
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
* Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode.
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(widget), "view");
bool new_state = false;
if (new_state) { //only one of the radio buttons has to be activated; the others will automatically be deactivated
// When the GtkMenuItem version of the "activate" signal has been emitted by a GtkRadioMenuItem, there is a second
// emission as the most recently active item is toggled to inactive. This is dealt with before the original signal is handled.
temporarily_block_actions = true;
temporarily_block_actions = false;
return FALSE;
sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref,
g_free(c);
g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) (action ? action->tip : tip));
if (dir) {
basename = 0;
continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already
basename = 0;
if (view) {
//sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu",
sp_ui_menu_append_check_item_from_verb(m, view, _("_Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands",
sp_ui_menu_append_check_item_from_verb(m, view, _("Sn_ap Controls Bar"), _("Show or hide the snapping controls"), "snaptoolbox",
sp_ui_menu_append_check_item_from_verb(m, view, _("T_ool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel",
sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox",
sp_ui_menu_append_check_item_from_verb(m, view, _("_Palette"), _("Show or hide the color palette"), "panels",
sp_ui_menu_append_check_item_from_verb(m, view, _("_Statusbar"), _("Show or hide the statusbar (at the bottom of the window)"), "statusbar",
int count = 0;
gint active = Inkscape::UI::UXManager::getInstance()->getDefaultTask( dynamic_cast<SPDesktop*>(view) );
g_signal_connect( G_OBJECT(item), "toggled", reinterpret_cast<GCallback>(taskToggled), GINT_TO_POINTER(count) );
g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), const_cast<gchar*>(strs[1]) );
void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI::View::View *view)
g_signal_connect(G_OBJECT(recent_menu), "item-activated", G_CALLBACK(sp_recent_open), (gpointer) NULL);
return mbar;
GtkWidget *m;
m = gtk_menu_new();
if (item) {
if (item) {
gtk_widget_show(w);
gtk_widget_show(w);
switch (info) {
case APP_X_INKY_COLOR:
int destX = 0;
int destY = 0;
if ( item )
sp_svg_write_color( c, sizeof(c),
bool updatePerformed = false;
str = 0;
updatePerformed = true;
if ( !updatePerformed ) {
if ( srgbProf ) {
case APP_X_COLOR:
int destX = 0;
int destY = 0;
bool consumed = false;
if (consumed) {
if (fillnotstroke &&
boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
if (position) {
double stroke_tolerance =
fillnotstroke = false;
delete livarot_path;
case APP_OSWB_COLOR:
bool worked = false;
if ( worked ) {
if (matches) {
if ( worked ) {
int destX = 0;
int destY = 0;
bool consumed = false;
if (consumed) {
if (fillnotstroke &&
boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
if (position) {
double stroke_tolerance =
fillnotstroke = false;
delete livarot_path;
case SVG_DATA:
case SVG_XML_DATA: {
Inkscape::XML::Document *rnewdoc = sp_repr_read_mem(svgdata, gtk_selection_data_get_length (data), SP_SVG_NS_URI);
if (sel_bbox) {
case URI_LIST: {
case PNG_DATA:
case JPEG_DATA:
case IMAGE_DATA: {
NULL);
#include "gradient-context.h"
if (!list)
if (filename) {
if (!doc) return;
_( "<span weight=\"bold\" size=\"larger\">A file named \"%s\" already exists. Do you want to replace it?</span>\n\n"
NULL );
return return_value;
void injectRenamedIcons()
for ( std::vector< std::pair<Glib::ustring, Glib::ustring> >::iterator it = renamed.begin(); it < renamed.end(); ++it ) {
if ( pb ) {