From: Arkadiy Illarionov Date: Wed, 17 Apr 2024 20:42:44 +0000 (+0300) Subject: Deduplicate "Show star rating" menu item creation X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=98b2cdbeb4fada4a4e123bf0779a11067a6deae5 Deduplicate "Show star rating" menu item creation --- diff --git a/src/view-file/view-file-icon.cc b/src/view-file/view-file-icon.cc index fe7c180b..56b9e542 100644 --- a/src/view-file/view-file-icon.cc +++ b/src/view-file/view-file-icon.cc @@ -138,23 +138,14 @@ void vficon_pop_menu_show_names_cb(GtkWidget *, gpointer data) vficon_toggle_filenames(vf); } -static void vficon_toggle_star_rating(ViewFile *vf) +void vficon_pop_menu_show_star_rating_cb(ViewFile *vf) { GtkAllocation allocation; - options->show_star_rating = !options->show_star_rating; - gtk_widget_get_allocation(vf->listview, &allocation); vficon_populate_at_new_size(vf, allocation.width, allocation.height, TRUE); } -void vficon_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data) -{ - auto vf = static_cast(data); - - vficon_toggle_star_rating(vf); -} - void vficon_pop_menu_refresh_cb(GtkWidget *, gpointer data) { auto vf = static_cast(data); diff --git a/src/view-file/view-file-icon.h b/src/view-file/view-file-icon.h index 73d0615b..a0d09381 100644 --- a/src/view-file/view-file-icon.h +++ b/src/view-file/view-file-icon.h @@ -52,10 +52,10 @@ GList *vficon_selection_get_one(ViewFile *vf, FileData *fd); GList *vficon_pop_menu_file_list(ViewFile *vf); void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data); void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data); +void vficon_pop_menu_show_star_rating_cb(ViewFile *vf); void vficon_pop_menu_refresh_cb(GtkWidget *widget, gpointer data); void vficon_popup_destroy_cb(GtkWidget *widget, gpointer data); void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data); -void vficon_pop_menu_show_star_rating_cb(GtkWidget *widget, gpointer data); FileData *vficon_index_get_data(ViewFile *vf, gint row); gint vficon_index_by_fd(ViewFile *vf, FileData *in_fd); diff --git a/src/view-file/view-file-list.cc b/src/view-file/view-file-list.cc index a941e7f7..94049813 100644 --- a/src/view-file/view-file-list.cc +++ b/src/view-file/view-file-list.cc @@ -461,12 +461,8 @@ void vflist_star_rating_set(ViewFile *vf, gboolean enable) g_list_free(columns); } -void vflist_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data) +void vflist_pop_menu_show_star_rating_cb(ViewFile *vf) { - auto vf = static_cast(data); - - options->show_star_rating = !options->show_star_rating; - vflist_populate_view(vf, TRUE); vflist_color_set(vf, VFLIST(vf)->click_fd, FALSE); diff --git a/src/view-file/view-file-list.h b/src/view-file/view-file-list.h index 7039cfdd..6fc64c5c 100644 --- a/src/view-file/view-file-list.h +++ b/src/view-file/view-file-list.h @@ -52,6 +52,7 @@ GList *vflist_selection_get_one(ViewFile *vf, FileData *fd); GList *vflist_pop_menu_file_list(ViewFile *vf); void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data); void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data); +void vflist_pop_menu_show_star_rating_cb(ViewFile *vf); void vflist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data); void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data); void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data); @@ -81,7 +82,6 @@ void vflist_read_metadata_progress_count(GList *list, gint *count, gint *done); void vflist_set_thumb_fd(ViewFile *vf, FileData *fd); FileData *vflist_thumb_next_fd(ViewFile *vf); void vflist_thumb_reset_all(ViewFile *vf); -void vflist_pop_menu_show_star_rating_cb(GtkWidget *widget, gpointer data); FileData *vflist_star_next_fd(ViewFile *vf); void vflist_set_star_fd(ViewFile *vf, FileData *fd); diff --git a/src/view-file/view-file.cc b/src/view-file/view-file.cc index 929f4eb9..27b0c8e8 100644 --- a/src/view-file/view-file.cc +++ b/src/view-file/view-file.cc @@ -668,6 +668,19 @@ static void vf_pop_menu_collections_cb(GtkWidget *widget, gpointer data) filelist_free(selection_list); } +static void vf_pop_menu_show_star_rating_cb(GtkWidget *, gpointer data) +{ + auto *vf = static_cast(data); + + options->show_star_rating = !options->show_star_rating; + + switch (vf->type) + { + case FILEVIEW_LIST: vflist_pop_menu_show_star_rating_cb(vf); break; + case FILEVIEW_ICON: vficon_pop_menu_show_star_rating_cb(vf); break; + } +} + GtkWidget *vf_pop_menu(ViewFile *vf) { GtkWidget *menu; @@ -825,17 +838,8 @@ GtkWidget *vf_pop_menu(ViewFile *vf) break; } - switch (vf->type) - { - case FILEVIEW_LIST: - menu_item_add_check(menu, _("Show star rating"), options->show_star_rating, - G_CALLBACK(vflist_pop_menu_show_star_rating_cb), vf); - break; - case FILEVIEW_ICON: - menu_item_add_check(menu, _("Show star rating"), options->show_star_rating, - G_CALLBACK(vficon_pop_menu_show_star_rating_cb), vf); - break; - } + menu_item_add_check(menu, _("Show star rating"), options->show_star_rating, + G_CALLBACK(vf_pop_menu_show_star_rating_cb), vf); menu_item_add_icon(menu, _("Re_fresh"), GQ_ICON_REFRESH, G_CALLBACK(vf_pop_menu_refresh_cb), vf);