[gnome-applets/wip/muktupavels/window-picker/task-title: 8/8] window-picker: redo TaskTitle (unfinished)
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/muktupavels/window-picker/task-title: 8/8] window-picker: redo TaskTitle (unfinished)
- Date: Thu, 23 Jul 2015 12:09:03 +0000 (UTC)
commit 5056df2433c5daca653ed3df9a8d365824bca596
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Jul 23 15:07:51 2015 +0300
window-picker: redo TaskTitle (unfinished)
po/POTFILES.in | 2 +-
windowpicker/src/Makefile.am | 6 +-
windowpicker/src/task-title.c | 497 ------------------------------------
windowpicker/src/task-title.h | 52 ----
windowpicker/src/wp-applet.c | 96 +++----
windowpicker/src/wp-applet.h | 10 +-
windowpicker/src/wp-task-title.c | 525 ++++++++++++++++++++++++++++++++++++++
windowpicker/src/wp-task-title.h | 37 +++
8 files changed, 609 insertions(+), 616 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 3c600b6..fc58d4e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -104,9 +104,9 @@ trashapplet/src/trashapplet.c
trashapplet/src/trash-empty.c
[type: gettext/glade]trashapplet/trashapplet-menu.xml
[type: gettext/glade]trashapplet/trashapplet-empty-progress.ui
-windowpicker/src/task-title.c
windowpicker/src/task-item.c
windowpicker/src/wp-about-dialog.c
windowpicker/src/wp-applet.c
[type: gettext/glade]windowpicker/src/wp-menu.xml
[type: gettext/glade]windowpicker/src/wp-preferences-dialog.ui
+windowpicker/src/wp-task-title.c
diff --git a/windowpicker/src/Makefile.am b/windowpicker/src/Makefile.am
index ca1979a..5d88de4 100644
--- a/windowpicker/src/Makefile.am
+++ b/windowpicker/src/Makefile.am
@@ -37,10 +37,10 @@ libwindow_picker_applet_la_SOURCES = \
task-item.h \
task-list.c \
task-list.h \
- task-title.c \
- task-title.h \
wp-resources.c \
- wp-resources.h
+ wp-resources.h \
+ wp-task-title.c \
+ wp-task-title.h
EXTRA_DIST = \
wp-about-logo.png \
diff --git a/windowpicker/src/wp-applet.c b/windowpicker/src/wp-applet.c
index 965450c..f9cbc09 100644
--- a/windowpicker/src/wp-applet.c
+++ b/windowpicker/src/wp-applet.c
@@ -30,14 +30,15 @@
#include <libwnck/libwnck.h>
#include <string.h>
-#include "task-title.h"
#include "task-list.h"
#include "wp-about-dialog.h"
#include "wp-applet.h"
#include "wp-preferences-dialog.h"
+#include "wp-task-title.h"
#define SETTINGS_SCHEMA "org.gnome.gnome-applets.window-picker-applet"
#define GRESOURCE "/org/gnome/gnome-applets/window-picker/"
+#define TITLE_BUTTON_SPACE 6
struct _WpApplet
{
@@ -49,8 +50,6 @@ struct _WpApplet
GtkWidget *preferences_dialog;
gboolean show_all_windows;
- gboolean show_application_title;
- gboolean show_home_title;
gboolean icons_greyscale;
gboolean expand_task_list;
@@ -63,8 +62,6 @@ enum
{
PROP_0,
PROP_SHOW_ALL_WINDOWS,
- PROP_SHOW_APPLICATION_TITLE,
- PROP_SHOW_HOME_TITLE,
PROP_ICONS_GREYSCALE,
PROP_EXPAND_TASK_LIST,
LAST_PROP
@@ -175,30 +172,54 @@ wp_applet_setup_menu (PanelApplet *applet)
}
static void
-wp_applet_load (PanelApplet *panel_applet)
+wp_applet_setup_list (WpApplet *applet)
{
- WpApplet *applet;
-
- applet = WP_APPLET (panel_applet);
-
- applet->settings = panel_applet_settings_new (panel_applet, SETTINGS_SCHEMA);
-
applet->tasks = task_list_new (applet);
+
gtk_box_pack_start (GTK_BOX (applet->container), applet->tasks,
FALSE, FALSE, 0);
+}
+
+static void
+wp_applet_setup_title (WpApplet *applet)
+{
+ PanelApplet *panel_applet;
+
+ panel_applet = PANEL_APPLET (applet);
+
+ applet->title = wp_task_title_new (TITLE_BUTTON_SPACE);
+
+ g_object_bind_property (applet->container, "orientation",
+ applet->title, "orientation",
+ G_BINDING_DEFAULT);
+
+ g_object_bind_property (panel_applet, "orient",
+ applet->title, "orient",
+ G_BINDING_DEFAULT);
- applet->title = task_title_new (applet);
gtk_box_pack_start (GTK_BOX (applet->container), applet->title,
FALSE, FALSE, 0);
+}
+
+static void
+wp_applet_load (PanelApplet *panel_applet)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (panel_applet);
+
+ applet->settings = panel_applet_settings_new (panel_applet, SETTINGS_SCHEMA);
g_settings_bind (applet->settings, KEY_SHOW_ALL_WINDOWS,
applet, KEY_SHOW_ALL_WINDOWS, G_SETTINGS_BIND_GET);
g_settings_bind (applet->settings, KEY_SHOW_APPLICATION_TITLE,
- applet, KEY_SHOW_APPLICATION_TITLE, G_SETTINGS_BIND_GET);
+ applet->title, KEY_SHOW_APPLICATION_TITLE,
+ G_SETTINGS_BIND_GET);
g_settings_bind (applet->settings, KEY_SHOW_HOME_TITLE,
- applet, KEY_SHOW_HOME_TITLE, G_SETTINGS_BIND_GET);
+ applet->title, KEY_SHOW_HOME_TITLE,
+ G_SETTINGS_BIND_GET);
g_settings_bind (applet->settings, KEY_ICONS_GREYSCALE,
applet, KEY_ICONS_GREYSCALE, G_SETTINGS_BIND_GET);
@@ -271,14 +292,6 @@ wp_applet_set_property (GObject *object,
applet->show_all_windows = g_value_get_boolean (value);
break;
- case PROP_SHOW_APPLICATION_TITLE:
- applet->show_application_title = g_value_get_boolean (value);
- break;
-
- case PROP_SHOW_HOME_TITLE:
- applet->show_home_title = g_value_get_boolean (value);
- break;
-
case PROP_ICONS_GREYSCALE:
applet->icons_greyscale = g_value_get_boolean (value);
break;
@@ -329,14 +342,6 @@ wp_applet_get_property (GObject *object,
g_value_set_boolean (value, applet->show_all_windows);
break;
- case PROP_SHOW_APPLICATION_TITLE:
- g_value_set_boolean (value, applet->show_application_title);
- break;
-
- case PROP_SHOW_HOME_TITLE:
- g_value_set_boolean (value, applet->show_home_title);
- break;
-
case PROP_ICONS_GREYSCALE:
g_value_set_boolean (value, applet->icons_greyscale);
break;
@@ -400,20 +405,6 @@ wp_applet_class_init (WpAppletClass *applet_class)
TRUE,
G_PARAM_READWRITE);
- properties[PROP_SHOW_APPLICATION_TITLE] =
- g_param_spec_boolean ("show-application-title",
- "Show Application Title",
- "Show the application title",
- FALSE,
- G_PARAM_READWRITE);
-
- properties[PROP_SHOW_HOME_TITLE] =
- g_param_spec_boolean ("show-home-title",
- "Show Home Title",
- "Show the home title and logout button",
- FALSE,
- G_PARAM_READWRITE);
-
properties[PROP_ICONS_GREYSCALE] =
g_param_spec_boolean ("icons-greyscale",
"Icons Greyscale",
@@ -448,6 +439,9 @@ wp_applet_init (WpApplet *applet)
applet->container = gtk_box_new (orientation, 10);
gtk_container_add (GTK_CONTAINER (applet), applet->container);
+ wp_applet_setup_list (applet);
+ wp_applet_setup_title (applet);
+
wp_applet_setup_menu (panel_applet);
}
@@ -464,18 +458,6 @@ wp_applet_get_show_all_windows(WpApplet *applet)
}
gboolean
-wp_applet_get_show_application_title (WpApplet *applet)
-{
- return applet->show_application_title;
-}
-
-gboolean
-wp_applet_get_show_home_title (WpApplet *applet)
-{
- return applet->show_home_title;
-}
-
-gboolean
wp_applet_get_icons_greyscale (WpApplet *applet)
{
return applet->icons_greyscale;
diff --git a/windowpicker/src/wp-applet.h b/windowpicker/src/wp-applet.h
index c54eeb1..feac05a 100644
--- a/windowpicker/src/wp-applet.h
+++ b/windowpicker/src/wp-applet.h
@@ -42,13 +42,11 @@ struct _WpAppletClass
PanelAppletClass parent_class;
};
-GType wp_applet_get_type (void) G_GNUC_CONST;
+GType wp_applet_get_type (void) G_GNUC_CONST;
-GtkWidget *wp_applet_get_tasks (WpApplet *applet);
-gboolean wp_applet_get_show_all_windows (WpApplet *applet);
-gboolean wp_applet_get_show_application_title (WpApplet *applet);
-gboolean wp_applet_get_show_home_title (WpApplet *applet);
-gboolean wp_applet_get_icons_greyscale (WpApplet *applet);
+GtkWidget *wp_applet_get_tasks (WpApplet *applet);
+gboolean wp_applet_get_show_all_windows (WpApplet *applet);
+gboolean wp_applet_get_icons_greyscale (WpApplet *applet);
G_END_DECLS
diff --git a/windowpicker/src/wp-task-title.c b/windowpicker/src/wp-task-title.c
new file mode 100644
index 0000000..f6b5d5f
--- /dev/null
+++ b/windowpicker/src/wp-task-title.c
@@ -0,0 +1,525 @@
+/*
+ * Copyright (C) 2008 Canonical Ltd
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alberts Muktupāvels <alberts muktupavels gmail com>
+ * Neil Jagdish Patel <neil patel canonical com>
+ * Sebastian Geiger <sbastig gmx net>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <libwnck/libwnck.h>
+#include <panel-applet.h>
+
+#include "wp-task-title.h"
+
+#define CLOSE_WINDOW_ICON "window-close"
+#define LOGOUT_ICON "gnome-logout"
+
+struct _WpTaskTitle
+{
+ GtkBox parent;
+
+ GtkWidget *label;
+ GtkWidget *button;
+ GtkWidget *image;
+
+ gboolean show_application_title;
+ gboolean show_home_title;
+ PanelAppletOrient applet_orient;
+
+ WnckWindow *active_window;
+};
+
+enum
+{
+ PROP_0,
+ PROP_SHOW_APPLICATION_TITLE,
+ PROP_SHOW_HOME_TITLE,
+ PROP_APPLET_ORIENT,
+ LAST_PROP
+};
+
+static GParamSpec *properties[LAST_PROP] = { NULL };
+
+G_DEFINE_TYPE (WpTaskTitle, wp_task_title, GTK_TYPE_BOX)
+
+static void disconnect_active_window (WpTaskTitle *title);
+
+static gboolean
+button_press_event_cb (GtkButton *button,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ WpTaskTitle *title;
+ const gchar *icon;
+
+ title = WP_TASK_TITLE (user_data);
+
+ gtk_image_get_icon_name (GTK_IMAGE (title->image), &icon, NULL);
+
+ if (g_strcmp0 (icon, CLOSE_WINDOW_ICON) == 0)
+ {
+ WnckScreen *screen;
+ WnckWindow *active_window;
+ GdkEventButton *event_button;
+
+ screen = wnck_screen_get_default ();
+ active_window = wnck_screen_get_active_window (screen);
+
+ if (WNCK_IS_WINDOW (active_window) == FALSE)
+ return FALSE;
+
+ if (title->active_window != active_window)
+ return FALSE;
+
+ event_button = (GdkEventButton *) event;
+
+ disconnect_active_window (title);
+ wnck_window_close (active_window, event_button->time);
+ }
+ else if (g_strcmp0 (icon, LOGOUT_ICON) == 0)
+ {
+ }
+ else
+ {
+ g_assert_not_reached ();
+ }
+
+ return FALSE;
+}
+
+static gboolean
+is_desktop_visible (void)
+{
+ WnckScreen *screen;
+ GList *windows;
+ GList *w;
+
+ screen = wnck_screen_get_default ();
+ windows = wnck_screen_get_windows (screen);
+
+ for (w = windows; w; w = w->next)
+ {
+ WnckWindow *window;
+ WnckWindowType type;
+
+ window = WNCK_WINDOW (w->data);
+
+ if (WNCK_IS_WINDOW (window) == FALSE)
+ continue;
+
+ type = wnck_window_get_window_type (window);
+
+ if (type == WNCK_WINDOW_DOCK || type == WNCK_WINDOW_SPLASHSCREEN ||
+ type == WNCK_WINDOW_MENU || type == WNCK_WINDOW_DESKTOP);
+ continue;
+
+ if (wnck_window_is_minimized (window) == FALSE)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+show_home_title (WpTaskTitle *title)
+{
+ const gchar *name;
+ const gchar *tooltip;
+
+ name = _("Home");
+ tooltip = _("Log off, switch user, lock screen or power down the computer");
+
+ gtk_label_set_text (GTK_LABEL (title->label), name);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (title), name);
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (title->image), LOGOUT_ICON,
+ GTK_ICON_SIZE_MENU);
+
+ gtk_widget_set_tooltip_text (title->button, tooltip);
+}
+
+static void
+show_application_title (WpTaskTitle *title)
+{
+ const gchar *name;
+ const gchar *tooltip;
+
+ name = wnck_window_get_name (title->active_window);
+ tooltip = _("Close window");
+
+ gtk_label_set_text (GTK_LABEL (title->label), name);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (title), name);
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (title->image), CLOSE_WINDOW_ICON,
+ GTK_ICON_SIZE_MENU);
+
+ gtk_widget_set_tooltip_text (title->button, tooltip);
+}
+
+static void
+update_title_visibility (WpTaskTitle *title)
+{
+ GtkWidget *widget;
+ WnckWindowType type;
+
+ widget = GTK_WIDGET (title);
+ type = WNCK_WINDOW_NORMAL;
+
+ gtk_widget_hide (widget);
+
+ if (title->show_application_title == FALSE && title->show_home_title == FALSE)
+ return;
+
+ if (title->active_window)
+ type = wnck_window_get_window_type (title->active_window);
+
+ if (title->active_window == NULL || type == WNCK_WINDOW_DESKTOP)
+ {
+ if (title->show_home_title == FALSE)
+ return;
+
+ if (is_desktop_visible () == FALSE)
+ return;
+
+ show_home_title (title);
+ }
+ else
+ {
+ if (title->show_application_title == FALSE)
+ return;
+
+ if (wnck_window_is_maximized (title->active_window) == FALSE)
+ return;
+
+ show_application_title (title);
+ }
+
+ gtk_widget_show (widget);
+}
+
+static void
+name_changed_cb (WnckWindow *window,
+ gpointer user_data)
+{
+ WpTaskTitle *title;
+
+ title = WP_TASK_TITLE (user_data);
+
+ update_title_visibility (title);
+}
+
+static void
+state_changed_cb (WnckWindow *window,
+ WnckWindowState changed_mask,
+ WnckWindowState new_state,
+ gpointer user_data)
+{
+ WpTaskTitle *title;
+
+ title = WP_TASK_TITLE (user_data);
+
+ update_title_visibility (title);
+}
+
+static void
+disconnect_active_window (WpTaskTitle *title)
+{
+ if (title->active_window == NULL)
+ return;
+
+ g_signal_handlers_disconnect_by_func (title->active_window,
+ name_changed_cb, title);
+ g_signal_handlers_disconnect_by_func (title->active_window,
+ state_changed_cb, title);
+
+ title->active_window = NULL;
+}
+
+static void
+active_window_changed_cb (WnckScreen *screen,
+ WnckWindow *previously_active_window,
+ gpointer user_data)
+{
+ WpTaskTitle *title;
+ WnckWindow *active_window;
+ WnckWindowType type;
+
+ title = WP_TASK_TITLE (user_data);
+
+ active_window = wnck_screen_get_active_window (screen);
+ type = WNCK_WINDOW_NORMAL;
+
+ if (WNCK_IS_WINDOW (active_window) == FALSE)
+ {
+ disconnect_active_window (title);
+ update_title_visibility (title);
+ return;
+ }
+
+ if (active_window)
+ type = wnck_window_get_window_type (active_window);
+
+ if (wnck_window_is_skip_tasklist (active_window) &&
+ type != WNCK_WINDOW_DESKTOP)
+ return;
+
+ if (type == WNCK_WINDOW_DOCK || type == WNCK_WINDOW_SPLASHSCREEN ||
+ type == WNCK_WINDOW_MENU)
+ return;
+
+ disconnect_active_window (title);
+
+ g_signal_connect_object (active_window, "name-changed",
+ G_CALLBACK (name_changed_cb), title,
+ G_CONNECT_AFTER);
+ g_signal_connect_object (active_window, "state-changed",
+ G_CALLBACK (state_changed_cb), title,
+ G_CONNECT_AFTER);
+
+ title->active_window = active_window;
+ update_title_visibility (title);
+}
+
+static void
+update_label_rotation (WpTaskTitle *title)
+{
+ gdouble angle;
+
+ if (title->applet_orient == PANEL_APPLET_ORIENT_RIGHT ||
+ title->applet_orient == PANEL_APPLET_ORIENT_LEFT)
+ angle = 270;
+ else
+ angle = 0;
+
+ gtk_label_set_angle (GTK_LABEL (title->label), angle);
+}
+
+static void
+wp_task_title_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ WpTaskTitle *title;
+ gboolean show_application_title;
+ gboolean show_home_title;
+ PanelAppletOrient orient;
+
+ title = WP_TASK_TITLE (object);
+
+ switch (property_id)
+ {
+ case PROP_SHOW_APPLICATION_TITLE:
+ show_application_title = g_value_get_boolean (value);
+
+ if (title->show_application_title != show_application_title)
+ {
+ title->show_application_title = show_application_title;
+ update_title_visibility (title);
+ }
+ break;
+
+ case PROP_SHOW_HOME_TITLE:
+ show_home_title = g_value_get_boolean (value);
+
+ if (title->show_home_title != show_home_title)
+ {
+ title->show_home_title = show_home_title;
+ update_title_visibility (title);
+ }
+ break;
+
+ case PROP_APPLET_ORIENT:
+ orient = g_value_get_uint (value);
+
+ if (title->applet_orient != orient)
+ {
+ title->applet_orient = g_value_get_uint (value);
+ update_label_rotation (title);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+wp_task_title_class_init (WpTaskTitleClass *title_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (title_class);
+
+ object_class->set_property = wp_task_title_set_property;
+
+ properties[PROP_SHOW_APPLICATION_TITLE] =
+ g_param_spec_boolean ("show-application-title",
+ "Show Application Title",
+ "Show the application title",
+ FALSE,
+ G_PARAM_WRITABLE);
+
+ properties[PROP_SHOW_HOME_TITLE] =
+ g_param_spec_boolean ("show-home-title",
+ "Show Home Title",
+ "Show the home title and logout button",
+ FALSE,
+ G_PARAM_WRITABLE);
+
+ properties[PROP_APPLET_ORIENT] =
+ g_param_spec_uint ("orient",
+ "Orient",
+ "Panel Applet Orientation",
+ PANEL_APPLET_ORIENT_FIRST,
+ PANEL_APPLET_ORIENT_LAST,
+ PANEL_APPLET_ORIENT_UP,
+ G_PARAM_WRITABLE);
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+}
+
+static gboolean
+label_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ WpTaskTitle *title;
+
+ title = WP_TASK_TITLE (user_data);
+
+ if (event->button == 3)
+ {
+ WnckWindowType type;
+
+ type = wnck_window_get_window_type (title->active_window);
+
+ if (type != WNCK_WINDOW_DESKTOP)
+ {
+ GtkWidget *menu;
+
+ menu = wnck_action_menu_new (title->active_window);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+ event->button, event->time);
+
+ return TRUE;
+ }
+ }
+ else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
+ {
+ if (wnck_window_is_maximized (title->active_window))
+ wnck_window_unmaximize (title->active_window);
+ }
+
+ return FALSE;
+}
+
+static void
+wp_task_title_setup_label (WpTaskTitle *title)
+{
+ GtkWidget *event_box;
+ PangoAttrList *attr_list;
+ PangoAttribute *attr;
+
+ event_box = gtk_event_box_new ();
+
+ gtk_widget_add_events (GTK_WIDGET (event_box), GDK_BUTTON_PRESS_MASK);
+
+ g_signal_connect (event_box, "button-press-event",
+ G_CALLBACK (label_button_press_event_cb), title);
+
+ gtk_box_pack_start (GTK_BOX (title), event_box, FALSE, FALSE, 0);
+ gtk_widget_show (event_box);
+
+ title->label = gtk_label_new (NULL);
+ attr_list = pango_attr_list_new ();
+ attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+
+ pango_attr_list_insert (attr_list, attr);
+
+ gtk_label_set_ellipsize (GTK_LABEL (title->label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_attributes (GTK_LABEL (title->label), attr_list);
+ pango_attr_list_unref (attr_list);
+
+ gtk_container_add (GTK_CONTAINER (event_box), title->label);
+ gtk_widget_show (title->label);
+}
+
+static void
+wp_task_title_setup_button (WpTaskTitle *title)
+{
+ GtkWidget *widget;
+
+ title->button = gtk_button_new ();
+ title->image = gtk_image_new ();
+
+ widget = GTK_WIDGET (title->button);
+
+ gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
+
+ gtk_button_set_image (GTK_BUTTON (widget), title->image);
+ gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
+
+ gtk_box_pack_start (GTK_BOX (title), title->button, FALSE, FALSE, 0);
+ gtk_widget_show (title->button);
+
+ g_signal_connect (title->button, "button-press-event",
+ G_CALLBACK (button_press_event_cb), title);
+}
+
+static void
+wp_task_title_setup_wnck (WpTaskTitle *title)
+{
+ WnckScreen *screen;
+
+ screen = wnck_screen_get_default ();
+
+ g_signal_connect_object (screen, "active-window-changed",
+ G_CALLBACK (active_window_changed_cb), title,
+ G_CONNECT_AFTER);
+
+ active_window_changed_cb (screen, NULL, title);
+}
+
+static void
+wp_task_title_init (WpTaskTitle *title)
+{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (title);
+
+ gtk_widget_set_name (widget, "tasklist-button");
+
+ wp_task_title_setup_label (title);
+ wp_task_title_setup_button (title);
+ wp_task_title_setup_wnck (title);
+}
+
+GtkWidget *
+wp_task_title_new (gint spacing)
+{
+ return g_object_new (WP_TYPE_TASK_TITLE,
+ "spacing", spacing,
+ NULL);
+}
diff --git a/windowpicker/src/wp-task-title.h b/windowpicker/src/wp-task-title.h
new file mode 100644
index 0000000..4450e31
--- /dev/null
+++ b/windowpicker/src/wp-task-title.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Canonical Ltd
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Alberts Muktupāvels <alberts muktupavels gmail com>
+ * Neil Jagdish Patel <neil patel canonical com>
+ */
+
+#ifndef WP_TASK_TITLE_H
+#define WP_TASK_TITLE_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define WP_TYPE_TASK_TITLE wp_task_title_get_type ()
+G_DECLARE_FINAL_TYPE (WpTaskTitle, wp_task_title, WP, TASK_TITLE, GtkBox)
+
+GtkWidget *wp_task_title_new (gint spacing);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]