From e504576092e499bdc5ecb14fc8b99db74ee9382d Mon Sep 17 00:00:00 2001 From: Nik Soggia Date: Sat, 11 Feb 2023 11:08:06 +0100 Subject: Update window-list.c Fix for "no option to disable middle-click to close in window list" https://github.com/mate-desktop/mate-panel/issues/962#issuecomment-1418934577 --- applets/wncklet/window-list.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c index 85c305d4..a87649b1 100644 --- a/applets/wncklet/window-list.c +++ b/applets/wncklet/window-list.c @@ -63,6 +63,7 @@ typedef struct { TasklistGroupingType grouping; gboolean move_unminimized_windows; gboolean scroll_enable; + gboolean middle_click_close; GtkOrientation orientation; int size; @@ -88,6 +89,7 @@ typedef struct { GtkWidget* always_group_radio; GtkWidget* move_minimized_radio; GtkWidget* mouse_scroll_check; + GtkWidget* middle_click_close_check; GtkWidget* change_workspace_radio; GtkWidget* minimized_windows_box; GtkWidget* window_grouping_box; @@ -138,6 +140,7 @@ static void tasklist_update(TasklistData* tasklist) wnck_tasklist_set_include_all_workspaces(WNCK_TASKLIST(tasklist->tasklist), tasklist->include_all_workspaces); wnck_tasklist_set_switch_workspace_on_unminimize(WNCK_TASKLIST(tasklist->tasklist), tasklist->move_unminimized_windows); wnck_tasklist_set_scroll_enabled (WNCK_TASKLIST(tasklist->tasklist), tasklist->scroll_enable); + wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist), tasklist->middle_click_close); } #endif /* HAVE_X11 */ @@ -700,6 +703,12 @@ static void scroll_enabled_changed (GSettings* settings, gchar* key, TasklistDat tasklist_update(tasklist); } +static void middle_click_close_changed (GSettings* settings, gchar* key, TasklistData* tasklist) +{ + tasklist->middle_click_close = g_settings_get_boolean (settings, key); + tasklist_update(tasklist); +} + static void setup_gsettings(TasklistData* tasklist) { tasklist->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (tasklist->applet), WINDOW_LIST_SCHEMA); @@ -734,6 +743,10 @@ static void setup_gsettings(TasklistData* tasklist) "changed::scroll-enabled", G_CALLBACK (scroll_enabled_changed), tasklist); + g_signal_connect (tasklist->settings, + "changed::middle-click-close", + G_CALLBACK (middle_click_close_changed), + tasklist); } static void applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation, TasklistData *tasklist) @@ -859,6 +872,8 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) tasklist->scroll_enable = g_settings_get_boolean (tasklist->settings, "scroll-enabled"); + tasklist->middle_click_close = g_settings_get_boolean (tasklist->settings, "middle-click-close"); + tasklist->size = mate_panel_applet_get_size(applet); #if !defined(WNCKLET_INPROCESS) && !GTK_CHECK_VERSION (3, 23, 0) @@ -883,7 +898,6 @@ gboolean window_list_applet_fill(MatePanelApplet* applet) { tasklist->tasklist = wnck_tasklist_new(); - wnck_tasklist_set_middle_click_close (WNCK_TASKLIST (tasklist->tasklist), TRUE); wnck_tasklist_set_icon_loader(WNCK_TASKLIST(tasklist->tasklist), icon_loader_func, tasklist, NULL); #ifdef HAVE_WINDOW_PREVIEWS @@ -1153,6 +1167,7 @@ static void setup_dialog(GtkBuilder* builder, TasklistData* tasklist) tasklist->move_minimized_radio = WID("move_minimized_radio"); tasklist->change_workspace_radio = WID("change_workspace_radio"); tasklist->mouse_scroll_check = WID("mouse_scroll_check"); + tasklist->middle_click_close_check = WID("middle_click_close_check"); tasklist->minimized_windows_box = WID("minimized_windows_box"); tasklist->window_grouping_box = WID("window_grouping_box"); tasklist->window_list_content_box = WID("window_list_content_box"); @@ -1183,6 +1198,13 @@ static void setup_dialog(GtkBuilder* builder, TasklistData* tasklist) "active", G_SETTINGS_BIND_DEFAULT); + /* Middle mouse click to close window: */ + g_settings_bind (tasklist->settings, + "middle-click-close", + tasklist->middle_click_close_check, + "active", + G_SETTINGS_BIND_DEFAULT); + #ifdef HAVE_WINDOW_PREVIEWS /* change thumbnail size: */ tasklist_update_thumbnail_size_spin(tasklist); -- cgit v1.2.1