interface.cpp revision 8b9a820756fdf348239872236be2257f854e094a
#define __SP_INTERFACE_C__
/**
* Main UI stuff
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
* Copyright (C) 2004 David Turner
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "inkscape-private.h"
#include "prefs-utils.h"
#include "path-prefix.h"
#include "shortcuts.h"
#include "document.h"
#include "desktop-handles.h"
#include "file.h"
#include "interface.h"
#include "desktop.h"
#include "ui/context-menu.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "svg-view-widget.h"
#include "widgets/desktop-widget.h"
#include "sp-item-group.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-namedview.h"
#include "helper/gnome-utils.h"
#include "io/stringstream.h"
#include "io/base64stream.h"
#include "dialogs/dialog-events.h"
#include "message-context.h"
// Added for color drag-n-drop
#if ENABLE_LCMS
#include "lcms.h"
#endif // ENABLE_LCMS
#include "display/sp-canvas.h"
#include "color.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "style.h"
#include "event-context.h"
#include "gradient-drag.h"
// Include Mac OS X menu synchronization on native OSX build
#ifdef GDK_WINDOWING_QUARTZ
#include "ige-mac-menu.h"
#endif
/* Drag and Drop */
typedef enum {
static GtkTargetEntry ui_drop_target_entries [] = {
#endif // ENABLE_MAGIC_COLORS
};
static GtkTargetEntry *completeDropTargets = 0;
static int completeDropTargetsCount = 0;
#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
static void sp_ui_import_one_file(char const *filename);
unsigned int sensitive,
void *data);
void *data);
{NULL},
NULL,
NULL, /* set_active */
sp_ui_menu_item_set_sensitive, /* set_sensitive */
NULL, /* set_shortcut */
sp_ui_menu_item_set_name /* set_name */
};
static const int MIN_ONSCREEN_DISTANCE = 50;
void
{
if (editable) {
win->signal_focus_in_event().connect(sigc::mem_fun(*desktop_widget, &SPDesktopWidget::onFocusInEvent));
if (prefs_geometry) {
if (w>0 && h>0 && x>0 && y>0) {
x = MIN(gdk_screen_width() - w, x);
y = MIN(gdk_screen_height() - h, y);
}
if (w>0 && h>0) {
desktop->setWindowSize(w, h);
}
// Only restore xy for the first window so subsequent windows don't overlap exactly
// with first. (Maybe rule should be only restore xy if it's different from xy of
// other desktops?)
// Empirically it seems that active_desktop==this desktop only the first time a
// desktop is created.
if (x>0 && y>0) {
}
}
}
if (maxed) {
}
if (full) {
win->fullscreen();
}
}
} else {
}
if ( completeDropTargets == 0 || completeDropTargetsCount == 0 )
{
while ( list ) {
int i = 0;
for ( i = 0; typesXX[i]; i++ ) {
}
}
for ( int i = 0; i < (int)nui_drop_target_entries; i++ ) {
}
int pos = nui_drop_target_entries;
pos++;
}
}
"drag_data_received",
NULL);
"drag_motion",
NULL);
"drag_leave",
NULL);
// needed because the first ACTIVATE_DESKTOP was sent when there was no window yet
}
void
{
if (!document) return;
}
/* TODO: not yet working */
/* To be re-enabled (by adding to menu) once it works. */
void
{
if (!document) return;
}
/**
* \param widget unused
*/
void
{
if (SP_ACTIVE_DESKTOP == NULL) {
return;
}
if ((SP_ACTIVE_DESKTOP)->shutdown()) {
return;
}
}
/**
* sp_ui_close_all
*
* This function is called to exit the program, and iterates through all
* open document view windows, attempting to close each in turn. If the
* view has unsaved information, the user will be prompted to save,
* discard, or cancel.
*
* Returns FALSE if the user cancels the close_all operation, TRUE
* otherwise.
*/
unsigned int
sp_ui_close_all(void)
{
/* Iterate through all the windows, destroying each in the order they
become active */
while (SP_ACTIVE_DESKTOP) {
if ((SP_ACTIVE_DESKTOP)->shutdown()) {
/* The user cancelled the operation, so end doing the close */
return FALSE;
}
}
return TRUE;
}
/*
* Some day when the right-click menus are ready to start working
* smarter with the verbs, we'll need to change this NULL being
* sent to sp_action_perform to something useful, or set some kind
* of global "right-clicked position" variable for actions to
* investigate when they're called.
*/
static void
{
}
static void
{
}
static void
{
}
static void
{
Inkscape::UI::View::View *view = static_cast<Inkscape::UI::View::View*> (g_object_get_data(G_OBJECT(object), "view"));
}
static void
{
Inkscape::UI::View::View *view = static_cast<Inkscape::UI::View::View*> (g_object_get_data(G_OBJECT(object), "view"));
}
/**
* sp_ui_menuitem_add_icon
*
* Creates and attaches a scaled icon to the given menu item.
*
*/
void
{
} // end of sp_ui_menu_add_icon
/**
* sp_ui_menu_append_item
*
*
*/
static GtkWidget *
{
if (stock) {
} else if (label) {
item = (with_mnemonic)
} else {
}
if (callback) {
}
}
return item;
} // end of sp_ui_menu_append_item()
/**
\brief a wrapper around gdk_keyval_name producing (when possible) characters, not names
*/
static gchar const *
{
/* TODO: Compare with the definition of gtk_accel_label_refetch in gtk/gtkaccellabel.c (or
simply use GtkAccelLabel as the TODO comment in sp_ui_shortcut_string suggests). */
else return n;
}
/**
* \param shortcut A GDK keyval OR'd with SP_SHORTCUT_blah_MASK values.
* \param c Points to a buffer at least 256 bytes long.
*/
void
{
/* TODO: This function shouldn't exist. Our callers should use GtkAccelLabel instead of
* a generic GtkLabel containing this string, and should call gtk_widget_add_accelerator.
* Will probably need to change sp_shortcut_invoke callers.
*
* The existing gtk_label_new_with_mnemonic call can be replaced with
* g_object_new(GTK_TYPE_ACCEL_LABEL, NULL) followed by
* gtk_label_set_text_with_mnemonic(lbl, str).
*/
static GtkAccelLabelClass const &accel_lbl_cls
};
gchar *p = c;
for (unsigned i = 0; i < G_N_ELEMENTS(modifier_tbl); ++i) {
&& (p < end))
{
modifier_tbl[i].name,
}
}
if (p < end) {
}
}
void
{
unsigned int shortcut;
gchar *s;
if (!action)
return;
if (shortcut) {
s = g_stpcpy(s, " (");
s = g_stpcpy(s, ")");
}
}
/**
* sp_ui_menu_append_item_from_verb
*
* Appends a custom menu UI from a verb.
*
*/
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)
{
} else {
unsigned int shortcut;
if (shortcut) {
gchar c[256];
if (radio) {
} else {
}
} else {
if (radio) {
} else {
item = gtk_image_menu_item_new ();
}
}
nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item);
}
}
}
return item;
} // end of sp_ui_menu_append_item_from_verb
static void
{
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
else
}
static gboolean
{
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
else
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;
}
void
sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref,
{
unsigned int shortcut = 0;
if (verb) {
}
gchar c[256];
{
}
{
GtkWidget *l = gtk_label_new(c);
}
} else {
}
#if 0
nr_active_object_add_listener((NRActiveObject *)action, (NRObjectEventVector *)&menu_item_event_vector, sizeof(SPActionEventVector), item);
}
#endif
g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) (action ? action->tip : tip));
}
static void
{
}
static void
{
}
void
{
// Use this loop to iterate through a list of possible document locations.
if (dir) {
continue; // skip non-svg files
continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already
// how does "filepath" ever get freed?
"activate",
if (view) {
// set null tip for now; later use a description from the template file
}
}
}
}
// toss the dirname
}
}
void
{
if (recent) {
int i;
"activate",
}
} else {
}
}
void
{
//sp_ui_menu_append_check_item_from_verb(m, view, _("_Menu"), _("Show or hide the menu bar"), "menu",
// checkitem_toggled, checkitem_update, 0);
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, _("Tool 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",
}
/** \brief This function turns XML into a menu
\param menus This is the XML that defines the menu
\param menu Menu to be added to
\param view The View that this menu is being built for
This function is realitively simple as it just goes through the XML
and parses the individual elements. In the case of a submenu, it
just calls itself recursively. Because it is only reasonable to have
a couple of submenus, it is unlikely this will go more than two or
three times.
In the case of an unreconginzed verb, a menu item is made to identify
the verb that is missing, and display that. The menu item is also made
insensitive.
*/
void
{
continue;
}
}
} else {
}
} else {
gtk_widget_set_sensitive(item, false);
}
continue;
}
// This was spelt wrong in the original version
// and so this is for backward compatibility. It can
// probably be dropped after the 0.44 release.
continue;
}
continue;
}
continue;
}
continue;
}
}
}
/** \brief Build the main tool bar
\param view View to build the bar for
Currently the main tool bar is built as a dynamic XML menu using
\c sp_ui_build_dyn_menus. This function builds the bar, and then
pass it to get items attached to it.
*/
{
#ifdef GDK_WINDOWING_QUARTZ
#endif
#ifdef GDK_WINDOWING_QUARTZ
return NULL;
#else
return mbar;
#endif
}
}
}
{
GtkWidget *m;
m = gtk_menu_new();
/* Undo and Redo */
/* Separator */
/* Separator */
/* Item menu */
if (item) {
}
/* layer menu */
if (item) {
if (SP_IS_GROUP(item)) {
}
}
( dt->currentLayer() != dt->currentRoot() && SP_OBJECT_PARENT(dt->currentLayer()) != dt->currentRoot() ) ) {
/* Separator */
}
/* TRANSLATORS: #%s is the id of the group e.g. <g id="#g7">, not a number. */
gtk_widget_show(w);
gtk_menu_shell_append(GTK_MENU_SHELL(m), w);
}
gtk_widget_show(w);
gtk_menu_shell_append(GTK_MENU_SHELL(m), w);
}
}
return m;
}
/* Drag and Drop */
void
guint /*event_time*/,
gpointer /*user_data*/)
{
switch (info) {
case APP_X_INKY_COLOR:
{
int destX = 0;
int destY = 0;
if ( item )
{
gchar c[64] = {0};
// Careful about endian issues.
sp_svg_write_color( c, sizeof(c),
0xff // can't have transparency in the color itself
//0x0ff & (data->data[3] >> 8),
));
bool updatePerformed = false;
// piggie-backed palette entry info
for ( int i = 0; i < dataVals[6]; i++ ) {
}
// Now hook in a magic tag of some sort.
str = 0;
false );
item->updateRepr();
updatePerformed = true;
}
}
if ( !updatePerformed ) {
}
item->updateRepr();
_("Drop color"));
if ( srgbProf ) {
}
}
}
}
break;
#endif // ENABLE_MAGIC_COLORS
case APP_X_COLOR:
{
int destX = 0;
int destY = 0;
gchar c[64] = {0};
// Careful about endian issues.
sp_svg_write_color( c, 64,
0xff // can't have transparency in the color itself
//0x0ff & (data->data[3] >> 8),
));
bool consumed = false;
if (consumed) {
}
}
//if (!consumed && tools_active(desktop, TOOLS_TEXT)) {
// consumed = sp_text_context_drop_color(c, button_doc);
// if (consumed) {
// sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient stop"));
// }
//}
if (fillnotstroke &&
boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
if (position) {
double stroke_tolerance =
desktop->current_zoom() *
: 0.0)
fillnotstroke = false;
}
}
delete livarot_path;
}
item->updateRepr();
_("Drop color"));
}
}
}
break;
case SVG_DATA:
case SVG_XML_DATA: {
sp_ui_error_dialog(_("Could not parse SVG data"));
return;
}
}
// Add it to the current layer
// Greg's edits to add intelligent positioning of svg drops
// To move the imported object, we must temporarily set the "transform pattern with
// object" option.
{
if (sel_bbox) {
}
}
_("Drop SVG"));
break;
}
case URI_LIST: {
break;
}
case PNG_DATA:
case JPEG_DATA:
case IMAGE_DATA: {
char tmp[1024];
b64out.setColumnWidth(0);
}
GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_mime_type( gdk_atom_name(data->type), &error );
if ( loader ) {
if ( pbuf ) {
}
}
}
// Add it to the current layer
_("Drop bitmap image"));
break;
}
}
}
#include "gradient-context.h"
GdkDragContext */*drag_context*/,
GtkSelectionData */*data*/,
guint /*info*/,
guint /*event_time*/,
gpointer /*user_data*/)
{
// SPDocument *doc = SP_ACTIVE_DOCUMENT;
// SPDesktop *desktop = SP_ACTIVE_DESKTOP;
// g_message("drag-n-drop motion (%4d, %4d) at %d", x, y, event_time);
}
GdkDragContext */*drag_context*/,
guint /*event_time*/,
gpointer /*user_data*/ )
{
// g_message("drag-n-drop leave at %d", event_time);
}
static void
{
if (!list)
return;
}
static void
{
if (filename) {
sp_ui_import_one_file((char const *)filename);
}
}
static void
sp_ui_import_one_file(char const *filename)
{
if (!doc) return;
// Pass off to common implementation
// TODO might need to get the proper type of Inkscape::Extension::Extension
}
void
{
}
bool
{
bool return_value = FALSE;
_( "<span weight=\"bold\" size=\"larger\">A file named \"%s\" already exists. Do you want to replace it?</span>\n\n"
"The file already exists in \"%s\". Replacing it will overwrite its contents." ),
);
_("Replace"), GTK_RESPONSE_YES,
NULL );
return_value = TRUE;
} else {
}
} else {
return_value = TRUE;
}
return return_value;
}
static void
{
}
static void
{
//child is either
//- a GtkHBox, whose first child is a label displaying name if the menu
//item has an accel key
//- a GtkLabel if the menu has no accel key
if (GTK_IS_LABEL(child)) {
} else if (GTK_IS_HBOX(child)) {
}//else sp_ui_menu_append_item_from_verb has been modified and can set
//a menu item in yet another way...
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :