summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9562014)
raw | patch | inline | side by side (parent: 9562014)
author | Jon A. Cruz <jon@joncruz.org> | |
Mon, 4 Jan 2010 10:06:59 +0000 (02:06 -0800) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Mon, 4 Jan 2010 10:06:59 +0000 (02:06 -0800) |
src/widgets/toolbox.cpp | patch | blob | history |
index eddd184ebc2e31ff0ac930c01902340447c80a80..44ad5a6ce013b6a9aef7327b2d23b54087b01da1 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -860,11 +860,11 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, GtkPositionType handlePos )
GtkWidget *sp_tool_toolbox_new()
{
- GtkWidget *tb = gtk_toolbar_new();
- gtk_toolbar_set_orientation(GTK_TOOLBAR(tb), GTK_ORIENTATION_VERTICAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(tb), TRUE);
+ GtkWidget *toolBar = gtk_toolbar_new();
+ gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_VERTICAL);
+ gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
- return toolboxNewCommon( tb, GTK_POS_TOP );
+ return toolboxNewCommon( toolBar, GTK_POS_TOP );
}
GtkWidget *sp_aux_toolbox_new()
@@ -1584,6 +1584,43 @@ toolbox_set_desktop(GtkWidget *toolbox, SPDesktop *desktop, SetupFunction setup_
} // end of toolbox_set_desktop()
+static void setupToolboxCommon( GtkWidget *toolbox,
+ SPDesktop *desktop,
+ gchar const *descr,
+ gchar const* toolbarName,
+ gchar const* sizePref,
+ GtkOrientation orientation )
+{
+ Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ GtkUIManager* mgr = gtk_ui_manager_new();
+ GError* errVal = 0;
+
+ gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
+ gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
+
+ GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName );
+ if ( prefs->getBool("/toolbox/icononly", true) ) {
+ gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
+ }
+
+ Inkscape::IconSize toolboxSize = prefToSize(sizePref);
+ gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
+
+ gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), orientation);
+ gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
+
+ g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
+
+ GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
+ if ( child ) {
+ gtk_container_remove( GTK_CONTAINER(toolbox), child );
+ }
+
+ gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
+}
+
static void
setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
" <toolitem action='ToolDropper' />"
" </toolbar>"
"</ui>";
- Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
- GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
-
- GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/ToolToolbar" );
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
- }
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
-
- gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_VERTICAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
-
- g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
-
- GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
- if ( child ) {
- gtk_container_remove( GTK_CONTAINER(toolbox), child );
- }
- gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
-// Inkscape::IconSize toolboxSize = prefToSize("/toolbox/tools/small");
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/ToolToolbar",
+ "/toolbox/tools/small",
+ GTK_ORIENTATION_VERTICAL );
}
-
static void
update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget */*toolbox*/ )
{
} else {
GtkWidget *sub_toolbox = 0;
- if (aux_toolboxes[i].create_func == NULL)
+ if (aux_toolboxes[i].create_func == NULL) {
sub_toolbox = sp_empty_toolbox_new(desktop);
- else {
+ } else {
sub_toolbox = aux_toolboxes[i].create_func(desktop);
}
" <toolitem action='DialogDocumentProperties' />"
" </toolbar>"
"</ui>";
- Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
-
- gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
-
- GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/CommandsToolbar" );
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
- }
-
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/small");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), (GtkIconSize)toolboxSize );
-
- gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_HORIZONTAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
-
-
- g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
-
- GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
- if ( child ) {
- gtk_container_remove( GTK_CONTAINER(toolbox), child );
- }
- gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/CommandsToolbar",
+ "/toolbox/small",
+ GTK_ORIENTATION_HORIZONTAL );
}
static void
@@ -1958,7 +1948,6 @@ void toggle_snap_callback (GtkToggleAction *act, gpointer data) { //data points
void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions(desktop);
gchar const * descr =
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
}*/
- GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
-
- gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
-
- GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, "/ui/SnapToolbar" );
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
- }
-
- Inkscape::IconSize toolboxSize = prefToSize("/toolbox/secondary");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast<GtkIconSize>(toolboxSize) );
-
- gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), GTK_ORIENTATION_HORIZONTAL);
- gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
-
- g_object_set_data(G_OBJECT(toolBar), "desktop", NULL);
-
- GtkWidget* child = gtk_bin_get_child(GTK_BIN(toolbox));
- if ( child ) {
- gtk_container_remove( GTK_CONTAINER(toolbox), child );
- }
-
- gtk_container_add( GTK_CONTAINER(toolbox), toolBar );
-
+ setupToolboxCommon( toolbox, desktop, descr,
+ "/ui/SnapToolbar",
+ "/toolbox/secondary",
+ GTK_ORIENTATION_HORIZONTAL );
}
void update_snap_toolbox(SPDesktop *desktop, SPEventContext */*eventcontext*/, GtkWidget *toolbox)