interface.cpp revision 3a66119215c6701c659557af3e524ea9b22bda0e
#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 "object-ui.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-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
#include "display/sp-canvas.h"
#include "color.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "style.h"
/* forward declaration */
/* Drag and Drop */
typedef enum {
static GtkTargetEntry ui_drop_target_entries [] = {
{"image/svg+xml", 0, SVG_XML_DATA},
{"application/x-color", 0, APP_X_COLOR}
};
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);
{NULL},
NULL,
NULL, /* set_active */
sp_ui_menu_item_set_sensitive, /* set_sensitive */
NULL /* set_shortcut */
};
void
{
if (editable) {
static_cast<GtkWindow*>((void*)w);
}
/* fixme: */
if (editable) {
} 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);
gtk_widget_show(w);
// 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;
}
static gint
{
}
/*
* 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, _("_Statusbar"), _("Show or hide the statusbar (at the bottom of the window)"), "statusbar",
sp_ui_menu_append_check_item_from_verb(m, view, _("_Palette"), _("Show or hide the color palette"), "panels",
}
/** \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
{
if (!strcmp(menu_pntr->attribute("name"), "Effects") && !prefs_get_int_attribute("extensions", "show-effects-menu", 0)) {
continue;
}
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.
*/
{
return mbar;
}
}
}
{
GtkWidget *m;
m = gtk_menu_new();
/* Undo and Redo */
/* Separator */
/* Separator */
/* Item menu */
if (item) {
}
/* layer menu */
if (item) {
if (SP_IS_GROUP(item)) {
}
}
}
/* 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
{
switch (info) {
case APP_X_COLOR:
{
int destX = 0;
int destY = 0;
if ( item )
{
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),
));
item->updateRepr();
sp_document_done( doc );
}
}
}
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.
{
}
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
sp_document_done( doc );
break;
}
}
}
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;
NULL,
NULL);
text = g_strdup_printf(_("The file %s already exists. Do you want to overwrite that file with the current document?"), filename);
return_value = TRUE;
} else {
}
} else {
return_value = TRUE;
}
return return_value;
}
static void
{
}
/*
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 :