summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2010-06-16 06:35:11 +0000
committerJon A. Cruz <jon@joncruz.org>2010-06-16 06:35:11 +0000
commitde71f527765af3f177bfab6cbf74d26746ad7b32 (patch)
tree4dfbf179076fd75a8440f06b300580c2203c67d5 /src
parent* [INTL:pl] Final touches on the Polish translation (diff)
downloadinkscape-de71f527765af3f177bfab6cbf74d26746ad7b32.tar.gz
inkscape-de71f527765af3f177bfab6cbf74d26746ad7b32.zip
Move the task view changing to the "View" menu. Fixes bugs #170781 and #171663.
Fixed bugs: - https://launchpad.net/bugs/170781 - https://launchpad.net/bugs/171663 (bzr r9503)
Diffstat (limited to 'src')
-rw-r--r--src/interface.cpp99
-rw-r--r--src/menus-skeleton.h2
-rw-r--r--src/preferences-skeleton.h7
-rw-r--r--src/ui/uxmanager.cpp52
-rw-r--r--src/ui/uxmanager.h3
-rw-r--r--src/widgets/desktop-widget.cpp6
-rw-r--r--src/widgets/toolbox.cpp51
7 files changed, 135 insertions, 85 deletions
diff --git a/src/interface.cpp b/src/interface.cpp
index 1a6da5635..9e0866bc1 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -53,6 +53,7 @@
#include "io/sys.h"
#include "dialogs/dialog-events.h"
#include "message-context.h"
+#include "ui/uxmanager.h"
// Added for color drag-n-drop
#if ENABLE_LCMS
@@ -634,20 +635,28 @@ sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb *verb, Inkscape::
} // end of sp_ui_menu_append_item_from_verb
-static void
-checkitem_toggled(GtkCheckMenuItem *menuitem, gpointer user_data)
+static Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view )
{
- gchar const *pref = (gchar const *) user_data;
- Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
+ Glib::ustring prefPath;
- Glib::ustring pref_path;
if (reinterpret_cast<SPDesktop*>(view)->is_focusMode()) {
- pref_path = "/focus/";
+ prefPath = "/focus/";
} else if (reinterpret_cast<SPDesktop*>(view)->is_fullscreen()) {
- pref_path = "/fullscreen/";
+ prefPath = "/fullscreen/";
} else {
- pref_path = "/window/";
+ prefPath = "/window/";
}
+
+ return prefPath;
+}
+
+static void
+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");
+
+ Glib::ustring pref_path = getLayoutPrefPath( view );
pref_path += pref;
pref_path += "/state";
@@ -666,12 +675,9 @@ checkitem_update(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_dat
gchar const *pref = (gchar const *) user_data;
Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
- Glib::ustring pref_path;
- if ((static_cast<SPDesktop*>(view))->is_fullscreen()) {
- pref_path = "/fullscreen/";
- } else {
- pref_path = "/window/";
- }
+ Glib::ustring pref_path = getLayoutPrefPath( view );
+ pref_path += pref;
+ pref_path += "/state";
pref_path += pref;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -684,6 +690,20 @@ checkitem_update(GtkWidget *widget, GdkEventExpose */*event*/, gpointer user_dat
return FALSE;
}
+static void taskToggled(GtkCheckMenuItem *menuitem, gpointer userData)
+{
+ if ( gtk_check_menu_item_get_active(menuitem) ) {
+ gint taskNum = GPOINTER_TO_INT(userData);
+ taskNum = (taskNum < 0) ? 0 : (taskNum > 2) ? 2 : taskNum;
+
+ Inkscape::UI::View::View *view = (Inkscape::UI::View::View *) g_object_get_data(G_OBJECT(menuitem), "view");
+
+ // note: this will change once more options are in the task set support:
+ Inkscape::UI::UXManager::getInstance()->setTask( dynamic_cast<SPDesktop*>(view), taskNum );
+ }
+}
+
+
/**
* \brief Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline)
*/
@@ -731,15 +751,9 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
gboolean (*callback_update)(GtkWidget *widget, GdkEventExpose *event, gpointer user_data),
Inkscape::Verb *verb)
{
- GtkWidget *item;
-
- unsigned int shortcut = 0;
- SPAction *action = NULL;
-
- if (verb) {
- shortcut = sp_shortcut_get_primary(verb);
- action = verb->get_action(view);
- }
+ unsigned int shortcut = (verb) ? sp_shortcut_get_primary(verb) : 0;
+ SPAction *action = (verb) ? verb->get_action(view) : 0;
+ GtkWidget *item = gtk_check_menu_item_new();
if (verb && shortcut) {
gchar c[256];
@@ -761,12 +775,10 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *
gtk_widget_show_all(hb);
- item = gtk_check_menu_item_new();
gtk_container_add((GtkContainer *) item, hb);
} else {
GtkWidget *l = gtk_label_new_with_mnemonic(action ? action->name : label);
gtk_misc_set_alignment((GtkMisc *) l, 0.0, 0.5);
- item = gtk_check_menu_item_new();
gtk_container_add((GtkContainer *) item, l);
}
#if 0
@@ -887,6 +899,39 @@ sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view)
checkitem_toggled, checkitem_update, 0);
}
+
+void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view)
+{
+ gchar const* data[] = {
+ _("Default"), _("Default interface setup"),
+ _("Custom"), _("Set the custom task"),
+ _("Wide"), _("Setup for widescreen work."),
+ 0, 0
+ };
+
+ GSList *group = 0;
+ int count = 0;
+ gint active = Inkscape::UI::UXManager::getInstance()->getDefaultTask( dynamic_cast<SPDesktop*>(view) );
+ for (gchar const **strs = data; strs[0]; strs += 2, count++)
+ {
+ GtkWidget *item = gtk_radio_menu_item_new_with_label( group, strs[0] );
+ group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) );
+ if ( count == active )
+ {
+ gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item), TRUE );
+ }
+
+ g_object_set_data( G_OBJECT(item), "view", 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]) );
+ g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), 0 );
+
+ gtk_widget_show( item );
+ gtk_menu_shell_append( GTK_MENU_SHELL(menu), item );
+ }
+}
+
+
/** @brief Observer that updates the recent list's max document count */
class MaxRecentObserver : public Inkscape::Preferences::Observer {
public:
@@ -1012,6 +1057,10 @@ sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, Inkscape::UI:
sp_ui_checkboxes_menus(GTK_MENU(menu), view);
continue;
}
+ if (!strcmp(menu_pntr->name(), "task-checkboxes")) {
+ addTaskMenuItems(GTK_MENU(menu), view);
+ continue;
+ }
}
}
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 0a9aa2751..4e4c45b8c 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -133,6 +133,8 @@ static char const menus_skeleton[] =
" <verb verb-id=\"ViewNew\" />\n"
" <separator/>\n"
" <verb verb-id=\"FullScreen\" />\n"
+" <separator/>\n"
+" <task-checkboxes/>\n"
// Not quite ready to be in the menus.
// " <verb verb-id=\"FocusToggle\" />\n"
" </submenu>\n"
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 73e7bd2ac..c334ae31e 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -17,6 +17,7 @@ static char const preferences_skeleton[] =
" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n"
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\">\n"
" <group id=\"window\">\n"
+" <group id=\"task\" />\n"
" <group id=\"menu\" state=\"1\"/>\n"
" <group id=\"commands\" state=\"1\"/>\n"
" <group id=\"snaptoolbox\" state=\"1\"/>\n"
@@ -28,6 +29,7 @@ static char const preferences_skeleton[] =
" <group id=\"scrollbars\" state=\"1\"/>\n"
" </group>\n"
" <group id=\"fullscreen\">\n"
+" <group id=\"task\" />\n"
" <group id=\"menu\" state=\"1\"/>\n"
" <group id=\"commands\" state=\"1\"/>\n"
" <group id=\"snaptoolbox\" state=\"1\"/>\n"
@@ -39,6 +41,7 @@ static char const preferences_skeleton[] =
" <group id=\"scrollbars\" state=\"1\"/>\n"
" </group>\n"
" <group id=\"focus\">\n"
+" <group id=\"task\" />\n"
" <group id=\"menu\" state=\"0\"/>\n"
" <group id=\"commands\" state=\"0\"/>\n"
" <group id=\"snaptoolbox\" state=\"0\"/>\n"
@@ -397,6 +400,10 @@ static char const preferences_skeleton[] =
" show=\"1\"\n"
" id=\"size16\" />\n"
" <group\n"
+" value=\"22\"\n"
+" show=\"0\"\n"
+" id=\"size22\" />\n"
+" <group\n"
" value=\"24\"\n"
" show=\"1\"\n"
" id=\"size24\" />\n"
diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp
index ae4de62e3..fbe000de9 100644
--- a/src/ui/uxmanager.cpp
+++ b/src/ui/uxmanager.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include "uxmanager.h"
+#include "desktop.h"
#include "util/ege-tags.h"
#include "widgets/toolbox.h"
#include "widgets/desktop-widget.h"
@@ -39,6 +40,24 @@ static vector<SPDesktopWidget*> dtws;
static map<SPDesktop*, vector<GtkWidget*> > trackedBoxes;
+namespace {
+// TODO unify this later:
+static Glib::ustring getLayoutPrefPath( Inkscape::UI::View::View *view )
+{
+ Glib::ustring prefPath;
+
+ if (reinterpret_cast<SPDesktop*>(view)->is_focusMode()) {
+ prefPath = "/focus/";
+ } else if (reinterpret_cast<SPDesktop*>(view)->is_fullscreen()) {
+ prefPath = "/fullscreen/";
+ } else {
+ prefPath = "/window/";
+ }
+
+ return prefPath;
+}
+
+}
namespace Inkscape {
namespace UI {
@@ -51,11 +70,14 @@ public:
UXManagerImpl();
virtual ~UXManagerImpl();
- virtual void setTask(SPDesktop* dt, gint val);
virtual void addTrack( SPDesktopWidget* dtw );
virtual void delTrack( SPDesktopWidget* dtw );
+
virtual void connectToDesktop( vector<GtkWidget *> const & toolboxes, SPDesktop *desktop );
+ virtual gint getDefaultTask( SPDesktop *desktop );
+ virtual void setTask(SPDesktop* dt, gint val);
+
virtual bool isFloatWindowProblem() const;
virtual bool isWidescreen() const;
@@ -129,6 +151,17 @@ bool UXManagerImpl::isWidescreen() const
return _widescreen;
}
+gint UXManagerImpl::getDefaultTask( SPDesktop *desktop )
+{
+ gint taskNum = isWidescreen() ? 2 : 0;
+
+ Glib::ustring prefPath = getLayoutPrefPath( desktop );
+ taskNum = Inkscape::Preferences::get()->getInt( prefPath + "task/taskset", taskNum );
+ taskNum = (taskNum < 0) ? 0 : (taskNum > 2) ? 2 : taskNum;
+
+ return taskNum;
+}
+
void UXManagerImpl::setTask(SPDesktop* dt, gint val)
{
for (vector<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it) {
@@ -137,6 +170,7 @@ void UXManagerImpl::setTask(SPDesktop* dt, gint val)
gboolean notDone = Inkscape::Preferences::get()->getBool("/options/workarounds/dynamicnotdone", false);
if (dtw->desktop == dt) {
+ int taskNum = val;
switch (val) {
default:
case 0:
@@ -145,15 +179,16 @@ void UXManagerImpl::setTask(SPDesktop* dt, gint val)
if (notDone) {
dtw->setToolboxPosition("AuxToolbar", GTK_POS_TOP);
}
- dtw->setToolboxPosition("SnapToolbar", GTK_POS_TOP);
+ dtw->setToolboxPosition("SnapToolbar", GTK_POS_RIGHT);
+ taskNum = val; // in case it was out of range
break;
case 1:
- dtw->setToolboxPosition("ToolToolbar", GTK_POS_TOP);
- dtw->setToolboxPosition("CommandsToolbar", GTK_POS_LEFT);
+ dtw->setToolboxPosition("ToolToolbar", GTK_POS_LEFT);
+ dtw->setToolboxPosition("CommandsToolbar", GTK_POS_TOP);
if (notDone) {
dtw->setToolboxPosition("AuxToolbar", GTK_POS_TOP);
}
- dtw->setToolboxPosition("SnapToolbar", GTK_POS_RIGHT);
+ dtw->setToolboxPosition("SnapToolbar", GTK_POS_TOP);
break;
case 2:
dtw->setToolboxPosition("ToolToolbar", GTK_POS_LEFT);
@@ -163,6 +198,8 @@ void UXManagerImpl::setTask(SPDesktop* dt, gint val)
dtw->setToolboxPosition("AuxToolbar", GTK_POS_RIGHT);
}
}
+ Glib::ustring prefPath = getLayoutPrefPath( dtw->desktop );
+ Inkscape::Preferences::get()->setInt( prefPath + "task/taskset", taskNum );
}
}
}
@@ -200,6 +237,11 @@ void UXManagerImpl::connectToDesktop( vector<GtkWidget *> const & toolboxes, SPD
if (std::find(desktops.begin(), desktops.end(), desktop) == desktops.end()) {
desktops.push_back(desktop);
}
+
+ gint taskNum = getDefaultTask( desktop );
+
+ // note: this will change once more options are in the task set support:
+ Inkscape::UI::UXManager::getInstance()->setTask( desktop, taskNum );
}
diff --git a/src/ui/uxmanager.h b/src/ui/uxmanager.h
index 7f7cc6ecb..5fef08f11 100644
--- a/src/ui/uxmanager.h
+++ b/src/ui/uxmanager.h
@@ -39,7 +39,8 @@ public:
virtual void connectToDesktop( std::vector<GtkWidget *> const & toolboxes, SPDesktop *desktop ) = 0;
- virtual void setTask(SPDesktop* dt, gint val) = 0;
+ virtual gint getDefaultTask( SPDesktop *desktop ) = 0;
+ virtual void setTask( SPDesktop* dt, gint val ) = 0;
virtual bool isFloatWindowProblem() const = 0;
virtual bool isWidescreen() const = 0;
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index ab440595f..36047e81b 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -1393,8 +1393,6 @@ SPViewWidget *sp_desktop_widget_new( SPNamedView *namedview )
{
SPDesktopWidget* dtw = SPDesktopWidget::createInstance(namedview);
- UXManager::getInstance()->addTrack(dtw);
-
return SP_VIEW_WIDGET(dtw);
}
@@ -1440,10 +1438,12 @@ SPDesktopWidget* SPDesktopWidget::createInstance(SPNamedView *namedview)
toolboxes.push_back(dtw->aux_toolbox);
toolboxes.push_back(dtw->commands_toolbox);
toolboxes.push_back(dtw->snap_toolbox);
- UXManager::getInstance()->connectToDesktop( toolboxes, dtw->desktop );
dtw->panels->setDesktop( dtw->desktop );
+ UXManager::getInstance()->addTrack(dtw);
+ UXManager::getInstance()->connectToDesktop( toolboxes, dtw->desktop );
+
return dtw;
}
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 68f7e0972..c255e087b 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -108,7 +108,6 @@
#include "toolbox.h"
-#define ENABLE_TASK_SUPPORT 1
//#define DEBUG_TEXT
using Inkscape::UnitTracker;
@@ -147,14 +146,6 @@ static void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mai
static void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
static void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
-#if ENABLE_TASK_SUPPORT
-static void fireTaskChange( EgeSelectOneAction *act, SPDesktop *dt )
-{
- gint selected = ege_select_one_action_get_active( act );
- UXManager::getInstance()->setTask(dt, selected);
-}
-#endif // ENABLE_TASK_SUPPORT
-
using Inkscape::UI::ToolboxFactory;
@@ -978,44 +969,6 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
}
}
-#if ENABLE_TASK_SUPPORT
- if ( !mainActions->get_action("TaskSetAction") ) {
- GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_STRING );
-
- GtkTreeIter iter;
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Default"),
- 1, _("Default interface setup"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Custom"),
- 1, _("Set the custom task"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Wide"),
- 1, _("Setup for widescreen work"),
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TaskSetAction", _("Task"), (""), NULL, GTK_TREE_MODEL(model) );
- g_object_set( act, "short_label", _("Task:"), NULL );
- mainActions->add(Glib::wrap(GTK_ACTION(act)));
- //g_object_set_data( holder, "mode_action", act );
-
- ege_select_one_action_set_appearance( act, "minimal" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- //ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
-
- //ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(fireTaskChange), desktop );
- }
-#endif // ENABLE_TASK_SUPPORT
-
return mainActions;
}
@@ -2061,10 +2014,6 @@ void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
" <separator />"
" <toolitem action='DialogPreferences' />"
" <toolitem action='DialogDocumentProperties' />"
-#if ENABLE_TASK_SUPPORT
- " <separator />"
- " <toolitem action='TaskSetAction' />"
-#endif // ENABLE_TASK_SUPPORT
" </toolbar>"
"</ui>";