diff options
author | John Stebbins <[email protected]> | 2017-09-15 16:27:22 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2017-11-06 08:19:49 -0800 |
commit | 737d67c0e7e9a404f25ed82318d243e344ec7672 (patch) | |
tree | ca8bc876d7d72846ab6422829320357691a18866 /gtk/src/preview.c | |
parent | d7a59d58cbaa5f08792dbb97c48065fdadbe4414 (diff) |
LinGui: Add preset selection menu
And convert appliction to a GtkApplication. This allows the use of
GActions for menu and other control actions. It's a cleaner simpler
interface that automatically tracks when multiple widgets perform the
same action and keeps their state in sync.
Diffstat (limited to 'gtk/src/preview.c')
-rw-r--r-- | gtk/src/preview.c | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/gtk/src/preview.c b/gtk/src/preview.c index 9dcf81c4f..508e284b9 100644 --- a/gtk/src/preview.c +++ b/gtk/src/preview.c @@ -936,7 +936,7 @@ init_preview_image(signal_user_data_t *ud) title_id = ghb_dict_get_int(ud->settings, "title"); title = ghb_lookup_title(title_id, &titleindex); - if (title == NULL) + if (title == NULL && ud->preview->pix != NULL) { g_object_unref(ud->preview->pix); ud->preview->pix = NULL; @@ -1068,22 +1068,19 @@ preview_button_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, si } void -ghb_preview_set_visible(signal_user_data_t *ud) +ghb_preview_set_visible(signal_user_data_t *ud, gboolean visible) { + GtkWidget *widget; +#if 0 gint title_id, titleindex; const hb_title_t *title; - GtkToggleToolButton *button; - GtkWidget *widget; - gboolean active; - - button = GTK_TOGGLE_TOOL_BUTTON(GHB_WIDGET(ud->builder, "show_preview")); - active = gtk_toggle_tool_button_get_active(button); title_id = ghb_dict_get_int(ud->settings, "title"); title = ghb_lookup_title(title_id, &titleindex); - active &= title != NULL; + visible &= title != NULL; +#endif widget = GHB_WIDGET(ud->builder, "preview_window"); - if (active) + if (visible) { gint x, y; x = ghb_dict_get_int(ud->prefs, "preview_x"); @@ -1092,7 +1089,7 @@ ghb_preview_set_visible(signal_user_data_t *ud) gtk_window_move(GTK_WINDOW(widget), x, y); gtk_window_deiconify(GTK_WINDOW(widget)); } - gtk_widget_set_visible(widget, active); + gtk_widget_set_visible(widget, visible); } static void @@ -1113,29 +1110,14 @@ update_preview_labels(signal_user_data_t *ud, gboolean active) } G_MODULE_EXPORT void -preview_toggled_cb(GtkWidget *xwidget, signal_user_data_t *ud) -{ - GtkCheckMenuItem *menuitem; - gboolean active; - - active = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(xwidget)); - ghb_preview_set_visible(ud); - update_preview_labels(ud, active); - - menuitem = GTK_CHECK_MENU_ITEM(GHB_WIDGET(ud->builder, - "show_preview_menu")); - gtk_check_menu_item_set_active(menuitem, active); -} - -G_MODULE_EXPORT void -preview_menu_toggled_cb(GtkWidget *xwidget, signal_user_data_t *ud) +show_preview_action_cb(GSimpleAction *action, GVariant *value, + signal_user_data_t *ud) { - GtkToggleToolButton *button; - gboolean active; + gboolean state = g_variant_get_boolean(value); - active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(xwidget)); - button = GTK_TOGGLE_TOOL_BUTTON(GHB_WIDGET(ud->builder, "show_preview")); - gtk_toggle_tool_button_set_active(button, active); + g_simple_action_set_state(action, value); + ghb_preview_set_visible(ud, state); + update_preview_labels(ud, state); } G_MODULE_EXPORT void |