From efab230bdeb40f1e217a0e1b825cb38b685129ea Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 15 Jun 2017 22:08:04 -0400 Subject: Complete to move to using ui files instead of compiled in xml --- src/widgets/toolbox.cpp | 493 +++--------------------------------------------- 1 file changed, 23 insertions(+), 470 deletions(-) (limited to 'src/widgets/toolbox.cpp') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 846321c71..671689716 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -225,390 +225,6 @@ static struct { { NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL } }; -static gchar const * ui_descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - -#if HAVE_POTRACE - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " -#endif - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " -// " " -// " " -// " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - "" -; static Glib::RefPtr create_or_fetch_actions( SPDesktop* desktop ); @@ -1199,7 +815,7 @@ void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop) static void setupToolboxCommon( GtkWidget *toolbox, SPDesktop *desktop, - gchar const *descr, + gchar const *ui_file, gchar const* toolbarName, gchar const* sizePref ) { @@ -1207,18 +823,17 @@ static void setupToolboxCommon( GtkWidget *toolbox, Inkscape::Preferences *prefs = Inkscape::Preferences::get(); GtkUIManager* mgr = gtk_ui_manager_new(); - GError* errVal = 0; + GError* err = 0; GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL; gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 ); - // This isn't good, but it is flexible. - if(descr[0] == '<') { - gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal ); - } else { - char const *filename = get_filename(UI, descr); - gtk_ui_manager_add_ui_from_file( mgr, filename, &errVal ); + char const *filename = get_filename(UI, ui_file); + gtk_ui_manager_add_ui_from_file( mgr, filename, &err ); + if(err) { + g_warning("Failed to load %s: %s", filename, err->message); + return; } GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName ); @@ -1354,9 +969,15 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) GtkSizeGroup* grouper = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); Glib::RefPtr mainActions = create_or_fetch_actions( desktop ); GtkUIManager* mgr = gtk_ui_manager_new(); - GError* errVal = 0; + GError *err = 0; gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 ); - gtk_ui_manager_add_ui_from_string( mgr, ui_descr, -1, &errVal ); + + char const *filename = get_filename(UI, "select-toolbar.ui"); + guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename, &err); + if(err) { + g_warning("Failed to load aux toolbar %s: %s", filename, err->message); + return; + } std::map dataHolders; @@ -1457,49 +1078,10 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { - gchar const * descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - ""; - - setupToolboxCommon( toolbox, desktop, descr, - "/ui/CommandsToolbar", - "/toolbox/small" ); + setupToolboxCommon( toolbox, desktop, + "commands-toolbar.ui", + "/ui/CommandsToolbar", + "/toolbox/small" ); } void update_commands_toolbox(SPDesktop * /*desktop*/, ToolBase * /*eventcontext*/, GtkWidget * /*toolbox*/) @@ -1635,36 +1217,6 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { Glib::RefPtr mainActions = create_or_fetch_actions(desktop); - gchar const * descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - //" " - " " - ""; - Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { @@ -1843,9 +1395,10 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox ); } - setupToolboxCommon( toolbox, desktop, descr, - "/ui/SnapToolbar", - "/toolbox/secondary" ); + setupToolboxCommon( toolbox, desktop, + "snap-toolbar.ui", + "/ui/SnapToolbar", + "/toolbox/secondary" ); } Glib::ustring ToolboxFactory::getToolboxName(GtkWidget* toolbox) -- cgit v1.2.3