dialog.cpp revision 6129af7cc5b723223e9617614c931936e5190421
/**
* \brief Base class for dialogs in Inkscape. This class provides certain
* common behaviors and styles wanted of all dialogs in the application.
*
* Author:
* Bryce W. Harrington <bryce@bryceharrington.org>
* buliabyak@gmail.com
*
* Copyright (C) 2004, 2005 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "application/application.h"
#include "application/editor.h"
#include "inkscape.h"
#include "event-context.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "dialog-manager.h"
#include "dialogs/dialog-events.h"
#include "shortcuts.h"
#include "prefs-utils.h"
#include "interface.h"
#include "verbs.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
#ifndef WIN32
static gboolean
{
dlg->retransientize_suppress = false;
return FALSE; // so that it is only called once
}
#endif
static void
{
}
static void
{
dlg->onShutdown();
}
void
{
}
void
{
int y, x, w, h;
get_position(x, y);
get_size(w, h);
// g_print ("write %d %d %d %d\n", x, y, w, h);
if (x<0) x=0;
if (y<0) y=0;
}
void
{
_user_hidden = false;
// g_print ("read %d %d %d %d\n", x, y, w, h);
if (x<0) x=0;
if (y<0) y=0;
// If there are stored height and width values for the dialog,
// resize the window to match; otherwise we leave it at its default
if (w != 0 && h != 0) {
resize (w, h);
}
// If there are stored values for where the dialog should be
// located, then restore the dialog to that position.
if (x != -1000 && y != -1000) {
move(x, y);
} else {
// ...otherwise just put it in the middle of the screen
}
}
{
}
{
}
//=====================================================================
/**
* UI::Dialog::Dialog is a base class for all dialogs in Inkscape. The
* purpose of this class is to provide a unified place for ensuring
* style and behavior. Specifically, this class provides functionality
* for saving and restoring the size and position of dialogs (through
* the user's preferences file).
*
* It also provides some general purpose signal handlers for things like
* showing and hiding all dialogs.
*/
{
hide();
set_has_separator(false);
// TODO: make the order of buttons obey the global preference
if (apply_label) {
}
}
if (verb_num)
{
}
retransientize_suppress = false;
_hiddenF12 = false;
{
_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*this, &Dialog::onDesktopActivated));
_dialogs_hidden_connection = Inkscape::NSApplication::Editor::connectDialogsHidden (sigc::mem_fun (*this, &Dialog::onHideF12));
_dialogs_unhidden_connection = Inkscape::NSApplication::Editor::connectDialogsUnhidden (sigc::mem_fun (*this, &Dialog::onShowF12));
_shutdown_connection = Inkscape::NSApplication::Editor::connectShutdown (sigc::mem_fun (*this, &Dialog::onShutdown));
}
else
{
g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_retransientize), (void *)this);
}
present();
}
{
}
{
{
}
}
{
unsigned int shortcut = 0;
SP_SHORTCUT_SHIFT_MASK : 0 ) |
SP_SHORTCUT_CONTROL_MASK : 0 ) |
SP_SHORTCUT_ALT_MASK : 0 );
}
//---------------------------------------------------------------------
void
{
switch (response_id) {
case Gtk::RESPONSE_APPLY: {
_apply();
break;
}
case Gtk::RESPONSE_CLOSE: {
_close();
break;
}
}
}
bool
{
_user_hidden = true;
return false;
}
void
{
_hiddenF12 = true;
hide();
}
void
{
if (_user_hidden)
return;
if (_hiddenF12) {
show();
}
_hiddenF12 = false;
}
void
Dialog::onShutdown()
{
_user_hidden = true;
}
void
{
gint transient_policy = prefs_get_int_attribute_limited ( "options.transientpolicy", "value", 1, 0, 2);
if (!transient_policy)
return;
#ifndef WIN32
if (retransientize_suppress) {
/* if retransientizing of this dialog is still forbidden after
* previous call warning turned off because it was confusingly fired
* when loading many files from command line
*/
// g_warning("Retranzientize aborted! You're switching windows too fast!");
return;
}
if (dialog_win)
{
retransientize_suppress = true; // disallow other attempts to retranzientize this dialog
/*
* This enables "aggressive" transientization,
* i.e. dialogs always emerging on top when you switch documents. Note
* however that this breaks "click to raise" policy of a window
* manager because the switched-to document will be raised at once
* (so that its transients also could raise)
*/
// without this, a transient window not always emerges on top
}
}
// we're done, allow next retransientizing not sooner than after 120 msec
#endif
}
{
return sp_desktop_selection(SP_ACTIVE_DESKTOP);
}
void
{
g_warning("Apply button clicked for dialog [Dialog::_apply()]");
}
void
{
/* this code sends a delete_event to the dialog,
* instead of just destroying it, so that the
* dialog can do some housekeeping, such as remember
* its position.
*/
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
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 :