Skip to content

Commit

Permalink
LinGUI: Add Invert Selection to title add dialog
Browse files Browse the repository at this point in the history
- Remove unnecessary code to disable Select All action
  • Loading branch information
robxnano authored and galad87 committed Mar 28, 2024
1 parent 17aaaa0 commit 64261d2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
2 changes: 2 additions & 0 deletions gtk/src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ GHB_DECLARE_ACTION_CB(log_copy_action_cb);
GHB_DECLARE_ACTION_CB(log_directory_action_cb);
GHB_DECLARE_ACTION_CB(title_add_select_all_cb);
GHB_DECLARE_ACTION_CB(title_add_clear_all_cb);
GHB_DECLARE_ACTION_CB(title_add_invert_cb);
GHB_DECLARE_ACTION_CB(audio_add_cb);
GHB_DECLARE_ACTION_CB(audio_add_all_cb);
GHB_DECLARE_ACTION_CB(audio_reset_cb);
Expand Down Expand Up @@ -504,6 +505,7 @@ map_actions (GtkApplication *app, signal_user_data_t *ud)
{ "log-directory", log_directory_action_cb },
{ "title-add-select-all", title_add_select_all_cb },
{ "title-add-clear-all", title_add_clear_all_cb },
{ "title-add-invert", title_add_invert_cb },
{ "audio-add", audio_add_cb },
{ "audio-add-all", audio_add_all_cb },
{ "audio-reset", audio_reset_cb },
Expand Down
49 changes: 26 additions & 23 deletions gtk/src/title-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,6 @@ title_add_select_all_cb (GSimpleAction *action, GVariant *param, gpointer data)
GtkWidget *selected;
signal_user_data_t *ud = (signal_user_data_t *)data;

g_simple_action_set_enabled(action, FALSE);
action = G_SIMPLE_ACTION(GHB_ACTION("title-add-clear-all"));
g_simple_action_set_enabled(action, TRUE);

clear_select_all_busy = TRUE;

list = GTK_LIST_BOX(ghb_builder_widget("title_add_multiple_list"));
Expand Down Expand Up @@ -529,10 +525,6 @@ title_add_clear_all_cb (GSimpleAction *action, GVariant *param, gpointer data)

clear_select_all_busy = TRUE;

g_simple_action_set_enabled(action, FALSE);
action = G_SIMPLE_ACTION(GHB_ACTION("title-add-select-all"));
g_simple_action_set_enabled(action, TRUE);

list = GTK_LIST_BOX(ghb_builder_widget("title_add_multiple_list"));
count = ghb_array_len(ud->settings_array);
for (ii = 0; ii < count; ii++)
Expand All @@ -546,12 +538,37 @@ title_add_clear_all_cb (GSimpleAction *action, GVariant *param, gpointer data)
clear_select_all_busy = FALSE;
}

G_MODULE_EXPORT void
title_add_invert_cb (GSimpleAction *action, GVariant *param, gpointer data)
{
gint count, ii;
GhbValue *settings;
GtkWidget *row;
GtkListBox *list;
GtkWidget *selected;
signal_user_data_t *ud = (signal_user_data_t *)data;

clear_select_all_busy = TRUE;

list = GTK_LIST_BOX(ghb_builder_widget("title_add_multiple_list"));
count = ghb_array_len(ud->settings_array);
for (ii = 0; ii < count; ii++)
{
row = GTK_WIDGET(gtk_list_box_get_row_at_index(list, ii));
selected = find_widget(row, "title_selected");
settings = ghb_array_get(ud->settings_array, ii);
gboolean is_selected = ghb_dict_get_bool(settings, "title_selected");
ghb_dict_set_bool(settings, "title_selected", !is_selected);
gtk_check_button_set_active(GTK_CHECK_BUTTON(selected), !is_selected);
}
clear_select_all_busy = FALSE;
}

G_MODULE_EXPORT void
title_selected_cb (GtkWidget *widget, signal_user_data_t *ud)
{
GhbValue *settings;
gboolean selected;
GSimpleAction *select_all, *clear_all;
gboolean can_select;

if (clear_select_all_busy)
Expand All @@ -561,12 +578,6 @@ title_selected_cb (GtkWidget *widget, signal_user_data_t *ud)
if (row == NULL)
return;


clear_all = G_SIMPLE_ACTION(GHB_ACTION("title-add-clear-all"));
g_simple_action_set_enabled(clear_all, TRUE);
select_all = G_SIMPLE_ACTION(GHB_ACTION("title-add-select-all"));
g_simple_action_set_enabled(select_all, TRUE);

gint index = gtk_list_box_row_get_index(row);
selected = ghb_widget_boolean(widget);
settings = ghb_array_get(ud->settings_array, index);
Expand Down Expand Up @@ -764,14 +775,6 @@ title_add_multiple_action_cb (GSimpleAction *action, GVariant *param,
gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END);
}

// Clear "select all" and "clear all" options
GSimpleAction *select_all, *clear_all;

clear_all = G_SIMPLE_ACTION(GHB_ACTION("title-add-clear-all"));
g_simple_action_set_enabled(clear_all, TRUE);
select_all = G_SIMPLE_ACTION(GHB_ACTION("title-add-select-all"));
g_simple_action_set_enabled(select_all, TRUE);

// Disable selection of files with duplicate file names.
title_add_check_conflicts(ud);

Expand Down
10 changes: 10 additions & 0 deletions gtk/src/ui/ghb.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5316,6 +5316,16 @@ Each selected source track will be encoded with all selected encoders.</property
<property name="action-name">app.title-add-clear-all</property>
</object>
</child>
<child>
<object class="GtkButton" id="title_add_multiple_invert_selection">
<property name="label" translatable="yes">Invert Selection</property>
<property name="focusable">1</property>
<property name="halign">start</property>
<property name="vexpand">0</property>
<property name="halign">start</property>
<property name="action-name">app.title-add-invert</property>
</object>
</child>
</object>
</child>
<child>
Expand Down

0 comments on commit 64261d2

Please sign in to comment.