#include "mapcache.h"
#include "print.h"
#include "preferences.h"
+#include "viklayer_defaults.h"
#include "icons/icons.h"
#include "vikexttools.h"
#include "garminsymbols.h"
// why not be allowed to open a thousand more...
#define MAX_WINDOWS 1024
static guint window_count = 0;
+static GSList *window_list = NULL;
#define VIKING_WINDOW_WIDTH 1000
#define VIKING_WINDOW_HEIGHT 800
GtkToolbar *toolbar;
- GtkItemFactory *item_factory;
-
/* tool management state */
guint current_tool;
toolbox_tools_t *vt;
a_background_remove_window ( vw );
+ window_list = g_slist_remove ( window_list, vw );
+
G_OBJECT_CLASS(parent_class)->finalize(gob);
}
VikWindow *vw = VIK_WINDOW (user_data);
GtkWidget *aw = gtk_menu_get_active ( GTK_MENU (menushell) );
- gint active = GPOINTER_TO_INT(gtk_object_get_data ( GTK_OBJECT (aw), "position" ));
+ gint active = GPOINTER_TO_INT(g_object_get_data ( G_OBJECT (aw), "position" ));
gdouble zoom_request = pow (2, active-2 );
GtkWidget *item = gtk_menu_item_new_with_label (itemLabels[i]);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
- gtk_object_set_data (GTK_OBJECT (item), "position", GINT_TO_POINTER(i));
+ g_object_set_data (G_OBJECT (item), "position", GINT_TO_POINTER(i));
}
return menu;
gtk_action_activate ( gtk_action_group_get_action ( vw->action_group, "Pan" ) );
vw->filename = NULL;
- vw->item_factory = NULL;
vw->modified = FALSE;
vw->only_updating_coord_mode_ui = FALSE;
gtk_toolbar_set_icon_size (vw->toolbar, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_toolbar_set_style (vw->toolbar, GTK_TOOLBAR_ICONS);
- vik_ext_tools_add_menu_items ( vw, vw->uim );
-
GtkWidget * zoom_levels = gtk_ui_manager_get_widget (vw->uim, "/MainMenu/View/SetZoom");
GtkWidget * zoom_levels_menu = create_zoom_menu_all_levels ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (zoom_levels), zoom_levels_menu);
a_background_add_window ( vw );
+ window_list = g_slist_prepend ( window_list, vw);
+
vw->open_dia = NULL;
vw->save_dia = NULL;
vw->save_img_dia = NULL;
gint wb, hb, xb, yb;
pl = gtk_widget_create_pango_layout (GTK_WIDGET(vvp), NULL);
- pango_layout_set_font_description (pl, GTK_WIDGET(vvp)->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(GTK_WIDGET(vvp))->font_desc);
pango_layout_set_text(pl, "N", -1);
gdk_draw_layout(d, gc, x1-5, y1-CR-3*CW-8, pl);
vik_coord_to_latlon ( &coord, &ll );
vik_viewport_coord_to_screen ( vvp, &s->oldcoord, &oldx, &oldy );
- gdk_draw_drawable (buf, GTK_WIDGET(vvp)->style->black_gc,
+ gdk_draw_drawable (buf, gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc,
vik_viewport_get_pixmap(vvp), 0, 0, 0, 0, -1, -1);
- draw_ruler(vvp, buf, GTK_WIDGET(vvp)->style->black_gc, oldx, oldy, event->x, event->y, vik_coord_diff( &coord, &(s->oldcoord)) );
+ draw_ruler(vvp, buf, gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc, oldx, oldy, event->x, event->y, vik_coord_diff( &coord, &(s->oldcoord)) );
if (draw_buf_done) {
static gpointer pass_along[3];
pass_along[0] = GTK_WIDGET(vvp)->window;
- pass_along[1] = GTK_WIDGET(vvp)->style->black_gc;
+ pass_along[1] = gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc;
pass_along[2] = buf;
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
draw_buf_done = FALSE;
// Blank out currently drawn area
gdk_draw_drawable ( zts->pixmap,
- GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc,
+ gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc,
vik_viewport_get_pixmap(zts->vw->viking_vvp),
0, 0, 0, 0, -1, -1);
}
// Draw the box
- gdk_draw_rectangle (zts->pixmap, GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc, FALSE, xx, yy, width, height);
+ gdk_draw_rectangle (zts->pixmap, gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc, FALSE, xx, yy, width, height);
// Only actually draw when there's time to do so
if (draw_buf_done) {
static gpointer pass_along[3];
pass_along[0] = GTK_WIDGET(zts->vw->viking_vvp)->window;
- pass_along[1] = GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc;
+ pass_along[1] = gtk_widget_get_style(GTK_WIDGET(zts->vw->viking_vvp))->black_gc;
pass_along[2] = zts->pixmap;
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
draw_buf_done = FALSE;
a_mapcache_flush();
}
+static void layer_defaults_cb ( GtkAction *a, VikWindow *vw )
+{
+ gchar **texts = g_strsplit ( gtk_action_get_name(a), "Layer", 0 );
+
+ if ( !texts[1] )
+ return; // Internally broken :(
+
+ if ( ! a_layer_defaults_show_window ( GTK_WINDOW(vw), texts[1] ) )
+ a_dialog_info_msg ( GTK_WINDOW(vw), _("This layer has no configurable properties.") );
+ // NB no update needed
+
+ g_strfreev ( texts );
+}
+
+static void preferences_change_update ( VikWindow *vw, gpointer data )
+{
+ // Want to update all TrackWaypoint layers
+ GList *layers = vik_layers_panel_get_all_layers_of_type ( vw->viking_vlp, VIK_LAYER_TRW, TRUE );
+
+ GList *iter = g_list_first ( layers );
+ while ( iter ) {
+ // Reset the individual waypoints themselves due to the preferences change
+ VikTrwLayer *vtl = VIK_TRW_LAYER(VIK_LAYER(layers->data));
+ vik_trw_layer_reset_waypoints ( vtl );
+ iter = g_list_next ( iter );
+ }
+
+ g_list_free ( layers );
+
+ draw_update ( vw );
+}
+
static void preferences_cb ( GtkAction *a, VikWindow *vw )
{
gboolean wp_icon_size = a_vik_get_use_large_waypoint_icons();
a_preferences_show_window ( GTK_WINDOW(vw) );
- // Delete icon indexing 'cache' and so automatically regenerates with the new setting when changed
- if (wp_icon_size != a_vik_get_use_large_waypoint_icons())
+ // Has the waypoint size setting changed?
+ if (wp_icon_size != a_vik_get_use_large_waypoint_icons()) {
+ // Delete icon indexing 'cache' and so automatically regenerates with the new setting when changed
clear_garmin_icon_syms ();
- draw_update ( vw );
+ // Update all windows
+ g_slist_foreach ( window_list, (GFunc) preferences_change_update, NULL );
+ }
}
static void default_location_cb ( GtkAction *a, VikWindow *vw )
/* Simplistic repeat of preference setting
Only the name & type are important for setting the preference via this 'external' way */
VikLayerParam pref_lat[] = {
- { VIKING_PREFERENCES_NAMESPACE "default_latitude",
+ { VIK_LAYER_NUM_TYPES,
+ VIKING_PREFERENCES_NAMESPACE "default_latitude",
VIK_LAYER_PARAM_DOUBLE,
VIK_LOCATION_LAT,
NULL,
NULL },
};
VikLayerParam pref_lon[] = {
- { VIKING_PREFERENCES_NAMESPACE "default_longitude",
+ { VIK_LAYER_NUM_TYPES,
+ VIKING_PREFERENCES_NAMESPACE "default_longitude",
VIK_LAYER_PARAM_DOUBLE,
VIK_LOCATION_LONG,
NULL,
{ "MapCacheFlush",NULL, N_("_Flush Map Cache"), NULL, NULL, (GCallback)mapcache_flush_cb },
{ "SetDefaultLocation", GTK_STOCK_GO_FORWARD, N_("_Set the Default Location"), NULL, N_("Set the Default Location to the current position"),(GCallback)default_location_cb },
{ "Preferences",GTK_STOCK_PREFERENCES, N_("_Preferences"), NULL, NULL, (GCallback)preferences_cb },
+ { "LayerDefaults",GTK_STOCK_PROPERTIES, N_("_Layer Defaults"), NULL, NULL, NULL },
{ "Properties",GTK_STOCK_PROPERTIES, N_("_Properties"), NULL, NULL, (GCallback)menu_properties_cb },
{ "HelpEntry", GTK_STOCK_HELP, N_("_Help"), "F1", NULL, (GCallback)help_help_cb },
// Overwrite with actual number to use
radio->value = ntools;
}
+
+ GtkActionEntry action_dl;
+ gtk_ui_manager_add_ui(uim, mid, "/ui/MainMenu/Edit/LayerDefaults",
+ vik_layer_get_interface(i)->name,
+ g_strdup_printf("Layer%s", vik_layer_get_interface(i)->fixed_layer_name),
+ GTK_UI_MANAGER_MENUITEM, FALSE);
+
+ // 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.label = g_strconcat("_", vik_layer_get_interface(i)->name, "...", NULL); // Prepend marker for keyboard accelerator
+ action_dl.accelerator = NULL;
+ action_dl.tooltip = NULL;
+ action_dl.callback = (GCallback)layer_defaults_cb;
+ gtk_action_group_add_actions(action_group, &action_dl, 1, window);
}
g_object_unref (icon_factory);
g_object_set(action, "sensitive", FALSE, NULL);
}
}
+
+ // This is done last so we don't need to track the value of mid anymore
+ vik_ext_tools_add_action_items ( window, window->uim, action_group, mid );
+
window->action_group = action_group;
accel_group = gtk_ui_manager_get_accel_group (uim);