David wrote:
> I think we need to make the different setting files accessible within
> Synfig so we can easily load and save different UI setups, tool setups,
> keyboard shortcuts etc.
> People can then easily share and download great setups, enabling
> everyone to contribute (easily, without coding skills) in making Synfig
> easier to use.
> Better setups will hopefully be adopted and you coding developers can
> see how people customize Synfig and can use that in developing a better
> vanilla flavour.
>
> -David
The toolbox is hardcoded in app.cpp, but if it was changed to read
a config-file, it could let users customize it with a file like
$HOME/.synfig/toolbox.lst or C:\Program Files\Synfig\toolbox.lst.
I attached some code that is supposed to do this, but it's very C-ish
and my package manager has outdated libs, so I have not tested it.
~Charlie
diff --git a/synfig-studio/src/gui/app.cpp b/synfig-studio/src/gui/app.cpp
index a02da7e..5d4d33f 100644
--- a/synfig-studio/src/gui/app.cpp
+++ b/synfig-studio/src/gui/app.cpp
@@ -83,6 +83,7 @@
#include "mainwindow.h"
#include "docks/dock_toolbox.h"
#include "onemoment.h"
+#include "loadtools.h"
#include "docks/dockmanager.h"
@@ -1512,32 +1513,34 @@ App::App(const synfig::String& basepath, int *argc, char ***argv):
// Init Tools must be done after load_accel_map() : accelerators keys
// are displayed in toolbox labels
studio_init_cb.task(_("Init Tools..."));
- /* editing tools */
- state_manager->add_state(&state_normal);
- state_manager->add_state(&state_smooth_move);
- state_manager->add_state(&state_scale);
- state_manager->add_state(&state_rotate);
- state_manager->add_state(&state_mirror);
-
- /* geometry */
- state_manager->add_state(&state_circle);
- state_manager->add_state(&state_rectangle);
- state_manager->add_state(&state_star);
- if(!getenv("SYNFIG_DISABLE_POLYGON")) state_manager->add_state(&state_polygon); // Enabled - for working without ducks
- state_manager->add_state(&state_gradient);
-
- /* bline tools */
- state_manager->add_state(&state_bline);
- if(!getenv("SYNFIG_DISABLE_DRAW" )) state_manager->add_state(&state_draw); // Enabled for now. Let's see whether they're good enough yet.
- if(!getenv("SYNFIG_DISABLE_WIDTH" )) state_manager->add_state(&state_width); // Enabled since 0.61.09
- state_manager->add_state(&state_fill);
- state_manager->add_state(&state_eyedrop);
-
- /* other */
- state_manager->add_state(&state_text);
- if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
- state_manager->add_state(&state_zoom);
+ if (!studio::loadtools(state_manager)) {
+ /* editing tools */
+ state_manager->add_state(&state_normal);
+ state_manager->add_state(&state_smooth_move);
+ state_manager->add_state(&state_scale);
+ state_manager->add_state(&state_rotate);
+ state_manager->add_state(&state_mirror);
+
+ /* geometry */
+ state_manager->add_state(&state_circle);
+ state_manager->add_state(&state_rectangle);
+ state_manager->add_state(&state_star);
+ if(!getenv("SYNFIG_DISABLE_POLYGON")) state_manager->add_state(&state_polygon); // Enabled - for working without ducks
+ state_manager->add_state(&state_gradient);
+
+ /* bline tools */
+ state_manager->add_state(&state_bline);
+ if(!getenv("SYNFIG_DISABLE_DRAW" )) state_manager->add_state(&state_draw); // Enabled for now. Let's see whether they're good enough yet.
+ if(!getenv("SYNFIG_DISABLE_WIDTH" )) state_manager->add_state(&state_width); // Enabled since 0.61.09
+ state_manager->add_state(&state_fill);
+ state_manager->add_state(&state_eyedrop);
+
+ /* other */
+ state_manager->add_state(&state_text);
+ if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
+ state_manager->add_state(&state_zoom);
+ }
device_tracker->load_preferences();
// If the default bline width is modified before focus a canvas
#include <cstdio>
#include <cstring>
#include "statemanager.h"
#include "states/state_eyedrop.h"
#include "states/state_normal.h"
#include "states/state_mirror.h"
#include "states/state_draw.h"
#include "states/state_fill.h"
#include "states/state_bline.h"
#include "states/state_polygon.h"
#include "states/state_sketch.h"
#include "states/state_gradient.h"
#include "states/state_circle.h"
#include "states/state_rectangle.h"
#include "states/state_smoothmove.h"
#include "states/state_scale.h"
#include "states/state_star.h"
#include "states/state_text.h"
#include "states/state_width.h"
#include "states/state_rotate.h"
#include "states/state_zoom.h"
#define nelem(x) (sizeof(x) / sizeof(*x))
typedef struct {
char *name;
Smach::state_base *state;
} Tool;
static void chomp(char *s);
static FILE *opencfg(char *name);
static void
chomp(char *s)
{
char *nl = strchr(s, '\n');
if (nl) {
*nl = '\0';
}
}
static FILE *
opencfg(char *name, char *mode)
{
char fullname[128];
FILE *f;
if (getenv("HOME")) {
#ifdef __APPLE__
snprintf(fullname, sizeof(fullname), "%s/Library/Synfig/%s", getenv("HOME"), name);
#else
snprintf(fullname, sizeof(fullname), "%s/.synfig/%s", getenv("HOME");
#endif
} else {
#ifdef WIN32
snprintf(fullname, sizeof(fullname), "C:\\Program Files\\Synfig\\%s", name);
#else
snprintf(fullname, sizeof(fullname), "%s", name);
#endif
}
f = fopen(fullname, mode);
return f;
}
void
studio::loadtools(studio::StateManager *mgr)
{
FILE *f;
int i;
char s[32];
Tool tools[] = {
{ "Normal", &state_normal },
{ "Drag", &state_smooth_move },
{ "Scale", &state_scale },
{ "Rotate", &state_rotate },
{ "Mirror", &state_mirror },
{ "Circle", &state_circle },
{ "Rect", &state_rectangle },
{ "Star", &state_star },
{ "Polygon", &state_polygon },
{ "Gradient", &state_gradient },
{ "BLine", &state_bline },
{ "Draw", &state_draw },
{ "Width", &state_width },
{ "Fill", &state_fill },
{ "Eyedrop", &state_eyedrop },
{ "Text", &state_text },
{ "Zoom", &state_zoom },
};
f = opencfg("toolbox.lst", "r");
if (!f) {
return FALSE;
}
while (fgets(s, sizeof(s), f)) {
chomp(s);
for (i = 0; i < nelem(tools); i++) {
if (strcmp(s, tools[i].name) == 0) {
mgr->add_state(tools[i].state);
break;
}
}
}
fclose(f);
return TRUE;
}
#ifndef STUDIO_LOADTOOLS_H
#define STUDIO_LOADTOOLS_H 1
#include "statemanager.h"
void studio::loadtools(studio::StateManager *mgr);
#endif
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl