[gnome-applets/wip/segeiger/windowpicker: 6/7] windowpicker: cleanup window handling in tasklist
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/segeiger/windowpicker: 6/7] windowpicker: cleanup window handling in tasklist
- Date: Fri, 11 Oct 2019 21:24:29 +0000 (UTC)
commit 2510310062a7a4cb755302bf6c02cdf250fce741
Author: Sebastian Geiger <sbastig gmx net>
Date: Wed Oct 9 00:09:56 2019 +0200
windowpicker: cleanup window handling in tasklist
windowpicker/src/task-list.c | 76 ++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 23 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 18b70feaf..ff4277e58 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -73,6 +73,15 @@ window_is_special (WnckWindow *window)
|| type == WNCK_WINDOW_MENU;
}
+static void
+clear_windows (TaskList *list);
+
+static void
+add_windows (TaskList *list, GList *windows);
+
+static void
+add_window (TaskList *list, WnckWindow *window);
+
static TaskList *
get_task_list_for_monitor (TaskList *task_list,
GdkMonitor *monitor)
@@ -206,17 +215,7 @@ static void on_window_opened (WnckScreen *screen,
WnckWindow *window,
TaskList *taskList)
{
- g_return_if_fail (taskList != NULL);
-
- g_signal_connect_object (window, "type-changed", G_CALLBACK (type_changed),
- taskList, 0);
-
- if (window_is_special (window))
- {
- return;
- }
-
- create_task_item (taskList, window);
+ add_window (taskList, window);
}
static void on_task_list_orient_changed(PanelApplet *applet,
@@ -249,14 +248,12 @@ remove_task_item (GtkWidget *item,
gtk_container_remove (GTK_CONTAINER (list), item);
}
-static gboolean
-on_monitors_changed (gpointer user_data)
+static void
+clear_windows (TaskList *list)
{
- TaskList *list;
GdkWindow *window;
GdkMonitor *list_monitor;
- list = user_data;
window = gtk_widget_get_window (GTK_WIDGET (list));
list_monitor = gdk_display_get_monitor_at_window (gdk_display_get_default (),
@@ -264,14 +261,47 @@ on_monitors_changed (gpointer user_data)
if (task_list_get_monitor (list) == list_monitor)
gtk_container_foreach (GTK_CONTAINER (list), remove_task_item, list);
+}
- GList *windows = wnck_screen_get_windows (list->screen);
-
+static void
+add_windows (TaskList *list,
+ GList *windows)
+{
while (windows != NULL)
{
- on_window_opened (list->screen, windows->data, list);
+ add_window (list, windows->data);
+
windows = windows->next;
}
+}
+
+static void
+add_window (TaskList *list, WnckWindow *window)
+{
+ g_signal_connect_object (window, "type-changed", G_CALLBACK (type_changed),
+ list, 0);
+
+ if (window_is_special (window))
+ {
+ return;
+ }
+
+ create_task_item (list, window);
+}
+
+static gboolean
+on_monitors_changed (gpointer user_data)
+{
+ TaskList *list;
+ GList *windows;
+
+ list = TASK_LIST (user_data);
+
+ clear_windows (list);
+
+ windows = wnck_screen_get_windows (list->screen);
+
+ add_windows (list, windows);
list->size_update_event_source = 0;
@@ -356,6 +386,7 @@ static void task_list_init (TaskList *list) {
GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
GtkOrientation orientation;
+ GList *windows;
orientation = get_applet_orientation (windowPickerApplet);
@@ -378,11 +409,10 @@ GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
window_filter_function,
taskList);
- GList *windows = wnck_screen_get_windows (taskList->screen);
- while (windows != NULL) {
- on_window_opened (taskList->screen, windows->data, taskList);
- windows = windows->next;
- }
+ windows = wnck_screen_get_windows (taskList->screen);
+
+ add_windows (taskList, windows);
+
return (GtkWidget *) taskList;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]