Skip to content

Commit

Permalink
fix regressions from #17425
Browse files Browse the repository at this point in the history
  • Loading branch information
dterrahe authored and TurboGit committed Sep 9, 2024
1 parent 8ded880 commit 83b4de5
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 82 deletions.
17 changes: 13 additions & 4 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2959,21 +2959,30 @@ GtkWidget *dt_iop_gui_header_button(dt_iop_module_t *module,

static gboolean _on_drag_motion(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, dt_iop_module_t *dest)
{
if(y < 0) return FALSE; // handled by panel after failing on current module and then sent to last item.

GtkWidget *src_widget = gtk_widget_get_ancestor(gtk_drag_get_source_widget(dc),
DTGTK_TYPE_EXPANDER);

dt_iop_module_t *src = NULL;
for(GList *iop = darktable.develop->iop; iop; iop = iop->next)
if(((dt_iop_module_t *)iop->data)->expander == src_widget)
src = iop->data;
if(!src || dest == src) return FALSE;

const gboolean above = y < gtk_widget_get_allocated_height(dest->header);

GList *iop_order = g_list_find(darktable.develop->iop, dest);
dest = above ^ (src && dest->iop_order < src->iop_order)
? dest : above ? iop_order->next->data : iop_order->prev->data;
if(above ^ (dest->iop_order > src->iop_order))
{
GList *dest_list = g_list_find(darktable.develop->iop, dest);
do
{
dest_list = above ? dest_list->next : dest_list->prev;
dest = dest_list->data;
} while (!dest->expander || !gtk_widget_get_visible(dest->expander));
}

if(!src || !dest || dest == src) return FALSE;
if(dest == src) return FALSE;

if(x != DND_DROP)
{
Expand Down
11 changes: 5 additions & 6 deletions src/libs/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ gboolean dt_lib_is_visible_in_view(dt_lib_module_t *module,
return FALSE;
}

const dt_view_t *cv = view ?: dt_view_manager_get_current_view(darktable.view_manager);
gboolean ret = module->views(module) & cv->view(cv);
gchar *key = _get_lib_view_path(module, cv, "_visible");
gboolean ret = module->views(module) & view->view(view);
gchar *key = _get_lib_view_path(module, view, "_visible");
if(key && dt_conf_key_exists(key))
ret = dt_conf_get_bool(key);
g_free(key);
Expand Down Expand Up @@ -1423,8 +1422,8 @@ static gchar *_get_lib_view_path(const dt_lib_module_t *module,
const dt_view_t *cv,
char *suffix)
{
if(!darktable.view_manager) return NULL;
if(!cv) cv = dt_view_manager_get_current_view(darktable.view_manager);
if(!cv && darktable.view_manager)
cv = dt_view_manager_get_current_view(darktable.view_manager);
if(!cv) return NULL;
// in lighttable, we store panels states per layout
char lay[32] = "";
Expand All @@ -1448,7 +1447,7 @@ static gchar *_get_lib_view_path(const dt_lib_module_t *module,

gboolean dt_lib_is_visible(dt_lib_module_t *module)
{
return dt_lib_is_visible_in_view(module, NULL);
return dt_lib_is_visible_in_view(module, dt_view_manager_get_current_view(darktable.view_manager));
}

void dt_lib_set_visible(dt_lib_module_t *module,
Expand Down
9 changes: 2 additions & 7 deletions src/lua/lualib.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,8 @@ int position_wrapper(const struct dt_lib_module_t *self)
const dt_view_t *cur_view = dt_view_manager_get_current_view(darktable.view_manager);
lua_lib_data_t *gui_data = self->data;
position_description_t *position_description = get_position_description(gui_data, cur_view);
if(position_description) return position_description->position;
printf("ERROR in lualib, couldn't find a position for `%s', this should never happen\n", gui_data->name);
/*
No position found. This can happen if we are called while current view is not one
of our views. just return 0
*/
return 0;
// If current view is not one of our views, just return 0
return position_description ? position_description->position : 0;
}

static int async_lib_call(lua_State * L)
Expand Down
1 change: 1 addition & 0 deletions src/views/darkroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,7 @@ void leave(dt_view_t *self)
}

GtkWidget *box = GTK_WIDGET(dt_ui_get_container(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER));
gtk_container_foreach(GTK_CONTAINER(box), (GtkCallback)gtk_widget_destroy, NULL);
GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(gtk_widget_get_ancestor(box, GTK_TYPE_SCROLLED_WINDOW));
if(sw) gtk_scrolled_window_set_propagate_natural_width(sw, TRUE);

Expand Down
110 changes: 45 additions & 65 deletions src/views/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,6 @@ void dt_vm_remove_child(GtkWidget *widget, gpointer data)
gtk_container_remove(GTK_CONTAINER(data), widget);
}

/*
When expanders get destroyed, they destroy the child
so remove the child before that
*/
static void _remove_child(GtkWidget *child,
gpointer container)
{
if(DTGTK_IS_EXPANDER(child))
{
GtkWidget * evb = dtgtk_expander_get_body_event_box(DTGTK_EXPANDER(child));
GtkWidget *body = dtgtk_expander_get_body(DTGTK_EXPANDER(child));
if(body) gtk_container_remove(GTK_CONTAINER(evb), body);
gtk_widget_destroy(child);
}
else
{
gtk_container_remove(container,child);
}
}

gboolean dt_view_manager_switch(dt_view_manager_t *vm,
const char *view_name)
{
Expand Down Expand Up @@ -353,13 +333,17 @@ gboolean dt_view_manager_switch_by_view(dt_view_manager_t *vm,
if(plugin->view_leave)
plugin->view_leave(plugin, old_view, new_view);

_remove_child(ppw, gtk_widget_get_parent(ppw));
/*
When expanders get destroyed, they destroy the child
so remove the child before that
*/
if(plugin->widget)
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(plugin->widget)), plugin->widget);
if(plugin->expander)
gtk_widget_destroy(plugin->expander);
}
plugin->expander = NULL;
}

if(new_view != old_view && old_view->view(old_view) == DT_VIEW_DARKROOM)
dt_ui_container_foreach(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, _remove_child);
}

/* change current view to the new view */
Expand All @@ -380,56 +364,52 @@ gboolean dt_view_manager_switch_by_view(dt_view_manager_t *vm,
iter = g_list_previous(iter))
{
dt_lib_module_t *plugin = (dt_lib_module_t *)(iter->data);
GtkWidget *w = plugin->widget;

if(new_view == old_view && !plugin->expandable(plugin)) continue;

if(dt_lib_is_visible_in_view(plugin, new_view))
if(plugin->expandable(plugin))
{
/* try get the module expander */
GtkWidget *w = dt_lib_gui_get_expander(plugin);

/* if we didn't get an expander let's add the widget */
if(!w) w = plugin->widget;
if(!dt_lib_is_visible_in_view(plugin, new_view))
continue;

dt_gui_add_help_link(w, plugin->plugin_name);
// some plugins help links depend on the view
if(!strcmp(plugin->plugin_name,"module_toolbox")
|| !strcmp(plugin->plugin_name,"view_toolbox"))
{
dt_view_type_flags_t view_type = new_view->view(new_view);
if(view_type == DT_VIEW_LIGHTTABLE)
dt_gui_add_help_link(w, "lighttable_mode");
if(view_type == DT_VIEW_DARKROOM)
dt_gui_add_help_link(w, "darkroom_bottom_panel");
}
w = dt_lib_gui_get_expander(plugin);

/* set expanded if last mode was that */
char var[1024];
gboolean expanded = FALSE;
gboolean visible = dt_lib_is_visible(plugin);
if(plugin->expandable(plugin))
{
snprintf(var, sizeof(var), "plugins/%s/%s/expanded",
new_view->module_name, plugin->plugin_name);
expanded = dt_conf_get_bool(var);
dt_lib_gui_set_expanded(plugin, expanded);
dt_lib_set_visible(plugin, visible);
}
snprintf(var, sizeof(var), "plugins/%s/%s/expanded",
new_view->module_name, plugin->plugin_name);
gboolean expanded = dt_conf_get_bool(var);
dt_lib_gui_set_expanded(plugin, expanded);
dt_lib_set_visible(plugin, TRUE);
}
else if(new_view != old_view && plugin->views(plugin) & new_view->view(new_view))
{
dt_lib_gui_get_expander(plugin); // connect modulegroups presets button

if(dt_lib_is_visible(plugin))
gtk_widget_show_all(plugin->widget);
else
{
/* show/hide plugin widget depending on expanded flag or if plugin
not is expandeable() */
if(visible)
gtk_widget_show_all(plugin->widget);
else
gtk_widget_hide(plugin->widget);
}
if(plugin->view_enter)
plugin->view_enter(plugin, old_view, new_view);
gtk_widget_hide(plugin->widget);
}
else
continue;

/* add module to its container */
dt_ui_container_add_widget(darktable.gui->ui, dt_lib_get_container(plugin), w);
if(plugin->view_enter)
plugin->view_enter(plugin, old_view, new_view);

dt_gui_add_help_link(w, plugin->plugin_name);
// some plugins help links depend on the view
if(!strcmp(plugin->plugin_name,"module_toolbox")
|| !strcmp(plugin->plugin_name,"view_toolbox"))
{
dt_view_type_flags_t view_type = new_view->view(new_view);
if(view_type == DT_VIEW_LIGHTTABLE)
dt_gui_add_help_link(w, "lighttable_mode");
if(view_type == DT_VIEW_DARKROOM)
dt_gui_add_help_link(w, "darkroom_bottom_panel");
}

/* add module to its container */
dt_ui_container_add_widget(darktable.gui->ui, dt_lib_get_container(plugin), w);
}

darktable.lib->gui_module = NULL;
Expand Down

0 comments on commit 83b4de5

Please sign in to comment.