#define VIKING_PREFERENCES_STARTUP_GROUP_KEY "viking.startup"
#define VIKING_PREFERENCES_STARTUP_NAMESPACE "viking.startup."
+// Additions to 'Stock Icons'
+#define VIK_ICON_SHOW_PICTURE "vik-icon-Show Picture"
+
G_END_DECLS
#endif
static gboolean dem_layer_download_click ( VikDEMLayer *vdl, GdkEventButton *event, VikViewport *vvp );
static VikToolInterface dem_tools[] = {
- { { "DEMDownload", "vik-icon-DEM Download", N_("_DEM Download"), NULL, N_("DEM Download"), 0 },
+ { &demdl_18_pixbuf,
+ { "DEMDownload", "vik-icon-DEM Download", N_("_DEM Download"), NULL, N_("DEM Download"), 0 },
(VikToolConstructorFunc) dem_layer_download_create, NULL, NULL, NULL,
(VikToolMouseFunc) dem_layer_download_click, NULL, (VikToolMouseFunc) dem_layer_download_release,
(VikToolKeyFunc) NULL,
// See comment in viktrwlayer.c for advice on values used
static VikToolInterface georef_tools[] = {
- { { "GeorefMoveMap", "vik-icon-Georef Move Map", N_("_Georef Move Map"), NULL, N_("Georef Move Map"), 0 },
+ { &geomove_18_pixbuf,
+ { "GeorefMoveMap", "vik-icon-Georef Move Map", N_("_Georef Move Map"), NULL, N_("Georef Move Map"), 0 },
(VikToolConstructorFunc) georef_layer_move_create, NULL, NULL, NULL,
(VikToolMouseFunc) georef_layer_move_press, NULL, (VikToolMouseFunc) georef_layer_move_release,
(VikToolKeyFunc) NULL,
FALSE,
GDK_CURSOR_IS_PIXMAP, &cursor_geomove_pixbuf, NULL },
- { { "GeorefZoomTool", "vik-icon-Georef Zoom Tool", N_("Georef Z_oom Tool"), NULL, N_("Georef Zoom Tool"), 0 },
+ { &geozoom_18_pixbuf,
+ { "GeorefZoomTool", "vik-icon-Georef Zoom Tool", N_("Georef Z_oom Tool"), NULL, N_("Georef Zoom Tool"), 0 },
(VikToolConstructorFunc) georef_layer_zoom_create, NULL, NULL, NULL,
(VikToolMouseFunc) georef_layer_zoom_press, NULL, NULL,
(VikToolKeyFunc) NULL,
typedef struct _VikToolInterface VikToolInterface;
struct _VikToolInterface {
+ const GdkPixdata *icon;
GtkRadioActionEntry radioActionEntry;
VikToolConstructorFunc create;
VikToolDestructorFunc destroy;
static VikToolInterface mapnik_tools[] = {
// Layer Info
// Zoom All?
- { { "MapnikFeatures", GTK_STOCK_INFO, N_("_Mapnik Features"), NULL, N_("Mapnik Features"), 0 },
+ { NULL,
+ { "MapnikFeatures", GTK_STOCK_INFO, N_("_Mapnik Features"), NULL, N_("Mapnik Features"), 0 },
(VikToolConstructorFunc) mapnik_feature_create,
NULL,
NULL,
}
static VikToolInterface maps_tools[] = {
- { { "MapsDownload", "vik-icon-Maps Download", N_("_Maps Download"), NULL, N_("Maps Download"), 0 },
+ { &mapdl_18_pixbuf,
+ { "MapsDownload", "vik-icon-Maps Download", N_("_Maps Download"), NULL, N_("Maps Download"), 0 },
(VikToolConstructorFunc) maps_layer_download_create,
NULL,
NULL,
// the second N_ text value is used for the button tooltip (i.e. generally don't want an underscore here)
// the value is always set to 0 and the tool loader in VikWindow will set the actual appropriate value used
static VikToolInterface trw_layer_tools[] = {
- { { "CreateWaypoint", "vik-icon-Create Waypoint", N_("Create _Waypoint"), "<control><shift>W", N_("Create Waypoint"), 0 },
+ { &addwp_18_pixbuf,
+ { "CreateWaypoint", "vik-icon-Create Waypoint", N_("Create _Waypoint"), "<control><shift>W", N_("Create Waypoint"), 0 },
(VikToolConstructorFunc) tool_new_waypoint_create, NULL, NULL, NULL,
(VikToolMouseFunc) tool_new_waypoint_click, NULL, NULL, (VikToolKeyFunc) NULL,
FALSE,
GDK_CURSOR_IS_PIXMAP, &cursor_addwp_pixbuf, NULL },
- { { "CreateTrack", "vik-icon-Create Track", N_("Create _Track"), "<control><shift>T", N_("Create Track"), 0 },
+ { &addtr_18_pixbuf,
+ { "CreateTrack", "vik-icon-Create Track", N_("Create _Track"), "<control><shift>T", N_("Create Track"), 0 },
(VikToolConstructorFunc) tool_new_track_create, NULL, NULL, NULL,
(VikToolMouseFunc) tool_new_track_click,
(VikToolMouseMoveFunc) tool_new_track_move,
TRUE, // Still need to handle clicks when in PAN mode to disable the potential trackpoint drawing
GDK_CURSOR_IS_PIXMAP, &cursor_addtr_pixbuf, NULL },
- { { "CreateRoute", "vik-icon-Create Route", N_("Create _Route"), "<control><shift>B", N_("Create Route"), 0 },
+ { &vik_new_route_18_pixbuf,
+ { "CreateRoute", "vik-icon-Create Route", N_("Create _Route"), "<control><shift>B", N_("Create Route"), 0 },
(VikToolConstructorFunc) tool_new_route_create, NULL, NULL, NULL,
(VikToolMouseFunc) tool_new_route_click,
(VikToolMouseMoveFunc) tool_new_track_move, // -\#
TRUE, // Still need to handle clicks when in PAN mode to disable the potential trackpoint drawing
GDK_CURSOR_IS_PIXMAP, &cursor_new_route_pixbuf, NULL },
- { { "ExtendedRouteFinder", "vik-icon-Route Finder", N_("Route _Finder"), "<control><shift>F", N_("Route Finder"), 0 },
+ { &route_finder_18_pixbuf,
+ { "ExtendedRouteFinder", "vik-icon-Route Finder", N_("Route _Finder"), "<control><shift>F", N_("Route Finder"), 0 },
(VikToolConstructorFunc) tool_extended_route_finder_create, NULL, NULL, NULL,
(VikToolMouseFunc) tool_extended_route_finder_click,
(VikToolMouseMoveFunc) tool_new_track_move, // -\#
TRUE, // Still need to handle clicks when in PAN mode to disable the potential trackpoint drawing
GDK_CURSOR_IS_PIXMAP, &cursor_route_finder_pixbuf, NULL },
- { { "EditWaypoint", "vik-icon-Edit Waypoint", N_("_Edit Waypoint"), "<control><shift>E", N_("Edit Waypoint"), 0 },
+ { &edwp_18_pixbuf,
+ { "EditWaypoint", "vik-icon-Edit Waypoint", N_("_Edit Waypoint"), "<control><shift>E", N_("Edit Waypoint"), 0 },
(VikToolConstructorFunc) tool_edit_waypoint_create,
(VikToolDestructorFunc) tool_edit_waypoint_destroy,
NULL, NULL,
FALSE,
GDK_CURSOR_IS_PIXMAP, &cursor_edwp_pixbuf, NULL },
- { { "EditTrackpoint", "vik-icon-Edit Trackpoint", N_("Edit Trac_kpoint"), "<control><shift>K", N_("Edit Trackpoint"), 0 },
+ { &edtr_18_pixbuf,
+ { "EditTrackpoint", "vik-icon-Edit Trackpoint", N_("Edit Trac_kpoint"), "<control><shift>K", N_("Edit Trackpoint"), 0 },
(VikToolConstructorFunc) tool_edit_trackpoint_create,
(VikToolDestructorFunc) tool_edit_trackpoint_destroy,
NULL, NULL,
FALSE,
GDK_CURSOR_IS_PIXMAP, &cursor_edtr_pixbuf, NULL },
- { { "ShowPicture", "vik-icon-Show Picture", N_("Show P_icture"), "<control><shift>I", N_("Show Picture"), 0 },
+ { NULL, // a pixbuf for this one is already made globally available
+ { "ShowPicture", VIK_ICON_SHOW_PICTURE, N_("Show P_icture"), "<control><shift>I", N_("Show Picture"), 0 },
(VikToolConstructorFunc) tool_show_picture_create, NULL, NULL, NULL,
(VikToolMouseFunc) tool_show_picture_click, NULL, NULL, (VikToolKeyFunc) NULL,
FALSE,
static VikToolInterface ruler_tool =
// NB Ctrl+Shift+R is used for Refresh (deemed more important), so use 'U' instead
- { { "Ruler", "vik-icon-ruler", N_("_Ruler"), "<control><shift>U", N_("Ruler Tool"), 2 },
+ { &ruler_18_pixbuf,
+ { "Ruler", "vik-icon-ruler", N_("_Ruler"), "<control><shift>U", N_("Ruler Tool"), 2 },
(VikToolConstructorFunc) ruler_create,
(VikToolDestructorFunc) ruler_destroy,
(VikToolActivationFunc) NULL,
}
static VikToolInterface zoom_tool =
- { { "Zoom", "vik-icon-zoom", N_("_Zoom"), "<control><shift>Z", N_("Zoom Tool"), 1 },
+ { &zoom_18_pixbuf,
+ { "Zoom", "vik-icon-zoom", N_("_Zoom"), "<control><shift>Z", N_("Zoom Tool"), 1 },
(VikToolConstructorFunc) zoomtool_create,
(VikToolDestructorFunc) zoomtool_destroy,
(VikToolActivationFunc) NULL,
}
static VikToolInterface pan_tool =
- { { "Pan", "vik-icon-pan", N_("_Pan"), "<control><shift>P", N_("Pan Tool"), 0 },
+ { &mover_22_pixbuf,
+ { "Pan", "vik-icon-pan", N_("_Pan"), "<control><shift>P", N_("Pan Tool"), 0 },
(VikToolConstructorFunc) pantool_create,
(VikToolDestructorFunc) NULL,
(VikToolActivationFunc) NULL,
}
static VikToolInterface select_tool =
- { { "Select", "vik-icon-select", N_("_Select"), "<control><shift>S", N_("Select Tool"), 3 },
+ { &select_18_pixbuf,
+ { "Select", "vik-icon-select", N_("_Select"), "<control><shift>S", N_("Select Tool"), 3 },
(VikToolConstructorFunc) selecttool_create,
(VikToolDestructorFunc) selecttool_destroy,
(VikToolActivationFunc) NULL,
/***********************************************************************************************
** GUI Creation
***********************************************************************************************/
+typedef struct {
+ const GdkPixdata *data;
+ const gchar *name;
+} icon_definition_t;
+
+static void
+a_register_icon ( GtkIconFactory *icon_factory, icon_definition_t icon )
+{
+ if ( !icon.data ) return;
+ GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf (gdk_pixbuf_from_pixdata ( icon.data, FALSE, NULL ));
+ gtk_icon_factory_add ( icon_factory, icon.name, icon_set );
+ gtk_icon_set_unref ( icon_set );
+}
+
static GtkActionEntry entries[] = {
{ "File", NULL, N_("_File"), 0, 0, 0 },
GError *error;
guint i, j, mid;
GtkIconFactory *icon_factory;
- GtkIconSet *icon_set;
GtkRadioActionEntry *tools = NULL, *radio;
guint ntools;
vik_layer_get_interface(i)->fixed_layer_name,
GTK_UI_MANAGER_MENUITEM, FALSE);
- icon_set = gtk_icon_set_new_from_pixbuf (gdk_pixbuf_from_pixdata (vik_layer_get_interface(i)->icon, FALSE, NULL ));
- gtk_icon_factory_add (icon_factory, vik_layer_get_interface(i)->name, icon_set);
- gtk_icon_set_unref (icon_set);
+ icon_definition_t icon = { vik_layer_get_interface(i)->icon,
+ vik_layer_get_interface(i)->fixed_layer_name };
+ a_register_icon ( icon_factory, icon );
action.name = vik_layer_get_interface(i)->fixed_layer_name;
- action.stock_id = vik_layer_get_interface(i)->name;
+ action.stock_id = vik_layer_get_interface(i)->fixed_layer_name;
action.label = g_strdup_printf( _("New _%s Layer"), _(vik_layer_get_interface(i)->name));
action.accelerator = vik_layer_get_interface(i)->accelerator;
action.tooltip = NULL;
tools = g_renew(GtkRadioActionEntry, tools, ntools+1);
radio = &tools[ntools];
ntools++;
-
+
+ icon_definition_t icon = { vik_layer_get_interface(i)->tools[j].icon,
+ vik_layer_get_interface(i)->tools[j].radioActionEntry.stock_id };
+ a_register_icon ( icon_factory, icon );
+
gtk_ui_manager_add_ui(uim, mid, "/ui/MainMenu/Tools",
vik_layer_get_interface(i)->tools[j].radioActionEntry.label,
vik_layer_get_interface(i)->tools[j].radioActionEntry.name,
// For default layers use action names of the form 'Layer<LayerName>'
// This is to avoid clashing with just the layer name used above for the tool actions
action_dl.name = g_strconcat("Layer", vik_layer_get_interface(i)->fixed_layer_name, NULL);
- action_dl.stock_id = NULL;
+ action_dl.stock_id = vik_layer_get_interface(i)->fixed_layer_name;
action_dl.label = g_strconcat(_(vik_layer_get_interface(i)->name), _("..."), NULL);
action_dl.accelerator = NULL;
action_dl.tooltip = NULL;
}
}
-
-// TODO - add method to add tool icons defined from outside this file
-// and remove the reverse dependency on icon definition from this file
-static struct {
- const GdkPixdata *data;
- gchar *stock_id;
-} stock_icons[] = {
+static icon_definition_t vik_icons[] = {
+ // Vikwindow specific icons:
{ &mover_22_pixbuf, "vik-icon-pan" },
{ &zoom_18_pixbuf, "vik-icon-zoom" },
{ &ruler_18_pixbuf, "vik-icon-ruler" },
{ &select_18_pixbuf, "vik-icon-select" },
- { &vik_new_route_18_pixbuf, "vik-icon-Create Route" },
- { &route_finder_18_pixbuf, "vik-icon-Route Finder" },
- { &demdl_18_pixbuf, "vik-icon-DEM Download" },
- { &showpic_18_pixbuf, "vik-icon-Show Picture" },
- { &addtr_18_pixbuf, "vik-icon-Create Track" },
- { &edtr_18_pixbuf, "vik-icon-Edit Trackpoint" },
- { &addwp_18_pixbuf, "vik-icon-Create Waypoint" },
- { &edwp_18_pixbuf, "vik-icon-Edit Waypoint" },
- { &geozoom_18_pixbuf, "vik-icon-Georef Zoom Tool" },
- { &geomove_18_pixbuf, "vik-icon-Georef Move Map" },
- { &mapdl_18_pixbuf, "vik-icon-Maps Download" },
+ // Generic icons for use anywhere:
+ { &showpic_18_pixbuf, VIK_ICON_SHOW_PICTURE },
};
-
-static gint n_stock_icons = G_N_ELEMENTS (stock_icons);
static void
-register_vik_icons (GtkIconFactory *icon_factory)
+register_vik_icons ( GtkIconFactory *icon_factory )
{
- GtkIconSet *icon_set;
- gint i;
-
- for (i = 0; i < n_stock_icons; i++) {
- icon_set = gtk_icon_set_new_from_pixbuf (gdk_pixbuf_from_pixdata (
- stock_icons[i].data, FALSE, NULL ));
- gtk_icon_factory_add (icon_factory, stock_icons[i].stock_id, icon_set);
- gtk_icon_set_unref (icon_set);
+ for (guint i = 0; i < G_N_ELEMENTS(vik_icons); i++) {
+ a_register_icon ( icon_factory, vik_icons[i] );
}
}