[gnome-applets/wip/segeiger/windowpicker: 1/2] 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: 1/2] windowpicker: cleanup window handling in tasklist
- Date: Sat, 12 Oct 2019 13:26:39 +0000 (UTC)
commit ecb3614795b332b7c40f605d0f74f9bdc1151781
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 | 84 ++++++++++++++++++++++++++++----------------
1 file changed, 53 insertions(+), 31 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 18b70feaf..80522ab06 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -202,23 +202,6 @@ static void type_changed (WnckWindow *window,
}
}
-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);
-}
-
static void on_task_list_orient_changed(PanelApplet *applet,
guint orient,
GtkBox *box)
@@ -249,14 +232,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 +245,55 @@ 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_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 void
+add_windows (TaskList *list,
+ GList *windows)
+{
while (windows != NULL)
- {
- on_window_opened (list->screen, windows->data, list);
- windows = windows->next;
- }
+ {
+ add_window (list, windows->data);
+
+ windows = windows->next;
+ }
+}
+
+static void
+on_window_opened (WnckScreen *screen,
+ WnckWindow *window,
+ TaskList *taskList)
+{
+ add_window (taskList, 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 +378,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 +401,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]