Mercurial > geeqie
changeset 1582:2ca277a9845b
- handle color profile and write metadata buttons on statusbar by ui_manager
- statusbar buttons made configurable
author | nadvornik |
---|---|
date | Fri, 01 May 2009 23:15:51 +0000 |
parents | c9c1a16ff8ae |
children | 70d59df4d2a2 |
files | src/layout.c src/layout.h src/layout_util.c src/layout_util.h src/metadata.c src/rcfile.c src/rcfile.h src/typedefs.h |
diffstat | 8 files changed, 235 insertions(+), 273 deletions(-) [+] |
line wrap: on
line diff
--- a/src/layout.c Fri May 01 09:49:27 2009 +0000 +++ b/src/layout.c Fri May 01 23:15:51 2009 +0000 @@ -266,6 +266,7 @@ GtkWidget *box; GtkWidget *menu_bar; GtkWidget *tabcomp; + GtkWidget *toolbar; box = gtk_vbox_new(FALSE, 0); @@ -273,9 +274,9 @@ gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0); gtk_widget_show(menu_bar); - layout_actions_toolbar(lw); - gtk_box_pack_start(GTK_BOX(box), lw->toolbar, FALSE, FALSE, 0); - if (!lw->options.toolbar_hidden) gtk_widget_show(lw->toolbar); + toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN); + gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0); + if (!lw->options.toolbar_hidden) gtk_widget_show(toolbar); tabcomp = tab_completion_new_with_history(&lw->path_entry, NULL, "path_list", -1, layout_path_entry_cb, lw); @@ -391,80 +392,12 @@ return button; } -static GtkWidget *layout_color_button(LayoutWindow *lw) -{ - GtkWidget *button; - GtkWidget *image; - - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_SELECT_COLOR, GTK_ICON_SIZE_MENU); - gtk_container_add(GTK_CONTAINER(button), image); - gtk_widget_show(image); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - - gtk_widget_set_sensitive(GTK_BIN(button)->child, FALSE); - - return button; -} -/* - *----------------------------------------------------------------------------- - * write button - *----------------------------------------------------------------------------- - */ - -static void layout_write_button_press_cb(GtkWidget *widget, gpointer data) -{ - metadata_write_queue_confirm(NULL, NULL); -} - -static GtkWidget *layout_write_button(LayoutWindow *lw) -{ - GtkWidget *button; - GtkWidget *image; - - button = gtk_button_new(); - image = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); - gtk_container_add(GTK_CONTAINER(button), image); - gtk_widget_show(image); - g_signal_connect(G_OBJECT(button), "clicked", - G_CALLBACK(layout_write_button_press_cb), lw); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); - - gtk_widget_set_sensitive(button, metadata_queue_length() > 0); - - return button; -} - - /* *----------------------------------------------------------------------------- * status bar *----------------------------------------------------------------------------- */ -void layout_status_update_write(LayoutWindow *lw) -{ - if (!layout_valid(&lw)) return; - if (!lw->info_write) return; - - gtk_widget_set_sensitive(lw->info_write, metadata_queue_length() > 0); - /* FIXME: maybe show also the number of files */ -} - -void layout_status_update_write_all(void) -{ - GList *work; - - work = layout_window_list; - while (work) - { - LayoutWindow *lw = work->data; - work = work->next; - - layout_status_update_write(lw); - } -} - void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text) { @@ -550,8 +483,6 @@ void layout_status_update_image(LayoutWindow *lw) { guint64 n; - gchar *image_profile; - gchar *screen_profile; if (!layout_valid(&lw) || !lw->image) return; @@ -600,23 +531,7 @@ gtk_label_set_text(GTK_LABEL(lw->info_details), text); g_free(text); } - - if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile)) - { - gchar *buf; - gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, TRUE); - buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile); - /* FIXME: not sure if a tooltip is the best form of presentation */ - gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), buf); - g_free(image_profile); - g_free(screen_profile); - g_free(buf); - } - else - { - gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, FALSE); - gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), NULL); - } + layout_util_sync_color(lw); /* update color button */ } void layout_status_update_all(LayoutWindow *lw) @@ -624,7 +539,7 @@ layout_status_update_progress(lw, 0.0, NULL); layout_status_update_info(lw, NULL); layout_status_update_image(lw); - layout_status_update_write(lw); + layout_util_status_update_write(lw); } static GtkWidget *layout_status_label(gchar *text, GtkWidget *box, gboolean start, gint size, gboolean expand) @@ -655,6 +570,8 @@ static void layout_status_setup(LayoutWindow *lw, GtkWidget *box, gboolean small_format) { GtkWidget *hbox; + GtkWidget *toolbar; + GtkWidget *toolbar_frame; if (lw->info_box) return; @@ -688,14 +605,15 @@ gtk_box_pack_start(GTK_BOX(hbox), lw->info_sort, FALSE, FALSE, 0); gtk_widget_show(lw->info_sort); - lw->info_color = layout_color_button(lw); - gtk_widget_show(lw->info_color); - - lw->info_write = layout_write_button(lw); - gtk_widget_show(lw->info_write); - - if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); - if (small_format) gtk_box_pack_end(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); + toolbar = layout_actions_toolbar(lw, TOOLBAR_STATUS); + + toolbar_frame = gtk_frame_new(NULL); + gtk_frame_set_shadow_type(GTK_FRAME(toolbar_frame), GTK_SHADOW_IN); + gtk_container_add(GTK_CONTAINER(toolbar_frame), toolbar); + gtk_widget_show(toolbar_frame); + gtk_widget_show(toolbar); + + if (small_format) gtk_box_pack_end(GTK_BOX(hbox), toolbar_frame, FALSE, FALSE, 0); lw->info_status = layout_status_label(NULL, lw->info_box, TRUE, 0, (!small_format)); @@ -710,8 +628,7 @@ hbox = lw->info_box; } lw->info_details = layout_status_label(NULL, hbox, TRUE, 0, TRUE); - if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_color, FALSE, FALSE, 0); - if (!small_format) gtk_box_pack_start(GTK_BOX(hbox), lw->info_write, FALSE, FALSE, 0); + if (!small_format) gtk_box_pack_end(GTK_BOX(hbox), toolbar_frame, FALSE, FALSE, 0); lw->info_pixel = layout_status_label(NULL, hbox, FALSE, PIXEL_LABEL_WIDTH, TRUE); if (lw->options.info_pixel_hidden) gtk_widget_hide(gtk_widget_get_parent(lw->info_pixel)); lw->info_zoom = layout_status_label(NULL, hbox, FALSE, ZOOM_LABEL_WIDTH, FALSE); @@ -1594,6 +1511,7 @@ void layout_style_set(LayoutWindow *lw, gint style, const gchar *order) { FileData *dir_fd; + gint i; if (!layout_valid(&lw)) return; @@ -1623,11 +1541,12 @@ layout_geometry_get_dividers(lw, &lw->options.main_window.hdivider_pos, &lw->options.main_window.vdivider_pos); - /* preserve utility_box (image + sidebars), menu_bar and toolbar to be reused later in layout_grid_setup */ + /* preserve utility_box (image + sidebars), menu_bar and toolbars to be reused later in layout_grid_setup */ /* lw->image is preserved together with lw->utility_box */ if (lw->utility_box) gtk_container_remove(GTK_CONTAINER(lw->utility_box->parent), lw->utility_box); if (lw->menu_bar) gtk_container_remove(GTK_CONTAINER(lw->menu_bar->parent), lw->menu_bar); - if (lw->toolbar) gtk_container_remove(GTK_CONTAINER(lw->toolbar->parent), lw->toolbar); + for (i = 0; i < TOOLBAR_COUNT; i++) + if (lw->toolbar[i]) gtk_container_remove(GTK_CONTAINER(lw->toolbar[i]->parent), lw->toolbar[i]); /* clear it all */ @@ -1644,7 +1563,6 @@ lw->info_box = NULL; lw->info_progress_bar = NULL; lw->info_sort = NULL; - lw->info_color = NULL; lw->info_status = NULL; lw->info_details = NULL; lw->info_pixel = NULL; @@ -1782,11 +1700,11 @@ if (lw->options.toolbar_hidden) { - if (GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_hide(lw->toolbar); + if (GTK_WIDGET_VISIBLE(lw->toolbar[TOOLBAR_MAIN])) gtk_widget_hide(lw->toolbar[TOOLBAR_MAIN]); } else { - if (!GTK_WIDGET_VISIBLE(lw->toolbar)) gtk_widget_show(lw->toolbar); + if (!GTK_WIDGET_VISIBLE(lw->toolbar[TOOLBAR_MAIN])) gtk_widget_show(lw->toolbar[TOOLBAR_MAIN]); } } @@ -2084,6 +2002,7 @@ void layout_free(LayoutWindow *lw) { + gint i; if (!lw) return; layout_window_list = g_list_remove(layout_window_list, lw); @@ -2094,8 +2013,13 @@ layout_bars_close(lw); g_object_unref(lw->menu_bar); - g_object_unref(lw->toolbar); g_object_unref(lw->utility_box); + + for (i = 0; i < TOOLBAR_COUNT; i++) + { + if (lw->toolbar[i]) g_object_unref(lw->toolbar[i]); + string_list_free(lw->toolbar_actions[i]); + } gtk_widget_destroy(lw->window); @@ -2109,7 +2033,6 @@ file_data_unref(lw->dir_fd); } - string_list_free(lw->toolbar_actions); free_layout_options_content(&lw->options); g_free(lw); } @@ -2325,7 +2248,8 @@ bar_sort_write_config(lw->bar_sort, outstr, indent + 1); bar_write_config(lw->bar, outstr, indent + 1); - layout_toolbar_write_config(lw, outstr, indent + 1); + layout_toolbar_write_config(lw, TOOLBAR_MAIN, outstr, indent + 1); + layout_toolbar_write_config(lw, TOOLBAR_STATUS, outstr, indent + 1); WRITE_NL(); WRITE_STRING("</layout>"); }
--- a/src/layout.h Fri May 01 09:49:27 2009 +0000 +++ b/src/layout.h Fri May 01 23:15:51 2009 +0000 @@ -51,11 +51,8 @@ void layout_status_update_progress(LayoutWindow *lw, gdouble val, const gchar *text); void layout_status_update_info(LayoutWindow *lw, const gchar *text); void layout_status_update_image(LayoutWindow *lw); -void layout_status_update_write(LayoutWindow *lw); void layout_status_update_all(LayoutWindow *lw); -void layout_status_update_write_all(void); - GList *layout_list(LayoutWindow *lw); guint layout_list_count(LayoutWindow *lw, gint64 *bytes); FileData *layout_list_get_fd(LayoutWindow *lw, gint index);
--- a/src/layout_util.c Fri May 01 09:49:27 2009 +0000 +++ b/src/layout_util.c Fri May 01 23:15:51 2009 +0000 @@ -54,7 +54,6 @@ static gboolean layout_bar_enabled(LayoutWindow *lw); static gboolean layout_bar_sort_enabled(LayoutWindow *lw); -static void layout_util_sync_color(LayoutWindow *lw); /* *----------------------------------------------------------------------------- @@ -1037,6 +1036,11 @@ #endif +static void layout_menu_metadata_write_cb(GtkAction *action, gpointer data) +{ + metadata_write_queue_confirm(NULL, NULL); +} + /* *----------------------------------------------------------------------------- @@ -1088,111 +1092,6 @@ #endif } -#if 0 -static gchar *layout_color_name_parse(const gchar *name) -{ - if (!name || !*name) return g_strdup(_("Empty")); - return g_strdelimit(g_strdup(name), "_", '-'); -} - - -static void layout_color_button_press_cb(GtkWidget *widget, gpointer data) -{ -#ifndef HAVE_LCMS - gchar *msg = g_strdup_printf(_("This installation of %s was not built with support for color profiles."), GQ_APPNAME); - file_util_warning_dialog(_("Color profiles not supported"), - msg, - GTK_STOCK_DIALOG_INFO, widget); - g_free(msg); - return; -#else - LayoutWindow *lw = data; - GtkWidget *menu; - GtkWidget *item; - gchar *buf; - gboolean active; - gint input = 0; - gint screen = 0; - gboolean use_image = FALSE; - gboolean from_image; - gint image_profile; - gint i; - - if (!layout_image_color_profile_get(lw, &input, &screen, &use_image)) return; - - image_profile = layout_image_color_profile_get_from_image(lw); - from_image = use_image && (image_profile != COLOR_PROFILE_NONE); - menu = popup_menu_short_lived(); - - active = layout_image_color_profile_get_use(lw); - menu_item_add_check(menu, _("Use _color profiles"), active, - G_CALLBACK(layout_color_menu_enable_cb), lw); - - menu_item_add_divider(menu); - - item = menu_item_add_check(menu, _("Use profile from _image"), use_image, - G_CALLBACK(layout_color_menu_use_image_cb), lw); - gtk_widget_set_sensitive(item, image_profile == COLOR_PROFILE_MEM || (image_profile > COLOR_PROFILE_NONE && image_profile < COLOR_PROFILE_FILE)); - - for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) - { - const gchar *label; - - switch (i) - { - case COLOR_PROFILE_SRGB: label = _("sRGB"); break; - case COLOR_PROFILE_ADOBERGB: label = _("AdobeRGB compatible"); break; - default: label = "fixme"; break; - } - buf = g_strdup_printf(_("Input _%d: %s%s"), i, label, (i == image_profile) ? " *" : ""); - item = menu_item_add_radio(menu, (i == COLOR_PROFILE_SRGB) ? NULL : item, - buf, (input == i), - G_CALLBACK(layout_color_menu_input_cb), lw); - g_free(buf); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i)); - gtk_widget_set_sensitive(item, active && !from_image); - } - - for (i = 0; i < COLOR_PROFILE_INPUTS; i++) - { - const gchar *name = options->color_profile.input_name[i]; - const gchar *file = options->color_profile.input_file[i]; - gchar *end; - - if (!name || !name[0]) name = filename_from_path(file); - - end = layout_color_name_parse(name); - buf = g_strdup_printf(_("Input _%d: %s"), i + COLOR_PROFILE_FILE, end); - g_free(end); - - item = menu_item_add_radio(menu, item, - buf, (i + COLOR_PROFILE_FILE == input), - G_CALLBACK(layout_color_menu_input_cb), lw); - g_free(buf); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + COLOR_PROFILE_FILE)); - gtk_widget_set_sensitive(item, active && !from_image && is_readable_file(file)); - } - - menu_item_add_divider(menu); - - item = menu_item_add_radio(menu, NULL, - _("Screen sRGB"), (screen == 0), - G_CALLBACK(layout_color_menu_screen_cb), lw); - - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0)); - gtk_widget_set_sensitive(item, active); - - item = menu_item_add_radio(menu, item, - _("_Screen profile"), (screen == 1), - G_CALLBACK(layout_color_menu_screen_cb), lw); - g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1)); - gtk_widget_set_sensitive(item, active && is_readable_file(options->color_profile.screen_file)); - - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); -#endif /* HAVE_LCMS */ -} - -#endif /* *----------------------------------------------------------------------------- @@ -1358,6 +1257,7 @@ { "LayoutConfig",GTK_STOCK_PREFERENCES,N_("_Configure this window..."), NULL, NULL, CB(layout_menu_layout_config_cb) }, { "Maintenance", NULL, N_("_Thumbnail maintenance..."),NULL, NULL, CB(layout_menu_remove_thumb_cb) }, { "Wallpaper", NULL, N_("Set as _wallpaper"),NULL, NULL, CB(layout_menu_wallpaper_cb) }, + { "SaveMetadata", GTK_STOCK_SAVE, N_("Save metadata"),NULL, NULL, CB(layout_menu_metadata_write_cb) }, { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "equal", N_("Zoom in"), CB(layout_menu_zoom_in_cb) }, { "ZoomInAlt1",GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "KP_Add", N_("Zoom in"), CB(layout_menu_zoom_in_cb) }, @@ -1427,7 +1327,7 @@ { "SBar", NULL, N_("_Info"), "<control>K", NULL, CB(layout_menu_bar_cb), FALSE }, { "SBarSort", NULL, N_("Sort _manager"), "<control>S", NULL, CB(layout_menu_bar_sort_cb), FALSE }, { "SlideShow", NULL, N_("Toggle _slideshow"),"S", NULL, CB(layout_menu_slideshow_cb), FALSE }, - { "UseColorProfiles", NULL, N_("Use _color profiles"), NULL, NULL, CB(layout_color_menu_enable_cb), FALSE}, + { "UseColorProfiles", GTK_STOCK_SELECT_COLOR, N_("Use _color profiles"), NULL, NULL, CB(layout_color_menu_enable_cb), FALSE}, { "UseImageProfile", NULL, N_("Use profile from _image"), NULL, NULL, CB(layout_color_menu_use_image_cb), FALSE}, { "Grayscale", NULL, N_("Toggle _grayscale"),"<shift>G", NULL, CB(layout_menu_alter_desaturate_cb), FALSE}, }; @@ -1520,6 +1420,7 @@ " <menuitem action='Flip'/>" " <menuitem action='AlterNone'/>" " </menu>" +" <menuitem action='SaveMetadata'/>" " <placeholder name='PropertiesSection'/>" " <separator/>" " <menuitem action='Preferences'/>" @@ -1634,6 +1535,8 @@ " </menubar>" " <toolbar name='ToolBar'>" " </toolbar>" +" <toolbar name='StatusBar'>" +" </toolbar>" "<accelerator action='PrevImageAlt1'/>" "<accelerator action='PrevImageAlt2'/>" "<accelerator action='NextImageAlt1'/>" @@ -1883,6 +1786,7 @@ void layout_actions_setup(LayoutWindow *lw) { GError *error; + gint i; if (lw->ui_manager) return; @@ -1919,12 +1823,17 @@ exit(EXIT_FAILURE); } - layout_toolbar_clear(lw); - layout_toolbar_add_default(lw); + for (i = 0; i < TOOLBAR_COUNT; i++) + { + layout_toolbar_clear(lw, i); + layout_toolbar_add_default(lw, i); + } layout_actions_setup_marks(lw); layout_actions_setup_editors(lw); + layout_util_status_update_write(lw); + layout_actions_add_window(lw, lw->window); } @@ -1972,59 +1881,110 @@ return lw->menu_bar; } -GtkWidget *layout_actions_toolbar(LayoutWindow *lw) +GtkWidget *layout_actions_toolbar(LayoutWindow *lw, ToolbarType type) { - if (lw->toolbar) return lw->toolbar; - lw->toolbar = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar"); - g_object_ref(lw->toolbar); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar), GTK_TOOLBAR_ICONS); - return lw->toolbar; + if (lw->toolbar[type]) return lw->toolbar[type]; + switch (type) + { + case TOOLBAR_MAIN: + lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/ToolBar"); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS); + break; + case TOOLBAR_STATUS: + lw->toolbar[type] = gtk_ui_manager_get_widget(lw->ui_manager, "/StatusBar"); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(lw->toolbar[type]), GTK_ICON_SIZE_MENU); + gtk_toolbar_set_style(GTK_TOOLBAR(lw->toolbar[type]), GTK_TOOLBAR_ICONS); + gtk_toolbar_set_show_arrow(GTK_TOOLBAR(lw->toolbar[type]), FALSE); + break; + default: + break; + } + g_object_ref(lw->toolbar[type]); + return lw->toolbar[type]; } -void layout_toolbar_clear(LayoutWindow *lw) +void layout_toolbar_clear(LayoutWindow *lw, ToolbarType type) { - if (lw->toolbar_merge_id) + if (lw->toolbar_merge_id[type]) { - gtk_ui_manager_remove_ui(lw->ui_manager, lw->toolbar_merge_id); + gtk_ui_manager_remove_ui(lw->ui_manager, lw->toolbar_merge_id[type]); gtk_ui_manager_ensure_update(lw->ui_manager); } - string_list_free(lw->toolbar_actions); - lw->toolbar_actions = NULL; + string_list_free(lw->toolbar_actions[type]); + lw->toolbar_actions[type] = NULL; - lw->toolbar_merge_id = gtk_ui_manager_new_merge_id(lw->ui_manager); + lw->toolbar_merge_id[type] = gtk_ui_manager_new_merge_id(lw->ui_manager); } -void layout_toolbar_add(LayoutWindow *lw, const gchar *action) +void layout_toolbar_add(LayoutWindow *lw, ToolbarType type, const gchar *action) { + const gchar *path = NULL; if (!action || !lw->ui_manager) return; - if (g_list_find_custom(lw->toolbar_actions, action, (GCompareFunc)strcmp)) return; + if (g_list_find_custom(lw->toolbar_actions[type], action, (GCompareFunc)strcmp)) return; + + switch (type) + { + case TOOLBAR_MAIN: + path = "/ToolBar"; + break; + case TOOLBAR_STATUS: + path = "/StatusBar"; + break; + default: + break; + } - gtk_ui_manager_add_ui(lw->ui_manager, lw->toolbar_merge_id, "/ToolBar", action, action, GTK_UI_MANAGER_TOOLITEM, FALSE); - lw->toolbar_actions = g_list_append(lw->toolbar_actions, g_strdup(action)); + gtk_ui_manager_add_ui(lw->ui_manager, lw->toolbar_merge_id[type], path, action, action, GTK_UI_MANAGER_TOOLITEM, FALSE); + lw->toolbar_actions[type] = g_list_append(lw->toolbar_actions[type], g_strdup(action)); } -void layout_toolbar_add_default(LayoutWindow *lw) +void layout_toolbar_add_default(LayoutWindow *lw, ToolbarType type) { - layout_toolbar_add(lw, "Thumbnails"); - layout_toolbar_add(lw, "Back"); - layout_toolbar_add(lw, "Home"); - layout_toolbar_add(lw, "Refresh"); - layout_toolbar_add(lw, "ZoomIn"); - layout_toolbar_add(lw, "ZoomOut"); - layout_toolbar_add(lw, "ZoomFit"); - layout_toolbar_add(lw, "Zoom100"); - layout_toolbar_add(lw, "Preferences"); - layout_toolbar_add(lw, "FloatTools"); + switch (type) + { + case TOOLBAR_MAIN: + layout_toolbar_add(lw, type, "Thumbnails"); + layout_toolbar_add(lw, type, "Back"); + layout_toolbar_add(lw, type, "Home"); + layout_toolbar_add(lw, type, "Refresh"); + layout_toolbar_add(lw, type, "ZoomIn"); + layout_toolbar_add(lw, type, "ZoomOut"); + layout_toolbar_add(lw, type, "ZoomFit"); + layout_toolbar_add(lw, type, "Zoom100"); + layout_toolbar_add(lw, type, "Preferences"); + layout_toolbar_add(lw, type, "FloatTools"); + break; + case TOOLBAR_STATUS: + layout_toolbar_add(lw, type, "UseColorProfiles"); + layout_toolbar_add(lw, type, "SaveMetadata"); + break; + default: + break; + } } -void layout_toolbar_write_config(LayoutWindow *lw, GString *outstr, gint indent) +void layout_toolbar_write_config(LayoutWindow *lw, ToolbarType type, GString *outstr, gint indent) { - GList *work = lw->toolbar_actions; - WRITE_NL(); WRITE_STRING("<toolbar>"); + const gchar *name = NULL; + GList *work = lw->toolbar_actions[type]; + + switch (type) + { + case TOOLBAR_MAIN: + name = "toolbar"; + break; + case TOOLBAR_STATUS: + name = "statusbar"; + break; + default: + break; + } + + WRITE_NL(); WRITE_STRING("<%s>", name); indent++; WRITE_NL(); WRITE_STRING("<clear/>"); while (work) @@ -2036,10 +1996,10 @@ WRITE_STRING("/>"); } indent--; - WRITE_NL(); WRITE_STRING("</toolbar>"); + WRITE_NL(); WRITE_STRING("</%s>", name); } -void layout_toolbar_add_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values) +void layout_toolbar_add_from_config(LayoutWindow *lw, ToolbarType type, const gchar **attribute_names, const gchar **attribute_values) { gchar *action = NULL; @@ -2053,7 +2013,7 @@ log_printf("unknown attribute %s = %s\n", option, value); } - layout_toolbar_add(lw, action); + layout_toolbar_add(lw, type, action); g_free(action); } @@ -2062,13 +2022,46 @@ * misc *----------------------------------------------------------------------------- */ + +void layout_util_status_update_write(LayoutWindow *lw) +{ + GtkAction *action; + gint n = metadata_queue_length(); + action = gtk_action_group_get_action(lw->action_group, "SaveMetadata"); + gtk_action_set_sensitive(action, n > 0); + if (n > 0) + { + gchar *buf = g_strdup_printf(_("Number of files with unsaved metadata: %d"), n); + g_object_set(G_OBJECT(action), "tooltip", buf, NULL); + g_free(buf); + } + else + { + g_object_set(G_OBJECT(action), "tooltip", _("No unsaved metadata"), NULL); + } +} + +void layout_util_status_update_write_all(void) +{ + GList *work; + + work = layout_window_list; + while (work) + { + LayoutWindow *lw = work->data; + work = work->next; + + layout_util_status_update_write(lw); + } +} + static gchar *layout_color_name_parse(const gchar *name) { if (!name || !*name) return g_strdup(_("Empty")); return g_strdelimit(g_strdup(name), "_", '-'); } -static void layout_util_sync_color(LayoutWindow *lw) +void layout_util_sync_color(LayoutWindow *lw) { GtkAction *action; gint input = 0; @@ -2076,6 +2069,9 @@ gboolean use_image = FALSE; gint i; gchar action_name[15]; + gchar *image_profile; + gchar *screen_profile; + if (!lw->action_group) return; if (!layout_image_color_profile_get(lw, &input, &use_image)) return; @@ -2084,6 +2080,20 @@ action = gtk_action_group_get_action(lw->action_group, "UseColorProfiles"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_color); + + if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile)) + { + gchar *buf; + buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile); + g_object_set(G_OBJECT(action), "tooltip", buf, NULL); + g_free(image_profile); + g_free(screen_profile); + g_free(buf); + } + else + { + g_object_set(G_OBJECT(action), "tooltip", _("Click to enable color management"), NULL); + } action = gtk_action_group_get_action(lw->action_group, "UseImageProfile"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), use_image);
--- a/src/layout_util.h Fri May 01 09:49:27 2009 +0000 +++ b/src/layout_util.h Fri May 01 23:15:51 2009 +0000 @@ -20,8 +20,11 @@ gboolean layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data); void layout_util_sync_thumb(LayoutWindow *lw); +void layout_util_sync_color(LayoutWindow *lw); void layout_util_sync(LayoutWindow *lw); +void layout_util_status_update_write(LayoutWindow *lw); +void layout_util_status_update_write_all(void); //void layout_edit_update_all(void); @@ -34,14 +37,14 @@ void layout_actions_setup(LayoutWindow *lw); void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window); GtkWidget *layout_actions_menu_bar(LayoutWindow *lw); -void layout_toolbar_add_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values); +void layout_toolbar_add_from_config(LayoutWindow *lw, ToolbarType type, const gchar **attribute_names, const gchar **attribute_values); -GtkWidget *layout_actions_toolbar(LayoutWindow *lw); +GtkWidget *layout_actions_toolbar(LayoutWindow *lw, ToolbarType type); -void layout_toolbar_clear(LayoutWindow *lw); -void layout_toolbar_add(LayoutWindow *lw, const gchar *action); -void layout_toolbar_add_default(LayoutWindow *lw); -void layout_toolbar_write_config(LayoutWindow *lw, GString *outstr, gint indent); +void layout_toolbar_clear(LayoutWindow *lw, ToolbarType type); +void layout_toolbar_add(LayoutWindow *lw, ToolbarType type, const gchar *action); +void layout_toolbar_add_default(LayoutWindow *lw, ToolbarType type); +void layout_toolbar_write_config(LayoutWindow *lw, ToolbarType type, GString *outstr, gint indent); void layout_keyboard_init(LayoutWindow *lw, GtkWidget *window);
--- a/src/metadata.c Fri May 01 09:49:27 2009 +0000 +++ b/src/metadata.c Fri May 01 23:15:51 2009 +0000 @@ -23,7 +23,7 @@ #include "ui_misc.h" #include "utilops.h" #include "filefilter.h" -#include "layout.h" +#include "layout_util.h" #include "rcfile.h" typedef enum { @@ -56,7 +56,7 @@ metadata_write_queue = g_list_prepend(metadata_write_queue, fd); file_data_ref(fd); - layout_status_update_write_all(); + layout_util_status_update_write_all(); } if (metadata_write_idle_id) @@ -84,7 +84,7 @@ file_data_unref(fd); - layout_status_update_write_all(); + layout_util_status_update_write_all(); return TRUE; }
--- a/src/rcfile.c Fri May 01 09:49:27 2009 +0000 +++ b/src/rcfile.c Fri May 01 23:15:51 2009 +0000 @@ -969,12 +969,12 @@ LayoutWindow *lw = data; if (g_ascii_strcasecmp(element_name, "toolitem") == 0) { - layout_toolbar_add_from_config(lw, attribute_names, attribute_values); + layout_toolbar_add_from_config(lw, TOOLBAR_MAIN, attribute_names, attribute_values); options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL); } else if (g_ascii_strcasecmp(element_name, "clear") == 0) { - layout_toolbar_clear(lw); + layout_toolbar_clear(lw, TOOLBAR_MAIN); options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL); } else @@ -984,6 +984,26 @@ } } +static void options_parse_statusbar(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error) +{ + LayoutWindow *lw = data; + if (g_ascii_strcasecmp(element_name, "toolitem") == 0) + { + layout_toolbar_add_from_config(lw, TOOLBAR_STATUS, attribute_names, attribute_values); + options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL); + } + else if (g_ascii_strcasecmp(element_name, "clear") == 0) + { + layout_toolbar_clear(lw, TOOLBAR_STATUS); + options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL); + } + else + { + log_printf("unexpected in <statusbar>: <%s>\n", element_name); + options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL); + } +} + static void options_parse_layout(GQParserData *parser_data, GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer data, GError **error) { LayoutWindow *lw = data; @@ -1011,6 +1031,10 @@ { options_parse_func_push(parser_data, options_parse_toolbar, NULL, lw); } + else if (g_ascii_strcasecmp(element_name, "statusbar") == 0) + { + options_parse_func_push(parser_data, options_parse_statusbar, NULL, lw); + } else { log_printf("unexpected in <layout>: <%s>\n", element_name);
--- a/src/rcfile.h Fri May 01 09:49:27 2009 +0000 +++ b/src/rcfile.h Fri May 01 23:15:51 2009 +0000 @@ -41,7 +41,7 @@ #define WRITE_NL() write_indent(outstr, indent) #define WRITE_SEPARATOR() g_string_append(outstr, "\n") #define WRITE_SUBTITLE(_title_) g_string_append_printf(outstr, "\n\n<!-- "_title_" -->\n\n") -#define WRITE_STRING(_str_) g_string_append_printf(outstr, _str_) +#define WRITE_STRING(...) g_string_append_printf(outstr, __VA_ARGS__) #define READ_BOOL(_target_, _name_) read_bool_option(option, #_name_, value, &(_target_)._name_) #define READ_INT(_target_, _name_) read_int_option(option, #_name_, value, &(_target_)._name_)
--- a/src/typedefs.h Fri May 01 09:49:27 2009 +0000 +++ b/src/typedefs.h Fri May 01 23:15:51 2009 +0000 @@ -179,6 +179,12 @@ STARTUP_PATH_HOME, } StartUpPath; +typedef enum { + TOOLBAR_MAIN, + TOOLBAR_STATUS, + TOOLBAR_COUNT +} ToolbarType; + #define MAX_SPLIT_IMAGES 4 typedef struct _ImageLoader ImageLoader; @@ -562,8 +568,8 @@ GtkActionGroup *action_group_editors; guint ui_editors_id; GtkUIManager *ui_manager; - guint toolbar_merge_id; - GList *toolbar_actions; + guint toolbar_merge_id[TOOLBAR_COUNT]; + GList *toolbar_actions[TOOLBAR_COUNT]; GtkWidget *path_entry; @@ -591,7 +597,7 @@ GtkWidget *menu_bar; /* referenced by lw, exist during whole lw lifetime */ /* toolbar */ - GtkWidget *toolbar; /* referenced by lw, exist during whole lw lifetime */ + GtkWidget *toolbar[TOOLBAR_COUNT]; /* referenced by lw, exist during whole lw lifetime */ // gint toolbar_hidden; // GtkWidget *thumb_button; @@ -626,11 +632,9 @@ GtkWidget *info_box; GtkWidget *info_progress_bar; GtkWidget *info_sort; - GtkWidget *info_color; GtkWidget *info_status; GtkWidget *info_details; GtkWidget *info_zoom; - GtkWidget *info_write; GtkWidget *info_pixel; /* slide show */