From: Ted Gould Date: Thu, 25 Sep 2008 04:27:18 +0000 (-0500) Subject: Sorry, I got off on a branch and ended up with a bunch of things. I'm just going... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=86b3a7fc48d3fa59eb2e3289e0b8b2b56c7ed270;p=inkscape.git Sorry, I got off on a branch and ended up with a bunch of things. I'm just going to flatten and merge... Here's the list. * Added a focus mode activated by Shift+F11. The goal of this mode is to remove all toolbars for a short period so that you maximize screen area. Useful on small screens. Also when you know lots of shortcuts. * Created what I'm calling "Quick Zoom." The idea here is to have a modal zoom for touching up something with fine detail and then returning to what you're doing. This is activated with the letter "Q" on the keyboard. When you release it, you return back to where you were. This will zoom in on selected objects, or if you're in the node tool selected nodes. * Added .svg on the temporary files in extensions. This'll make many of them happier. This only works on recent versions of GLib, but shouldn't break older ones more than they already are. * Moved the Inkscape configuration directory on Linux from ~/.inkscape to ~/.config/Inkscape. This is the new way to do things with the cross desktop naming spec. I'm unsure whether we should be putting crash dumps in .config or .cache though. * Removed 'tools_switch_current' because every usage of it already had a pointer to where it needed to go. Removes usage of globals. * Made it so that dialogs will be transparent when not focused. This is an alternate to having the docked, and one that I like better as I feel it gives me more screen area. You can adjust how much transparency and the speed of the animation in the preferences dialog. (Note: this requires GTK+ 2.12 and a compositor, but gracefully degrades if you don't have either) --- diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 000000000..4dc262f49 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,38 @@ +Makefile.in +aclocal.m4 +autom4te.cache +build +compile +config.guess +config.h.in +config.sub +configure +depcomp +install +install-sh +intltool-extract.in +intltool-merge.in +intltool-update.in +missing +doc/Makefile.in +po/Makefile.in.in +share/Makefile.in +share/clipart/Makefile.in +share/examples/Makefile.in +share/extensions/Makefile.in +share/extensions/Barcode/Makefile.in +share/extensions/Poly3DObjects/Makefile.in +share/extensions/alphabet_soup/Makefile.in +share/extensions/xaml2svg/Makefile.in +share/fonts/Makefile.in +share/gradients/Makefile.in +share/icons/Makefile.in +share/keys/Makefile.in +share/markers/Makefile.in +share/palettes/Makefile.in +share/patterns/Makefile.in +share/screens/Makefile.in +share/templates/Makefile.in +share/tutorials/Makefile.in +share/ui/Makefile.in +src/Makefile.in diff --git a/configure.ac b/configure.ac index 46f255abb..5a7726241 100644 --- a/configure.ac +++ b/configure.ac @@ -551,11 +551,10 @@ fi AC_SUBST(POPPLER_CFLAGS) AC_SUBST(POPPLER_LIBS) -ink_svd_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$POPPLER_CFLAGS $CPPFLAGS" -AC_MSG_CHECKING([whether libpoppler has new getNextChar]) -AC_EGREP_CPP([Unicode ..u. int .uLen], [#include "GfxFont.h"], AC_DEFINE([POPPLER_NEW_GFXFONT], [], [True iff libpoppler is 0.8.3 or newer.]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) -CPPFLAGS="$ink_svd_CPPFLAGS" +PKG_CHECK_MODULES(POPPLERNEW, poppler >= 0.8.3, popplernew=yes, popplernew=no) +if test "x$popplernew" = "xyes"; then + AC_DEFINE(POPPLER_NEW_GFXFONT, 1, [Poppler version of GfxFont to use (0.8.3 or higher versions of Poppler)]) +fi dnl ****************************** dnl Inkboard dependency checking diff --git a/share/keys/default.xml b/share/keys/default.xml index 5ed3124d5..e5e5d43aa 100644 --- a/share/keys/default.xml +++ b/share/keys/default.xml @@ -215,6 +215,7 @@ override) the bindings in the main default.xml. + diff --git a/src/desktop.cpp b/src/desktop.cpp index 4f6ea7a5a..004a0116e 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -133,6 +133,7 @@ SPDesktop::SPDesktop() : page( 0 ), page_border( 0 ), current( 0 ), + _focusMode(false), zooms_past( 0 ), zooms_future( 0 ), dkey( 0 ), @@ -861,6 +862,102 @@ SPDesktop::next_zoom() zooms_future = g_list_remove (zooms_future, ((NRRect *) zooms_future->data)); } +#include "tools-switch.h" +#include "node-context.h" +#include "shape-editor.h" +#include "nodepath.h" + +/** \brief Performs a quick zoom into what the user is working on + \param enable Whether we're going in or out of quick zoom + +*/ +void +SPDesktop::zoom_quick (bool enable) +{ + if (enable == _quick_zoom_enabled) { + return; + } + + if (enable == true) { + _quick_zoom_stored_area = get_display_area(); + bool zoomed = false; + + if (!zoomed) { + SPItem * singleItem = selection->singleItem(); + if (singleItem != NULL && tools_isactive(this, TOOLS_NODES)) { + SPNodeContext * ncontext = SP_NODE_CONTEXT(event_context); + + Inkscape::NodePath::Path * nodepath = ncontext->shape_editor->get_nodepath(); + // printf("I've got a nodepath, crazy\n"); + + Geom::Rect nodes; + bool firstnode = true; + + if (nodepath->selected) { + for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) { + Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data; + for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) { + Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data; + if (node->selected) { + // printf("\tSelected node\n"); + if (firstnode) { + nodes = Geom::Rect(node->pos, node->pos); + firstnode = false; + } else { + nodes.expandTo(node->pos); + } + + if (node->p.other != NULL) { + /* Include previous node pos */ + nodes.expandTo(node->p.other->pos); + + /* Include previous handle */ + if (!sp_node_side_is_line(node, &node->p)) { + nodes.expandTo(node->p.pos); + } + } + + if (node->n.other != NULL) { + /* Include previous node pos */ + nodes.expandTo(node->n.other->pos); + + /* Include previous handle */ + if (!sp_node_side_is_line(node, &node->n)) { + nodes.expandTo(node->n.pos); + } + } + } + } + } + + if (!firstnode && nodes.area() * 2.0 < _quick_zoom_stored_area.area()) { + set_display_area(nodes, 10); + zoomed = true; + } + } + } + } + + if (!zoomed) { + boost::optional const d = selection->bounds_2geom(); + if (d && !d->isEmpty() && d->area() * 2.0 < _quick_zoom_stored_area.area()) { + set_display_area(*d, 10); + zoomed = true; + } + } + + if (!zoomed) { + zoom_relative(_quick_zoom_stored_area.midpoint()[NR::X], _quick_zoom_stored_area.midpoint()[NR::Y], 2.0); + zoomed = true; + } + } else { + set_display_area(_quick_zoom_stored_area, 0); + } + + _quick_zoom_enabled = enable; + return; +} + /** * Zoom to point with absolute zoom factor. */ @@ -1129,6 +1226,33 @@ SPDesktop::fullscreen() _widget->setFullscreen(); } +/** \brief Checks to see if the user is working in focused mode + + Returns the value of \c _focusMode +*/ +bool +SPDesktop::is_focusMode() +{ + return _focusMode; +} + +/** \brief Changes whether the user is in focus mode or not + \param mode Which mode the view should be in + +*/ +void +SPDesktop::focusMode (bool mode) +{ + if (mode == _focusMode) { return; } + + _focusMode = mode; + + layoutWidget(); + //sp_desktop_widget_layout(SPDesktopWidget); + + return; +} + void SPDesktop::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) { diff --git a/src/desktop.h b/src/desktop.h index f02f5556c..fa38e1b71 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -30,6 +30,7 @@ #include #include <2geom/matrix.h> +#include <2geom/rect.h> #include "ui/view/view.h" #include "ui/view/edit-widget-interface.h" @@ -112,9 +113,12 @@ struct SPDesktop : public Inkscape::UI::View::View SPCanvasItem *page; ///< page background SPCanvasItem *page_border; ///< page border SPCSSAttr *current; ///< current style + bool _focusMode; ///< Whether we're focused working or general working GList *zooms_past; GList *zooms_future; + bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode + Geom::Rect _quick_zoom_stored_area; ///< The area of the screen before quick zoom unsigned int dkey; unsigned int number; guint window_state; @@ -246,6 +250,9 @@ struct SPDesktop : public Inkscape::UI::View::View double current_zoom() const { return _d2w.descrim(); } void prev_zoom(); void next_zoom(); + void zoom_quick(bool enable = true); + /** \brief Returns whether the desktop is in quick zoom mode or not */ + bool quick_zoomed(void) { return _quick_zoom_enabled; } bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0); void scroll_world (double dx, double dy, bool is_scrolling = false); @@ -289,10 +296,12 @@ struct SPDesktop : public Inkscape::UI::View::View bool is_iconified(); bool is_maximized(); bool is_fullscreen(); + bool is_focusMode(); void iconify(); void maximize(); void fullscreen(); + void focusMode(bool mode = true); void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget) { _widget = widget; } diff --git a/src/event-context.cpp b/src/event-context.cpp index 9df171146..e5f81a2b9 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -533,6 +533,16 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, ret = TRUE; } break; + case GDK_Q: + case GDK_q: + if (desktop->quick_zoomed()) { + ret = TRUE; + } + if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) { + desktop->zoom_quick(true); + ret = TRUE; + } + break; case GDK_W: case GDK_w: case GDK_F4: @@ -628,6 +638,13 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, ret= TRUE; } break; + case GDK_Q: + case GDK_q: + if (desktop->quick_zoomed()) { + desktop->zoom_quick(false); + ret = TRUE; + } + break; default: break; } diff --git a/src/extension/db.h b/src/extension/db.h index c67a62bf2..9505ac779 100644 --- a/src/extension/db.h +++ b/src/extension/db.h @@ -64,7 +64,7 @@ public: typedef std::list InputList; typedef std::list EffectList; - InputList &get_input_list (InputList &ou_list); + InputList &get_input_list (InputList &ou_list); OutputList &get_output_list (OutputList &ou_list); EffectList &get_effect_list (EffectList &ou_list); }; /* class DB */ diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 1f6d973c3..9475b4796 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -11,23 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/* -TODO: -FIXME: - After Inkscape makes a formal requirement for a GTK version above 2.11.4, please - replace all the instances of ink_ext_XXXXXX in this file that represent - svg files with ink_ext_XXXXXX.svg . Doing so will prevent errors in extensions - that call inkscape to manipulate the file. - - "** (inkscape:5848): WARNING **: Format autodetect failed. The file is being opened as SVG." - - references: - http://www.gtk.org/api/2.6/glib/glib-File-Utilities.html#g-mkstemp - http://ftp.gnome.org/pub/gnome/sources/glib/2.11/glib-2.11.4.changes - http://developer.gnome.org/doc/API/2.0/glib/glib-File-Utilities.html#g-mkstemp - - --Aaron Spike -*/ #define __INKSCAPE_EXTENSION_IMPLEMENTATION_SCRIPT_C__ #ifdef HAVE_CONFIG_H @@ -77,19 +60,18 @@ namespace Inkscape { namespace Extension { namespace Implementation { -void pump_events (void) { +/** \brief Make GTK+ events continue to come through a little bit + + This just keeps coming the events through so that we'll make the GUI + update and look pretty. +*/ +void +Script::pump_events (void) { while( Gtk::Main::events_pending() ) Gtk::Main::iteration(); return; } -//Interpreter lookup table -struct interpreter_t { - gchar const *identity; - gchar const *prefstring; - gchar const *defaultval; -}; - /** \brief A table of what interpreters to call for a given language @@ -97,7 +79,7 @@ struct interpreter_t { given script. It also tracks the preference to use to overwrite the given interpreter to a custom one per user. */ -static interpreter_t const interpreterTab[] = { +Script::interpreter_t const Script::interpreterTab[] = { {"perl", "perl-interpreter", "perl" }, #ifdef WIN32 {"python", "python-interpreter", "pythonw" }, @@ -111,12 +93,13 @@ static interpreter_t const interpreterTab[] = { -/** - * Look up an interpreter name, and translate to something that - * is executable - */ -static Glib::ustring -resolveInterpreterExecutable(const Glib::ustring &interpNameArg) +/** \brief Look up an interpreter name, and translate to something that + is executable + \param interpNameArg The name of the interpreter that we're looking + for, should be an entry in interpreterTab +*/ +Glib::ustring +Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg) { Glib::ustring interpName = interpNameArg; @@ -184,8 +167,6 @@ resolveInterpreterExecutable(const Glib::ustring &interpNameArg) return interpName; } - - /** \brief This function creates a script object and sets up the variables. \return A script object @@ -199,7 +180,6 @@ Script::Script() : { } - /** * brief Destructor */ @@ -573,7 +553,7 @@ Script::open(Inkscape::Extension::Input *module, std::string tempfilename_out; int tempfd_out = 0; try { - tempfd_out = Inkscape::IO::file_open_tmp(tempfilename_out, "ink_ext_XXXXXX"); + tempfd_out = Inkscape::IO::file_open_tmp(tempfilename_out, "ink_ext_XXXXXX.svg"); } catch (...) { /// \todo Popup dialog here return NULL; @@ -647,7 +627,7 @@ Script::save(Inkscape::Extension::Output *module, std::string tempfilename_in; int tempfd_in = 0; try { - tempfd_in = Inkscape::IO::file_open_tmp(tempfilename_in, "ink_ext_XXXXXX"); + tempfd_in = Inkscape::IO::file_open_tmp(tempfilename_in, "ink_ext_XXXXXX.svg"); } catch (...) { /// \todo Popup dialog here return; diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h index 226a6beb2..4620375f9 100644 --- a/src/extension/implementation/script.h +++ b/src/extension/implementation/script.h @@ -199,6 +199,20 @@ private: const std::list &in_params, const Glib::ustring &filein, file_listener &fileout); + + void pump_events (void); + + /** \brief A definition of an interpreter, which can be specified + in the INX file, but we need to know what to call */ + struct interpreter_t { + gchar const *identity; /**< The ID that is in the INX file */ + gchar const *prefstring; /**< The preferences key that can override the default */ + gchar const *defaultval; /**< The default value if there are no preferences */ + }; + static interpreter_t const interpreterTab[]; + + Glib::ustring resolveInterpreterExecutable(const Glib::ustring &interpNameArg); + }; // class Script diff --git a/src/extension/timer.cpp b/src/extension/timer.cpp index c7a9331a0..640bf143d 100644 --- a/src/extension/timer.cpp +++ b/src/extension/timer.cpp @@ -31,7 +31,7 @@ bool ExpirationTimer::timer_started = false; This function creates the timer, and sets the time to the current time, plus what ever the current timeout is. Also, if this is the first timer extension, the timer is kicked off. This function - also sets up teh circularly linked list of all the timers. + also sets up the circularly linked list of all the timers. */ ExpirationTimer::ExpirationTimer (Extension * in_extension): locked(0), diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 6a0971ac7..dca23d539 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -147,12 +147,7 @@ static void (* fpe_handler) (int) = SIG_DFL; static void (* ill_handler) (int) = SIG_DFL; static void (* bus_handler) (int) = SIG_DFL; -#ifdef WIN32 #define INKSCAPE_PROFILE_DIR "Inkscape" -#else -#define INKSCAPE_PROFILE_DIR ".inkscape" -#endif - #define MENUS_FILE "menus.xml" @@ -626,20 +621,20 @@ inkscape_crash_handler (int /*signum*/) if (!docname || !*docname) docname = "emergency"; // try saving to the profile location - g_snprintf (c, 1024, "%.256s.%s.%d", docname, sptstr, count); + g_snprintf (c, 1024, "%.256s.%s.%d.svg", docname, sptstr, count); gchar * location = homedir_path(c); Inkscape::IO::dump_fopen_call(location, "E"); file = Inkscape::IO::fopen_utf8name(location, "w"); g_free(location); if (!file) { // try saving to /tmp - g_snprintf (c, 1024, "/tmp/inkscape-%.256s.%s.%d", docname, sptstr, count); + g_snprintf (c, 1024, "/tmp/inkscape-%.256s.%s.%d.svg", docname, sptstr, count); Inkscape::IO::dump_fopen_call(c, "G"); file = Inkscape::IO::fopen_utf8name(c, "w"); } if (!file) { // try saving to the current directory - g_snprintf (c, 1024, "inkscape-%.256s.%s.%d", docname, sptstr, count); + g_snprintf (c, 1024, "inkscape-%.256s.%s.%d.svg", docname, sptstr, count); Inkscape::IO::dump_fopen_call(c, "F"); file = Inkscape::IO::fopen_utf8name(c, "w"); } @@ -1392,7 +1387,7 @@ profile_path(const char *filename) } #endif if (!prefdir) { - prefdir = homedir_path(NULL); + prefdir = homedir_path(".config"); } } return g_build_filename(prefdir, INKSCAPE_PROFILE_DIR, filename, NULL); diff --git a/src/interface.cpp b/src/interface.cpp index 5abf8d8db..35e7bf957 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -633,14 +633,18 @@ checkitem_toggled(GtkCheckMenuItem *menuitem, gpointer user_data) gchar const *pref = (gchar const *) user_data; Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view"); - gchar const *pref_path; - if (reinterpret_cast(view)->is_fullscreen()) + gchar *pref_path; + if (reinterpret_cast(view)->is_focusMode()) { + pref_path = g_strconcat("focus.", pref, NULL); + } else if (reinterpret_cast(view)->is_fullscreen()) { pref_path = g_strconcat("fullscreen.", pref, NULL); - else + } else { pref_path = g_strconcat("window.", pref, NULL); + } gboolean checked = gtk_check_menu_item_get_active(menuitem); prefs_set_int_attribute(pref_path, "state", checked); + g_free(pref_path); reinterpret_cast(view)->layoutWidget(); } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 84aadff3c..78ebca384 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -197,7 +197,7 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt) { // If not already in nodecontext, goto it! if (!tools_isactive(dt, TOOLS_NODES)) { - tools_switch_current(TOOLS_NODES); + tools_switch(dt, TOOLS_NODES); } ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor; diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index bd4f8535e..680d4f0fe 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -134,6 +134,8 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +// Not quite ready to be in the menus. +// " \n" " \n" " \n" " \n" diff --git a/src/nodepath.h b/src/nodepath.h index 907d47be4..336c9019c 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -300,6 +300,8 @@ void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, G void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, Geom::Point p); void sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, Geom::Point delta); Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(Inkscape::NodePath::Path *np, int index); +bool sp_node_side_is_line (Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeSide *side); + /* possibly private functions */ void sp_node_selected_add_node (Inkscape::NodePath::Path *nodepath); diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 3ca113e85..6cf1b3feb 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -27,6 +27,16 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" "\n" " \n" " \n" @@ -185,6 +195,15 @@ static char const preferences_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" @@ -299,6 +318,8 @@ static char const preferences_skeleton[] = " \n" "\n" " " +// NOTE: This gets filled in by the extensions themselves based on +// the properties that they provide in their INX files. " \n" "\n" " event_context )->shape_editor; diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index 6ee162f1d..da03ab7bf 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -258,13 +258,6 @@ tools_switch(SPDesktop *dt, int num) } } -void -tools_switch_current(int num) -{ - SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (dt) tools_switch(dt, num); -} - void tools_switch_by_item(SPDesktop *dt, SPItem *item) { if (SP_IS_RECT(item)) { diff --git a/src/tools-switch.h b/src/tools-switch.h index 2026c1a3d..38b83b226 100644 --- a/src/tools-switch.h +++ b/src/tools-switch.h @@ -40,7 +40,6 @@ enum { int tools_isactive(SPDesktop *dt, unsigned num); int tools_active(SPDesktop *dt); void tools_switch(SPDesktop *dt, int num); -void tools_switch_current(int num); void tools_switch_by_item (SPDesktop *dt, SPItem *item); #endif /* !SEEN_TOOLS_SWITCH_H */ diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index f670c6410..9f5571b4b 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -32,6 +32,13 @@ namespace Behavior { FloatingBehavior::FloatingBehavior(Dialog &dialog) : Behavior(dialog), _d (new Gtk::Dialog(_dialog._title)) +#if GTK_VERSION_GE(2, 12) + ,_dialog_active(_d->property_is_active()) + ,_steps(0) + ,_trans_focus(prefs_get_double_attribute_limited("dialogs.transparency", "on-focus", 0.95, 0.0, 1.0)) + ,_trans_blur(prefs_get_double_attribute_limited("dialogs.transparency", "on-blur", 0.50, 0.0, 1.0)) + ,_trans_time(prefs_get_int_attribute_limited("dialogs.transparency", "animate-time", 100, 0, 5000)) +#endif { hide(); _d->set_has_separator(false); @@ -40,8 +47,83 @@ FloatingBehavior::FloatingBehavior(Dialog &dialog) : sp_transientize(GTK_WIDGET(_d->gobj())); _dialog.retransientize_suppress = false; + +#if GTK_VERSION_GE(2, 12) + _focus_event(); + _dialog_active.signal_changed().connect(sigc::mem_fun(this, &FloatingBehavior::_focus_event)); +#endif + +} + +#if GTK_VERSION_GE(2, 12) +/** \brief A function called when the window gets focus + + This function gets called on a focus event. It figures out how much + time is required for a transition, and the number of steps that'll take, + and sets up the _trans_timer function to do the work. If the transition + time is set to 0 ms it just calls _trans_timer once with _steps equal to + zero so that the transition happens instantaneously. This occurs on + windows as opacity changes cause flicker there. +*/ +void FloatingBehavior::_focus_event (void) { + _steps = 0; + _trans_focus = prefs_get_double_attribute_limited("dialogs.transparency", "on-focus", 0.95, 0.0, 1.0); + _trans_blur = prefs_get_double_attribute_limited("dialogs.transparency", "on-blur", 0.50, 0.0, 1.0); + _trans_time = prefs_get_int_attribute_limited("dialogs.transparency", "animate-time", 100, 0, 5000); + + if (_trans_time != 0) { + float diff = _trans_focus - _trans_blur; + if (diff < 0.0) diff *= -1.0; + + while (diff > 0.05) { + _steps++; + diff = diff / 2.0; + } + + if (_steps != 0) { + Glib::signal_timeout().connect(sigc::mem_fun(this, &FloatingBehavior::_trans_timer), _trans_time / _steps); + } + } + _trans_timer(); + + return; } +/** \brief Move the opacity of a window towards our goal + + This is a timer function that is set up by _focus_event to slightly + move the opacity of the window along in an animated fashion. It moves + the opacity half way to the goal until it runs out of steps, and then + it just forces the goal. +*/ +bool FloatingBehavior::_trans_timer (void) { + // printf("Go go gadget timer: %d\n", _steps); + if (_steps == 0) { + if (_dialog_active.get_value()) { + _d->set_opacity(_trans_focus); + } else { + _d->set_opacity(_trans_blur); + } + + return false; + } + + float goal, current; + goal = current = _d->get_opacity(); + + if (_dialog_active.get_value()) { + goal = _trans_focus; + } else { + goal = _trans_blur; + } + + _d->set_opacity(current - ((current - goal) / 2)); + _steps--; + return true; +} + +#endif + FloatingBehavior::~FloatingBehavior() { delete _d; diff --git a/src/ui/dialog/floating-behavior.h b/src/ui/dialog/floating-behavior.h index a7e6ef3a0..0ab2d6981 100644 --- a/src/ui/dialog/floating-behavior.h +++ b/src/ui/dialog/floating-behavior.h @@ -14,6 +14,7 @@ #define INKSCAPE_UI_DIALOG_FLOATING_BEHAVIOR_H #include +#include #include "behavior.h" namespace Inkscape { @@ -62,6 +63,17 @@ private: Gtk::Dialog *_d; //< the actual dialog +#if GTK_VERSION_GE(2, 12) + void _focus_event (void); + bool _trans_timer (void); + + Glib::PropertyProxy_ReadOnly _dialog_active; //< Variable proxy to track whether the dialog is the active window + int _steps; //< Number of steps for the timer to animate the transparent dialog + float _trans_focus; //< The percentage opacity when the dialog is focused + float _trans_blur; //< The percentage opactiy when the dialog is not focused + int _trans_time; //< The amount of time (in ms) for the dialog to change it's transparency +#endif + }; } // namespace Behavior diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2eec63478..e2e717c53 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -513,11 +513,11 @@ void InkscapePreferences::initPageWindows() _win_ontop_agressive.init ( _("Aggressive"), "options.transientpolicy", "value", 2, false, &_win_ontop_none); _page_windows.add_group_header( _("Saving window geometry (size and position):")); - _page_windows.add_line( false, "", _win_save_geom_off, "", + _page_windows.add_line( true, "", _win_save_geom_off, "", _("Let the window manager determine placement of all windows")); - _page_windows.add_line( false, "", _win_save_geom_prefs, "", + _page_windows.add_line( true, "", _win_save_geom_prefs, "", _("Remember and use the last window's geometry (saves geometry to user preferences)")); - _page_windows.add_line( false, "", _win_save_geom, "", + _page_windows.add_line( true, "", _win_save_geom, "", _("Save and restore window geometry for each document (saves geometry in the document)")); _page_windows.add_group_header( _("Dialog behavior (requires restart):")); @@ -537,6 +537,16 @@ void InkscapePreferences::initPageWindows() _("Same as Normal but may work better with some window managers")); #endif +#if GTK_VERSION_GE(2, 12) + _page_windows.add_group_header( _("Dialog Transparency:")); + _win_trans_focus.init("dialogs.transparency", "on-focus", 0.5, 1.0, 0.01, 0.1, 1.0, false, false); + _page_windows.add_line( true, _("Opacity when focused:"), _win_trans_focus, "", ""); + _win_trans_blur.init("dialogs.transparency", "on-blur", 0.0, 1.0, 0.01, 0.1, 0.5, false, false); + _page_windows.add_line( true, _("Opacity when unfocused:"), _win_trans_blur, "", ""); + _win_trans_time.init("dialogs.transparency", "animate-time", 0, 1000, 10, 100, 100, true, false); + _page_windows.add_line( true, _("Time of opacity change animation:"), _win_trans_time, "ms", ""); +#endif + _page_windows.add_group_header( _("Miscellaneous:")); #ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs _page_windows.add_line( false, "", _win_hide_task, "", diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 30dd2bdaa..02794d0e2 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -140,6 +141,9 @@ protected: PrefRadioButton _win_ontop_none, _win_ontop_normal, _win_ontop_agressive; PrefRadioButton _win_save_geom_off, _win_save_geom, _win_save_geom_prefs; PrefCheckButton _win_hide_task, _win_zoom_resize , _win_show_close; + PrefSpinButton _win_trans_focus; /**< The dialog transparency setting for when the dialog is focused. */ + PrefSpinButton _win_trans_blur; /**< The dialog transparency setting for when the dialog is out of focus. */ + PrefSpinButton _win_trans_time; /**< How much time to go from one transparency setting to another */ PrefCheckButton _calligrapy_use_abs_size; PrefCheckButton _calligrapy_keep_selected; diff --git a/src/verbs.cpp b/src/verbs.cpp index 71ec33b3f..c1e7e5fc9 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1070,13 +1070,12 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/) break; case SP_VERB_SELECTION_DYNAMIC_OFFSET: sp_selected_path_create_offset_object_zero(dt); - tools_switch_current(TOOLS_NODES); + tools_switch(dt, TOOLS_NODES); break; case SP_VERB_SELECTION_LINKED_OFFSET: sp_selected_path_create_updating_offset_object_zero(dt); - tools_switch_current(TOOLS_NODES); + tools_switch(dt, TOOLS_NODES); break; - case SP_VERB_SELECTION_OUTLINE: sp_selected_path_outline(dt); break; @@ -1434,61 +1433,61 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/) switch (verb) { case SP_VERB_CONTEXT_SELECT: - tools_switch_current(TOOLS_SELECT); + tools_switch(dt, TOOLS_SELECT); break; case SP_VERB_CONTEXT_NODE: - tools_switch_current(TOOLS_NODES); + tools_switch(dt, TOOLS_NODES); break; case SP_VERB_CONTEXT_TWEAK: - tools_switch_current(TOOLS_TWEAK); + tools_switch(dt, TOOLS_TWEAK); break; case SP_VERB_CONTEXT_RECT: - tools_switch_current(TOOLS_SHAPES_RECT); + tools_switch(dt, TOOLS_SHAPES_RECT); break; case SP_VERB_CONTEXT_3DBOX: - tools_switch_current(TOOLS_SHAPES_3DBOX); + tools_switch(dt, TOOLS_SHAPES_3DBOX); break; case SP_VERB_CONTEXT_ARC: - tools_switch_current(TOOLS_SHAPES_ARC); + tools_switch(dt, TOOLS_SHAPES_ARC); break; case SP_VERB_CONTEXT_STAR: - tools_switch_current(TOOLS_SHAPES_STAR); + tools_switch(dt, TOOLS_SHAPES_STAR); break; case SP_VERB_CONTEXT_SPIRAL: - tools_switch_current(TOOLS_SHAPES_SPIRAL); + tools_switch(dt, TOOLS_SHAPES_SPIRAL); break; case SP_VERB_CONTEXT_PENCIL: - tools_switch_current(TOOLS_FREEHAND_PENCIL); + tools_switch(dt, TOOLS_FREEHAND_PENCIL); break; case SP_VERB_CONTEXT_PEN: - tools_switch_current(TOOLS_FREEHAND_PEN); + tools_switch(dt, TOOLS_FREEHAND_PEN); break; case SP_VERB_CONTEXT_CALLIGRAPHIC: - tools_switch_current(TOOLS_CALLIGRAPHIC); + tools_switch(dt, TOOLS_CALLIGRAPHIC); break; case SP_VERB_CONTEXT_TEXT: - tools_switch_current(TOOLS_TEXT); + tools_switch(dt, TOOLS_TEXT); break; case SP_VERB_CONTEXT_GRADIENT: - tools_switch_current(TOOLS_GRADIENT); + tools_switch(dt, TOOLS_GRADIENT); break; case SP_VERB_CONTEXT_ZOOM: - tools_switch_current(TOOLS_ZOOM); + tools_switch(dt, TOOLS_ZOOM); break; case SP_VERB_CONTEXT_DROPPER: - tools_switch_current(TOOLS_DROPPER); + tools_switch(dt, TOOLS_DROPPER); break; case SP_VERB_CONTEXT_CONNECTOR: - tools_switch_current (TOOLS_CONNECTOR); + tools_switch(dt, TOOLS_CONNECTOR); break; case SP_VERB_CONTEXT_PAINTBUCKET: - tools_switch_current(TOOLS_PAINTBUCKET); + tools_switch(dt, TOOLS_PAINTBUCKET); break; case SP_VERB_CONTEXT_ERASER: - tools_switch_current(TOOLS_ERASER); + tools_switch(dt, TOOLS_ERASER); break; case SP_VERB_CONTEXT_LPETOOL: - tools_switch_current(TOOLS_LPETOOL); + tools_switch(dt, TOOLS_LPETOOL); break; case SP_VERB_CONTEXT_SELECT_PREFS: @@ -1702,6 +1701,9 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) dt->fullscreen(); break; #endif /* HAVE_GTK_WINDOW_FULLSCREEN */ + case SP_VERB_FOCUSTOGGLE: + dt->focusMode(!dt->is_focusMode()); + break; case SP_VERB_VIEW_NEW: sp_ui_new_view(); break; @@ -2572,6 +2574,8 @@ Verb *Verb::_base_verbs[] = { new ZoomVerb(SP_VERB_FULLSCREEN, "FullScreen", N_("_Fullscreen"), N_("Stretch this document window to full screen"), "view-fullscreen"), #endif /* HAVE_GTK_WINDOW_FULLSCREEN */ + new ZoomVerb(SP_VERB_FOCUSTOGGLE, "FocusToggle", N_("Toggle _Focus Mode"), N_("Remove excess toolbars to focus on drawing"), + NULL), new ZoomVerb(SP_VERB_VIEW_NEW, "ViewNew", N_("Duplic_ate Window"), N_("Open a new window with the same document"), "window-new"), new ZoomVerb(SP_VERB_VIEW_NEW_PREVIEW, "ViewNewPreview", N_("_New View Preview"), diff --git a/src/verbs.h b/src/verbs.h index 2362f23aa..8ae12f422 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -205,6 +205,7 @@ enum { #ifdef HAVE_GTK_WINDOW_FULLSCREEN SP_VERB_FULLSCREEN, #endif /* HAVE_GTK_WINDOW_FULLSCREEN */ + SP_VERB_FOCUSTOGGLE, SP_VERB_VIEW_NEW, SP_VERB_VIEW_NEW_PREVIEW, SP_VERB_VIEW_MODE_NORMAL, diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index aae34ed98..f7e2c3f27 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1194,48 +1194,72 @@ sp_desktop_widget_fullscreen(SPDesktopWidget *dtw) void sp_desktop_widget_layout (SPDesktopWidget *dtw) { - bool fullscreen = dtw->desktop->is_fullscreen(); + gchar * pref_path = NULL; + gchar const * pref_root = NULL; + + if (dtw->desktop->is_focusMode()) { + pref_root = "focus."; + } else if (dtw->desktop->is_fullscreen()) { + pref_root = "fullscreen."; + } else { + pref_root = "window."; + } + + pref_path = g_strconcat(pref_root, "menu", NULL); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (!prefs->getBool(( fullscreen ? "fullscreen.menu" : "window.menu" ), "state", true)) { + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->menubar); } else { gtk_widget_show_all (dtw->menubar); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.commands" : "window.commands" ), "state", true)) { + pref_path = g_strconcat(pref_root, "commands", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->commands_toolbox); } else { gtk_widget_show_all (dtw->commands_toolbox); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.toppanel" : "window.toppanel" ), "state", true)) { + pref_path = g_strconcat(pref_root, "toppanel", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->aux_toolbox); } else { // we cannot just show_all because that will show all tools' panels; // this is a function from toolbox.cpp that shows only the current tool's panel show_aux_toolbox (dtw->aux_toolbox); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.toolbox" : "window.toolbox" ), "state", true)) { + pref_path = g_strconcat(pref_root, "toolbox", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->tool_toolbox); } else { gtk_widget_show_all (dtw->tool_toolbox); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.statusbar" : "window.statusbar" ), "state", true)) { + pref_path = g_strconcat(pref_root, "statusbar", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->statusbar); } else { gtk_widget_show_all (dtw->statusbar); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.panels" : "window.panels" ), "state", true)) { + pref_path = g_strconcat(pref_root, "panels", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all( dtw->panels ); } else { gtk_widget_show_all( dtw->panels ); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.scrollbars" : "window.scrollbars" ), "state", true)) { + pref_path = g_strconcat(pref_root, "scrollbars", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->hscrollbar); gtk_widget_hide_all (dtw->vscrollbar_box); gtk_widget_hide_all( dtw->cms_adjust ); @@ -1244,14 +1268,19 @@ sp_desktop_widget_layout (SPDesktopWidget *dtw) gtk_widget_show_all (dtw->vscrollbar_box); gtk_widget_show_all( dtw->cms_adjust ); } + g_free(pref_path); - if (!prefs->getBool(( fullscreen ? "fullscreen.rulers" : "window.rulers" ), "state", true)) { + pref_path = g_strconcat(pref_root, "rulers", NULL); + if (!prefs->getBool(pref_path, "state", true)) { gtk_widget_hide_all (dtw->hruler); gtk_widget_hide_all (dtw->vruler); } else { gtk_widget_show_all (dtw->hruler); gtk_widget_show_all (dtw->vruler); } + g_free(pref_path); + + return; } void diff --git a/src/widgets/sp-xmlview-attr-list.h b/src/widgets/sp-xmlview-attr-list.h index c6ac75d27..8e7b844d0 100644 --- a/src/widgets/sp-xmlview-attr-list.h +++ b/src/widgets/sp-xmlview-attr-list.h @@ -13,8 +13,8 @@ */ #include +#include #include -#include #include "../xml/repr.h"