comparison src/layout.c @ 1473:01693e68707b

layout id "_current_" matches the currently active layout window
author nadvornik
date Sat, 21 Mar 2009 19:51:07 +0000
parents 38925ff71a46
children 077924265c28
comparison
equal deleted inserted replaced
1472:b4001cb9fbc4 1473:01693e68707b
57 57
58 #define PANE_DIVIDER_SIZE 10 58 #define PANE_DIVIDER_SIZE 10
59 59
60 60
61 GList *layout_window_list = NULL; 61 GList *layout_window_list = NULL;
62 62 LayoutWindow *current_lw = NULL;
63 63
64 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle); 64 static void layout_list_scroll_to_subpart(LayoutWindow *lw, const gchar *needle);
65 65
66 66
67 /* 67 /*
72 72
73 gboolean layout_valid(LayoutWindow **lw) 73 gboolean layout_valid(LayoutWindow **lw)
74 { 74 {
75 if (*lw == NULL) 75 if (*lw == NULL)
76 { 76 {
77 if (layout_window_list) *lw = layout_window_list->data; 77 if (current_lw) *lw = current_lw;
78 else if (layout_window_list) *lw = layout_window_list->data;
78 return (*lw != NULL); 79 return (*lw != NULL);
79 } 80 }
80
81 return (g_list_find(layout_window_list, *lw) != NULL); 81 return (g_list_find(layout_window_list, *lw) != NULL);
82 } 82 }
83 83
84 LayoutWindow *layout_find_by_image(ImageWindow *imd) 84 LayoutWindow *layout_find_by_image(ImageWindow *imd)
85 { 85 {
117 LayoutWindow *layout_find_by_layout_id(const gchar *id) 117 LayoutWindow *layout_find_by_layout_id(const gchar *id)
118 { 118 {
119 GList *work; 119 GList *work;
120 120
121 if (!id || !id[0]) return NULL; 121 if (!id || !id[0]) return NULL;
122
123 if (strcmp(id, LAYOUT_ID_CURRENT) == 0)
124 {
125 if (current_lw) return current_lw;
126 if (layout_window_list) return layout_window_list->data;
127 return NULL;
128 }
129
122 work = layout_window_list; 130 work = layout_window_list;
123 while (work) 131 while (work)
124 { 132 {
125 LayoutWindow *lw = work->data; 133 LayoutWindow *lw = work->data;
126 work = work->next; 134 work = work->next;
156 lw->options.id = g_strdup(id); 164 lw->options.id = g_strdup(id);
157 return; 165 return;
158 } 166 }
159 i++; 167 i++;
160 } 168 }
169 }
170
171 static gboolean layout_set_current_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
172 {
173 LayoutWindow *lw = data;
174 current_lw = lw;
175 return FALSE;
161 } 176 }
162 177
163 /* 178 /*
164 *----------------------------------------------------------------------------- 179 *-----------------------------------------------------------------------------
165 * menu, toolbar, and dir view 180 * menu, toolbar, and dir view
2201 void layout_free(LayoutWindow *lw) 2216 void layout_free(LayoutWindow *lw)
2202 { 2217 {
2203 if (!lw) return; 2218 if (!lw) return;
2204 2219
2205 layout_window_list = g_list_remove(layout_window_list, lw); 2220 layout_window_list = g_list_remove(layout_window_list, lw);
2221 if (current_lw == lw) current_lw = NULL;
2206 2222
2207 if (lw->exif_window) g_signal_handlers_disconnect_matched(G_OBJECT(lw->exif_window), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, lw); 2223 if (lw->exif_window) g_signal_handlers_disconnect_matched(G_OBJECT(lw->exif_window), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, lw);
2208 2224
2209 layout_bars_close(lw); 2225 layout_bars_close(lw);
2210 2226
2318 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT); 2334 gtk_window_set_default_size(GTK_WINDOW(lw->window), MAINWINDOW_DEF_WIDTH, MAINWINDOW_DEF_HEIGHT);
2319 } 2335 }
2320 2336
2321 g_signal_connect(G_OBJECT(lw->window), "delete_event", 2337 g_signal_connect(G_OBJECT(lw->window), "delete_event",
2322 G_CALLBACK(layout_delete_cb), lw); 2338 G_CALLBACK(layout_delete_cb), lw);
2339
2340 g_signal_connect(G_OBJECT(lw->window), "focus-in-event",
2341 G_CALLBACK(layout_set_current_cb), lw);
2323 2342
2324 layout_keyboard_init(lw, lw->window); 2343 layout_keyboard_init(lw, lw->window);
2325 2344
2326 #ifdef HAVE_LIRC 2345 #ifdef HAVE_LIRC
2327 layout_image_lirc_init(lw); 2346 layout_image_lirc_init(lw);
2439 WRITE_NL(); WRITE_STRING("</layout>"); 2458 WRITE_NL(); WRITE_STRING("</layout>");
2440 } 2459 }
2441 2460
2442 void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values) 2461 void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values)
2443 { 2462 {
2463 gchar *id = NULL;
2444 2464
2445 while (*attribute_names) 2465 while (*attribute_names)
2446 { 2466 {
2447 const gchar *option = *attribute_names++; 2467 const gchar *option = *attribute_names++;
2448 const gchar *value = *attribute_values++; 2468 const gchar *value = *attribute_values++;
2449 2469
2450 /* layout options */ 2470 /* layout options */
2451 if (READ_CHAR(*layout, id)) continue; 2471 if (READ_CHAR_FULL("id", id)) continue;
2452 2472
2453 if (READ_INT(*layout, style)) continue; 2473 if (READ_INT(*layout, style)) continue;
2454 if (READ_CHAR(*layout, order)) continue; 2474 if (READ_CHAR(*layout, order)) continue;
2455 2475
2456 if (READ_UINT(*layout, dir_view_type)) continue; 2476 if (READ_UINT(*layout, dir_view_type)) continue;
2488 if (READ_INT(*layout, image_overlay.histogram_channel)) continue; 2508 if (READ_INT(*layout, image_overlay.histogram_channel)) continue;
2489 if (READ_INT(*layout, image_overlay.histogram_mode)) continue; 2509 if (READ_INT(*layout, image_overlay.histogram_mode)) continue;
2490 2510
2491 log_printf("unknown attribute %s = %s\n", option, value); 2511 log_printf("unknown attribute %s = %s\n", option, value);
2492 } 2512 }
2493 2513 if (id && strcmp(id, LAYOUT_ID_CURRENT) != 0)
2514 {
2515 g_free(layout->id);
2516 layout->id = id;
2517 }
2518 else
2519 {
2520 g_free(id);
2521 }
2494 } 2522 }
2495 2523
2496 static void layout_config_commandline(LayoutOptions *lop, gchar **path) 2524 static void layout_config_commandline(LayoutOptions *lop, gchar **path)
2497 { 2525 {
2498 if (command_line->startup_blank) 2526 if (command_line->startup_blank)