summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fd0c33e)
raw | patch | inline | side by side (parent: fd0c33e)
author | Jon A. Cruz <jon@joncruz.org> | |
Wed, 16 Jun 2010 06:35:11 +0000 (23:35 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Wed, 16 Jun 2010 06:35:11 +0000 (23:35 -0700) |
diff --git a/src/interface.cpp b/src/interface.cpp
index 1a6da5635d5ae2fbbc70bc19fc2bd419ef73c36e..9e0866bc15711780e4749585127465822000b3e0 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
#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
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 0a9aa27510fdfffa1ef5e514c24b7751930337f7..4e4c45b8c474232de1b44ae9fe593a9a7b189f97 100644 (file)
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
" <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"
index 73e7bd2ac72b95abfcf0d32193a66272b2dbb5ac..c334ae31e1886fa7c99ade33a9ede2982b542e2e 100644 (file)
" 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"
" <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"
" <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"
" 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 ae4de62e368351c1b6b41ccc906fe3c8bcda065a..fbe000de9e66dad4fc10dd82a70b3cc083899886 100644 (file)
--- a/src/ui/uxmanager.cpp
+++ b/src/ui/uxmanager.cpp
#include <algorithm>
#include "uxmanager.h"
+#include "desktop.h"
#include "util/ege-tags.h"
#include "widgets/toolbox.h"
#include "widgets/desktop-widget.h"
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 {
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;
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) {
gboolean notDone = Inkscape::Preferences::get()->getBool("/options/workarounds/dynamicnotdone", false);
if (dtw->desktop == dt) {
+ int taskNum = val;
switch (val) {
default:
case 0:
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);
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 7f7cc6ecb3a52cdabaf214b2272cc097cc10fece..5fef08f11d01fad79c5c621e56fc3dc6c223116c 100644 (file)
--- a/src/ui/uxmanager.h
+++ b/src/ui/uxmanager.h
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;
index ab440595f24e0e6a06c12e934cb8aa2e3698c4fa..36047e81bec4260ad607ed83466672c5d69cee0c 100644 (file)
{
SPDesktopWidget* dtw = SPDesktopWidget::createInstance(namedview);
- UXManager::getInstance()->addTrack(dtw);
-
return SP_VIEW_WIDGET(dtw);
}
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;
}
index 68f7e097242d5ac1dac0081f4d15331a5598b08f..c255e087bb491484aa365daae1b5f089aab26967 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#include "toolbox.h"
-#define ENABLE_TASK_SUPPORT 1
//#define DEBUG_TEXT
using Inkscape::UnitTracker;
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;
}
" <separator />"
" <toolitem action='DialogPreferences' />"
" <toolitem action='DialogDocumentProperties' />"
-#if ENABLE_TASK_SUPPORT
- " <separator />"
- " <toolitem action='TaskSetAction' />"
-#endif // ENABLE_TASK_SUPPORT
" </toolbar>"
"</ui>";