/* * Copyright 2015 Javier S. Pedro * * This file is part of MDock. * * MDock is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MDock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MDock. If not, see . */ #include #define WNCK_I_KNOW_THIS_IS_UNSTABLE 1 #include #include "mdock-widget.h" #include "mdock-item.h" #include "matcher.h" struct _MDockWidgetPrivate { WnckScreen *wnck_screen; GSequence *groups; }; G_DEFINE_TYPE(MDockWidget, mdock_widget, GTK_TYPE_BOX) #define MDOCK_WIDGET_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), MDOCK_TYPE_WIDGET, MDockWidgetPrivate)) static void handle_active_window_changed(MDockWidget *self, WnckWindow *previous_window, WnckScreen *screen) { } static void handle_window_closed(MDockWidget *self, WnckWindow *window, WnckScreen *screen) { } static void handle_window_opened(MDockWidget *self, WnckWindow *window, WnckScreen *screen) { if (wnck_window_is_skip_tasklist(window)) { return; } g_debug("Window opened: %s", wnck_window_get_name(window)); AppId *appid = app_id_from_window(window); g_debug("%s %d %s %s %s", appid->host, appid->uid, appid->executable, appid->wm_class_class, appid->wm_class_name); const gchar *desktopid = match_appid_to_desktopid(appid); g_debug("desktopid: %s", desktopid); } static void mdock_widget_dispose(GObject *obj) { MDockWidget *self = MDOCK_WIDGET(obj); if (self->priv->wnck_screen) { g_signal_handlers_disconnect_by_data(self->priv->wnck_screen, self); self->priv->wnck_screen = NULL; } G_OBJECT_CLASS(mdock_widget_parent_class)->dispose(obj); } static void mdock_widget_class_init(MDockWidgetClass *klass) { // GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); GObjectClass *obj_class = G_OBJECT_CLASS(klass); obj_class->dispose = mdock_widget_dispose; g_type_class_add_private(klass, sizeof(MDockWidgetPrivate)); } static void mdock_widget_init(MDockWidget *self) { self->priv = MDOCK_WIDGET_GET_PRIVATE(self); self->priv->wnck_screen = wnck_screen_get_default(); g_signal_connect_object(self->priv->wnck_screen, "active-window-changed", G_CALLBACK(handle_active_window_changed), self, G_CONNECT_SWAPPED); g_signal_connect_object(self->priv->wnck_screen, "window-closed", G_CALLBACK(handle_window_closed), self, G_CONNECT_SWAPPED); g_signal_connect_object(self->priv->wnck_screen, "window-opened", G_CALLBACK(handle_window_opened), self, G_CONNECT_SWAPPED); self->priv->groups = g_sequence_new(NULL); g_debug("widget init"); GList *windows = wnck_screen_get_windows_stacked(self->priv->wnck_screen); for (GList *l = g_list_first(windows); l; l = g_list_next(l)) { g_debug("list"); WnckWindow *window = l->data; handle_window_opened(self, window, self->priv->wnck_screen); } } GtkWidget *mdock_widget_new(void) { return GTK_WIDGET(g_object_new(MDOCK_TYPE_WIDGET, NULL)); }