Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix expand/collapse when using reset/presets lib buttons. #17987

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 41 additions & 13 deletions src/libs/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,15 +891,23 @@ void dt_lib_unload_module(dt_lib_module_t *module)
g_module_close(module->module);
}

static void dt_lib_gui_reset_callback(GtkButton *button,
gpointer user_data)
gboolean _lib_gui_reset_callback(GtkButton *button,
gpointer user_data)
{
dt_lib_module_t *module = (dt_lib_module_t *)user_data;
module->gui_reset(module);
return TRUE;
}

static void presets_popup_callback(GtkButton *button,
dt_lib_module_t *module)
gboolean _lib_gui_button_reset_release_event(GtkButton *button,
GdkEventButton *event,
dt_lib_module_t *module)
{
return _lib_gui_reset_callback(button, module);
}

gboolean _presets_popup_callback(GtkButton *button,
dt_lib_module_t *module)
{
dt_lib_module_info_t *mi = calloc(1, sizeof(dt_lib_module_info_t));

Expand All @@ -918,8 +926,16 @@ static void presets_popup_callback(GtkButton *button,

if(button)
dtgtk_button_set_active(DTGTK_BUTTON(button), FALSE);

return TRUE;
}

gboolean _lib_gui_button_presets_release_event(GtkButton *button,
GdkEventButton *event,
gpointer user_data)
{
return _presets_popup_callback(button, user_data);
}

void dt_lib_gui_set_expanded(dt_lib_module_t *module, gboolean expanded)
{
Expand Down Expand Up @@ -1015,7 +1031,7 @@ static gboolean _lib_plugin_header_button_release(GtkWidget *w,
else if(e->button == 3)
{
if(gtk_widget_get_sensitive(module->presets_button))
presets_popup_callback(NULL, module);
_presets_popup_callback(NULL, module);

return TRUE;
}
Expand Down Expand Up @@ -1198,7 +1214,7 @@ GtkWidget *dt_lib_gui_get_expander(dt_lib_module_t *module)
// because not automatically registered via lib if presets btn
// has been loaded to be shown outside expander
g_signal_connect(G_OBJECT(module->presets_button), "clicked",
G_CALLBACK(presets_popup_callback), module);
G_CALLBACK(_presets_popup_callback), module);
}
module->expander = NULL;
return NULL;
Expand Down Expand Up @@ -1270,7 +1286,9 @@ GtkWidget *dt_lib_gui_get_expander(dt_lib_module_t *module)
module->presets_button = dtgtk_button_new(dtgtk_cairo_paint_presets, 0, NULL);
gtk_widget_set_tooltip_text(module->presets_button, _("presets and preferences"));
g_signal_connect(G_OBJECT(module->presets_button), "clicked",
G_CALLBACK(presets_popup_callback), module);
G_CALLBACK(_presets_popup_callback), module);
g_signal_connect(G_OBJECT(module->presets_button), "button-release-event",
G_CALLBACK(_lib_gui_button_presets_release_event), module);
g_signal_connect(G_OBJECT(module->presets_button), "enter-notify-event",
G_CALLBACK(_header_enter_notify_callback),
GINT_TO_POINTER(DT_ACTION_ELEMENT_PRESETS));
Expand All @@ -1284,11 +1302,14 @@ GtkWidget *dt_lib_gui_get_expander(dt_lib_module_t *module)
/* add reset button if module has implementation */
module->reset_button = dtgtk_button_new(dtgtk_cairo_paint_reset, 0, NULL);
g_signal_connect(G_OBJECT(module->reset_button), "clicked",
G_CALLBACK(dt_lib_gui_reset_callback), module);
G_CALLBACK(_lib_gui_reset_callback), module);
g_signal_connect(G_OBJECT(module->reset_button), "button-release-event",
G_CALLBACK(_lib_gui_button_reset_release_event), module);
g_signal_connect(G_OBJECT(module->reset_button), "enter-notify-event",
G_CALLBACK(_header_enter_notify_callback),
GINT_TO_POINTER(DT_ACTION_ELEMENT_RESET));
if(!module->gui_reset) gtk_widget_set_sensitive(module->reset_button, FALSE);
if(!module->gui_reset)
gtk_widget_set_sensitive(module->reset_button, FALSE);
dt_action_define(&module->actions, NULL, NULL, module->reset_button, NULL);
gtk_box_pack_end(GTK_BOX(header), module->reset_button, FALSE, FALSE, 0);

Expand Down Expand Up @@ -1496,7 +1517,10 @@ void dt_lib_colorpicker_set_box_area(dt_lib_t *lib,
void dt_lib_colorpicker_set_point(dt_lib_t *lib,
const float pos[2])
{
if(!lib->proxy.colorpicker.module || !lib->proxy.colorpicker.set_sample_point) return;
if(!lib->proxy.colorpicker.module
|| !lib->proxy.colorpicker.set_sample_point)
return;

lib->proxy.colorpicker.set_sample_point(lib->proxy.colorpicker.module, pos);
gtk_widget_grab_focus(dt_ui_center(darktable.gui->ui));
}
Expand All @@ -1506,7 +1530,10 @@ void dt_lib_colorpicker_setup(dt_lib_t *lib,
const gboolean pick_output)

{
if(!lib->proxy.colorpicker.module || !lib->proxy.colorpicker.setup_sample) return;
if(!lib->proxy.colorpicker.module
|| !lib->proxy.colorpicker.setup_sample)
return;

lib->proxy.colorpicker.setup_sample(lib->proxy.colorpicker.module, denoise, pick_output);
}

Expand Down Expand Up @@ -1543,11 +1570,12 @@ static float _action_process(gpointer target,
show_module_callback(module);
break;
case DT_ACTION_ELEMENT_RESET:
if(module->gui_reset) dt_lib_gui_reset_callback(NULL, module);
if(module->gui_reset)
_lib_gui_reset_callback(NULL, module);
break;
case DT_ACTION_ELEMENT_PRESETS:
if(module->get_params || module->set_preferences)
presets_popup_callback(NULL, module);
_presets_popup_callback(NULL, module);
break;
}
}
Expand Down
Loading