[gnome-applets/wip/window-picker-applet] window-picker-applet: stop using global variable
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/window-picker-applet] window-picker-applet: stop using global variable
- Date: Fri, 19 Sep 2014 07:34:54 +0000 (UTC)
commit dabed6b86c78184b1bd65f2e1844bd38790a6ae8
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Sep 19 10:29:41 2014 +0300
window-picker-applet: stop using global variable
1. Update WindowPicker applet to subclass PanelApplet instead of
using global variable.
2. Use G_DEFINE_TYPE_WITH_PRIVATE for types with private data.
3. Fix bug - all applets initially empty except first.
Thanks to Sebastian Geiger!
...rg.gnome.window-picker-applet.gschema.xml.in.in | 2 +-
window-picker-applet/src/Makefile.am | 11 +-
window-picker-applet/src/applet.c | 264 -----------
window-picker-applet/src/common.h | 36 --
window-picker-applet/src/task-item.c | 79 ++--
window-picker-applet/src/task-item.h | 9 +-
window-picker-applet/src/task-list.c | 230 +++++-----
window-picker-applet/src/task-list.h | 11 +-
window-picker-applet/src/task-title.c | 213 +++++----
window-picker-applet/src/task-title.h | 7 +-
window-picker-applet/src/window-picker.c | 483 ++++++++++++++++++++
window-picker-applet/src/window-picker.h | 55 +++
12 files changed, 836 insertions(+), 564 deletions(-)
---
diff --git a/window-picker-applet/data/org.gnome.window-picker-applet.gschema.xml.in.in
b/window-picker-applet/data/org.gnome.window-picker-applet.gschema.xml.in.in
index a34983b..0090390 100644
--- a/window-picker-applet/data/org.gnome.window-picker-applet.gschema.xml.in.in
+++ b/window-picker-applet/data/org.gnome.window-picker-applet.gschema.xml.in.in
@@ -12,7 +12,7 @@
<default>false</default>
<summary>Show the application title when an application is active and maximized</summary>
</key>
- <key name="icons-greyscale-mask" type="b">
+ <key name="icons-greyscale" type="b">
<default>false</default>
<summary>All icons except the current active window icon are greyed out.
Disable to have colored icons for all windows</summary>
diff --git a/window-picker-applet/src/Makefile.am b/window-picker-applet/src/Makefile.am
index 65fdeeb..09593ae 100644
--- a/window-picker-applet/src/Makefile.am
+++ b/window-picker-applet/src/Makefile.am
@@ -7,12 +7,9 @@ AM_CFLAGS=\
$(GCC_FLAGS) \
-I$(top_builddir) \
-I$(top_srcdir) \
- -D_GNU_SOURCE \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DPKGDATADIR=\"$(PKGDATADIR)\" \
-DWINDOW_PICKER_MENU_UI_DIR=\"$(datadir)/$(PACKAGE)/ui\" \
-DWNCK_I_KNOW_THIS_IS_UNSTABLE=1 \
- -DGTK_DISABLE_SINGLE_INCLUDES \
-lm
window_picker_applet_LDADD = \
@@ -20,13 +17,13 @@ window_picker_applet_LDADD = \
$(LIBWNCK_LIBS)
window_picker_applet_SOURCES = \
- applet.c \
- task-item.c \
- task-item.h \
+ window-picker.c \
+ window-picker.h \
task-list.c \
task-list.h \
task-title.c \
task-title.h \
- common.h
+ task-item.c \
+ task-item.h
-include $(top_srcdir)/git.mk
diff --git a/window-picker-applet/src/task-item.c b/window-picker-applet/src/task-item.c
index aec479a..b6f027a 100644
--- a/window-picker-applet/src/task-item.c
+++ b/window-picker-applet/src/task-item.c
@@ -19,7 +19,6 @@
#include "task-item.h"
#include "task-list.h"
-#include "common.h"
#include <math.h>
#include <glib/gi18n.h>
@@ -43,6 +42,7 @@ struct _TaskItemPrivate {
GTimeVal urgent_time;
guint timer;
gboolean mouse_over;
+ WindowPicker *picker;
};
enum {
@@ -159,7 +159,7 @@ static void task_item_set_visibility (TaskItem *item) {
window = priv->window;
screen = priv->screen;
workspace = wnck_screen_get_active_workspace (screen);
- gboolean show_all = task_list_get_show_all_windows (TASK_LIST (task_list_get_default ()));
+ gboolean show_all = window_picker_get_show_all_windows (priv->picker);
gboolean show_window = FALSE;
if (!wnck_window_is_skip_tasklist (window)) {
if(workspace != NULL) { //this can happen sometimes
@@ -251,8 +251,7 @@ static gboolean task_item_draw (
gint size = MIN (area.height, area.width);
gboolean active = wnck_window_is_active (priv->window);
/* load the GSettings key for gray icons */
- gboolean icons_greyscale = g_settings_get_boolean (
- mainapp->settings, ICONS_GREYSCALE_KEY);
+ gboolean icons_greyscale = window_picker_get_icons_greyscale (priv->picker);
gboolean attention = wnck_window_or_transient_needs_attention (priv->window);
if (GDK_IS_PIXBUF (pbuf) &&
gdk_pixbuf_get_width (pbuf) != size &&
@@ -666,32 +665,42 @@ static void on_drag_received_data (
guint time,
gpointer *user_data)
{
- if((selection_data != NULL) && (gtk_selection_data_get_length(selection_data) >= 0)) {
- gint active;
- switch (target_type) {
- case TARGET_WIDGET_DRAGED: {
- GtkWidget *taskList = mainapp->tasks;
- gpointer *data = (gpointer *) gtk_selection_data_get_data(selection_data);
- g_assert(GTK_IS_WIDGET(*data));
- GtkWidget *taskItem = GTK_WIDGET(*data);
- g_assert(TASK_IS_ITEM(taskItem));
- if(taskItem == widget) break; //source and target are identical
- gint target_position = grid_get_pos(mainapp->tasks, widget);
- g_object_ref(taskItem);
- gtk_box_reorder_child(GTK_BOX(taskList), taskItem, target_position);
- g_object_unref(taskItem);
- break;
- }
- default:
- active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "drag-true"));
- if (!active) {
- g_object_set_data (
- G_OBJECT (widget), "drag-true", GINT_TO_POINTER (1)
- );
- g_timeout_add (1000, (GSourceFunc)activate_window, widget);
- }
- }
- }
+ gpointer *data;
+ GtkWidget *taskItem;
+ GtkWidget *taskList;
+ TaskItem *item;
+ gint active;
+
+ if (!selection_data || gtk_selection_data_get_length (selection_data) == 0)
+ return;
+
+ item = TASK_ITEM (user_data);
+
+ switch (target_type) {
+ case TARGET_WIDGET_DRAGED:
+ taskList = window_picker_get_task_list (item->priv->picker);
+ data = (gpointer *) gtk_selection_data_get_data (selection_data);
+ g_assert (GTK_IS_WIDGET (*data));
+
+ taskItem = GTK_WIDGET (*data);
+ g_assert (TASK_IS_ITEM (taskItem));
+
+ if (taskItem == widget)
+ break; //source and target are identical
+
+ gint target_position = grid_get_pos (taskList, widget);
+ g_object_ref (taskItem);
+ gtk_box_reorder_child (GTK_BOX (taskList), taskItem, target_position);
+ g_object_unref (taskItem);
+ break;
+ default:
+ active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "drag-true"));
+ if (!active) {
+ g_object_set_data (G_OBJECT (widget), "drag-true", GINT_TO_POINTER (1));
+ g_timeout_add (1000, (GSourceFunc) activate_window, widget);
+ }
+ break;
+ }
}
static void task_item_setup_atk (TaskItem *item) {
@@ -744,7 +753,10 @@ static void task_item_init (TaskItem *item) {
g_signal_connect(item, "draw", G_CALLBACK(task_item_draw), NULL);
}
-GtkWidget *task_item_new (WnckWindow *window) {
+GtkWidget *
+task_item_new (WindowPicker *picker,
+ WnckWindow *window)
+{
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
TaskItem *task;
TaskItemPrivate *priv;
@@ -764,6 +776,7 @@ GtkWidget *task_item_new (WnckWindow *window) {
priv->window = window;
screen = wnck_window_get_screen (window);
priv->screen = screen;
+ priv->picker = picker;
/** Drag and Drop code
* This item can be both the target and the source of a drag and drop
@@ -795,8 +808,8 @@ GtkWidget *task_item_new (WnckWindow *window) {
G_CALLBACK (on_drag_motion), item);
g_signal_connect (item, "drag-leave",
G_CALLBACK (on_drag_leave), item);
- g_signal_connect (item, "drag_data_received",
- G_CALLBACK(on_drag_received_data), NULL);
+ g_signal_connect (item, "drag-data-received",
+ G_CALLBACK(on_drag_received_data), item);
g_signal_connect (item, "drag-drop",
G_CALLBACK (on_drag_drop), NULL);
g_signal_connect (item, "drag-end",
diff --git a/window-picker-applet/src/task-item.h b/window-picker-applet/src/task-item.h
index 8273c3d..34f9215 100644
--- a/window-picker-applet/src/task-item.h
+++ b/window-picker-applet/src/task-item.h
@@ -21,10 +21,10 @@
#ifndef _TASK_ITEM_H_
#define _TASK_ITEM_H_
-#include <glib.h>
-#include <gtk/gtk.h>
#include <libwnck/libwnck.h>
+#include "window-picker.h"
+
#define TASK_TYPE_ITEM (task_item_get_type ())
#define TASK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
@@ -56,7 +56,8 @@ struct _TaskItemClass {
void (* itemclosed) (TaskItem *item);
};
-GType task_item_get_type (void) G_GNUC_CONST;
-GtkWidget * task_item_new (WnckWindow *window);
+GType task_item_get_type (void);
+GtkWidget *task_item_new (WindowPicker *picker,
+ WnckWindow *window);
#endif /* _TASK_ITEM_H_ */
diff --git a/window-picker-applet/src/task-list.c b/window-picker-applet/src/task-list.c
index cc1864e..000c973 100644
--- a/window-picker-applet/src/task-list.c
+++ b/window-picker-applet/src/task-list.c
@@ -17,43 +17,26 @@
*
*/
-#include "task-list.h"
-#include "task-item.h"
-
-#include "common.h"
-
#include <libwnck/libwnck.h>
-#include <panel-applet.h>
-
-WinPickerApp *mainapp;
-G_DEFINE_TYPE (TaskList, task_list, GTK_TYPE_BOX);
-
-#define TASK_LIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
- TASK_TYPE_LIST, \
- TaskListPrivate))
+#include "task-list.h"
+#include "task-item.h"
struct _TaskListPrivate {
- WnckScreen *screen;
- GHashTable *win_table;
- guint timer;
- guint counter;
- gboolean show_all_windows;
+ WnckScreen *screen;
+ GHashTable *win_table;
+ guint timer;
+ guint counter;
+
+ WindowPicker *picker;
};
enum {
- PROP_0,
- PROP_SHOW_ALL_WINDOWS
+ PROP_0,
+ PROP_WINDOW_PICKER
};
-static void task_list_set_show_all_windows (
- TaskList *list,
- gboolean show_all_windows)
-{
- TaskListPrivate *priv = list->priv;
- priv->show_all_windows = show_all_windows;
- g_debug ("Show all windows: %s", show_all_windows ? "true" : "false");
-}
+G_DEFINE_TYPE_WITH_PRIVATE (TaskList, task_list, GTK_TYPE_BOX);
static void on_task_item_closed (
TaskItem *item,
@@ -79,7 +62,7 @@ static void on_window_opened (WnckScreen *screen,
{
return;
}
- GtkWidget *item = task_item_new (window);
+ GtkWidget *item = task_item_new (list->priv->picker, window);
if (item) {
//we add items dynamically to the end of the list
gtk_container_add(GTK_CONTAINER(list), item);
@@ -96,42 +79,42 @@ static void task_list_finalize (GObject *object) {
G_OBJECT_CLASS (task_list_parent_class)->finalize (object);
}
-static void task_list_get_property (
- GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+static void
+task_list_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- TaskList *list = TASK_LIST (object);
- TaskListPrivate *priv;
- g_return_if_fail (TASK_IS_LIST (list));
- priv = list->priv;
- switch (prop_id) {
- case PROP_SHOW_ALL_WINDOWS:
- g_value_set_boolean (value, priv->show_all_windows);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ TaskList *list = TASK_LIST (object);
+ g_return_if_fail (TASK_IS_LIST (list));
+
+ switch (prop_id) {
+ case PROP_WINDOW_PICKER:
+ g_value_set_pointer (value, list->priv->picker);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-static void task_list_set_property (
- GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+static void
+task_list_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- TaskList *list = TASK_LIST (object);
- g_return_if_fail (TASK_IS_LIST (list));
- switch (prop_id) {
- case PROP_SHOW_ALL_WINDOWS:
- task_list_set_show_all_windows (
- list, g_value_get_boolean (value)
- );
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ TaskList *list = TASK_LIST (object);
+ g_return_if_fail (TASK_IS_LIST (list));
+
+ switch (prop_id) {
+ case PROP_WINDOW_PICKER:
+ list->priv->picker = g_value_get_pointer (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void on_task_list_orient_changed(PanelApplet *applet,
@@ -155,69 +138,33 @@ static void on_task_list_orient_changed(PanelApplet *applet,
gtk_widget_queue_resize(GTK_WIDGET(box));
}
-static void task_list_class_init (TaskListClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
- obj_class->finalize = task_list_finalize;
- obj_class->set_property = task_list_set_property;
- obj_class->get_property = task_list_get_property;
- g_object_class_install_property (
- obj_class,
- PROP_SHOW_ALL_WINDOWS,
- g_param_spec_boolean ("show_all_windows",
- "Show All Windows",
- "Show windows from all workspaces",
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT
- )
- );
- g_type_class_add_private (obj_class, sizeof (TaskListPrivate));
-}
-
-static void task_list_init (TaskList *list) {
- TaskListPrivate *priv = list->priv = TASK_LIST_GET_PRIVATE (list);
- priv->screen = wnck_screen_get_default ();
- priv->win_table = g_hash_table_new (NULL, NULL);
- /* No blink timer */
- priv->timer = 0;
- gtk_container_set_border_width (GTK_CONTAINER (list), 0);
- g_signal_connect (priv->screen, "window-opened",
- G_CALLBACK (on_window_opened), list);
+static void
+task_list_class_init (TaskListClass *class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS (class);
+
+ obj_class->finalize = task_list_finalize;
+ obj_class->set_property = task_list_set_property;
+ obj_class->get_property = task_list_get_property;
+
+ g_object_class_install_property (obj_class,
+ PROP_WINDOW_PICKER,
+ g_param_spec_pointer ("picker",
+ "Window Picker",
+ "The Window Picker",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}
-GtkWidget *task_list_new (void) {
- PanelAppletOrient panel_orientation = panel_applet_get_orient(PANEL_APPLET(mainapp->applet));
- GtkOrientation orientation;
- switch(panel_orientation) {
- case PANEL_APPLET_ORIENT_UP:
- case PANEL_APPLET_ORIENT_DOWN:
- orientation = GTK_ORIENTATION_HORIZONTAL;
- break;
- case PANEL_APPLET_ORIENT_LEFT:
- case PANEL_APPLET_ORIENT_RIGHT:
- orientation = GTK_ORIENTATION_VERTICAL;
- break;
- default:
- orientation = GTK_ORIENTATION_HORIZONTAL;
- }
- GtkWidget* list = g_object_new (
- TASK_TYPE_LIST,
- "orientation", orientation,
- "homogeneous", FALSE,
- "spacing", 0,
- NULL
- );
-
- g_signal_connect(mainapp->applet, "change-orient",
- G_CALLBACK(on_task_list_orient_changed), list);
+static void
+task_list_init (TaskList *list)
+{
+ list->priv = task_list_get_instance_private (list);
- return list;
-}
+ list->priv->screen = wnck_screen_get_default ();
+ list->priv->win_table = g_hash_table_new (NULL, NULL);
+ list->priv->timer = 0;
-GtkWidget *task_list_get_default (void) {
- static GtkWidget *list = NULL;
- if (!list)
- list = task_list_new ();
- return list;
+ gtk_container_set_border_width (GTK_CONTAINER (list), 0);
}
gboolean task_list_get_desktop_visible (TaskList *list) {
@@ -238,6 +185,45 @@ gboolean task_list_get_desktop_visible (TaskList *list) {
return all_minimised;
}
-gboolean task_list_get_show_all_windows (TaskList *list) {
- return list->priv->show_all_windows;
+GtkWidget *
+task_list_new (WindowPicker *picker)
+{
+ TaskList *list;
+ PanelAppletOrient panel_orientation;
+ GtkOrientation orientation;
+ GList *windows;
+
+ panel_orientation = panel_applet_get_orient (PANEL_APPLET (picker));
+
+ switch (panel_orientation) {
+ case PANEL_APPLET_ORIENT_LEFT:
+ case PANEL_APPLET_ORIENT_RIGHT:
+ orientation = GTK_ORIENTATION_VERTICAL;
+ break;
+ case PANEL_APPLET_ORIENT_UP:
+ case PANEL_APPLET_ORIENT_DOWN:
+ default:
+ orientation = GTK_ORIENTATION_HORIZONTAL;
+ break;
+ }
+
+ list = g_object_new (TASK_TYPE_LIST,
+ "orientation", orientation,
+ "homogeneous", FALSE,
+ "spacing", 0,
+ "picker", picker,
+ NULL);
+
+ g_signal_connect (PANEL_APPLET (picker), "change-orient",
+ G_CALLBACK (on_task_list_orient_changed), list);
+ g_signal_connect (list->priv->screen, "window-opened",
+ G_CALLBACK (on_window_opened), list);
+
+ windows = wnck_screen_get_windows (list->priv->screen);
+ while (windows != NULL) {
+ on_window_opened (list->priv->screen, windows->data, list);
+ windows = windows->next;
+ }
+
+ return GTK_WIDGET (list);
}
diff --git a/window-picker-applet/src/task-list.h b/window-picker-applet/src/task-list.h
index 4aa7c70..f142ab7 100644
--- a/window-picker-applet/src/task-list.h
+++ b/window-picker-applet/src/task-list.h
@@ -20,8 +20,7 @@
#ifndef _TASK_LIST_H_
#define _TASK_LIST_H_
-#include <glib.h>
-#include <gtk/gtk.h>
+#include "window-picker.h"
#define TASK_TYPE_LIST (task_list_get_type ())
@@ -53,10 +52,8 @@ struct _TaskListClass {
GtkGridClass parent_class;
};
-GType task_list_get_type (void) G_GNUC_CONST;
-GtkWidget * task_list_new (void);
-GtkWidget * task_list_get_default (void);
-gboolean task_list_get_desktop_visible (TaskList *list);
-gboolean task_list_get_show_all_windows (TaskList *list);
+GType task_list_get_type (void);
+GtkWidget *task_list_new (WindowPicker *picker);
+gboolean task_list_get_desktop_visible (TaskList *list);
#endif /* _TASK_LIST_H_ */
diff --git a/window-picker-applet/src/task-title.c b/window-picker-applet/src/task-title.c
index 7f43ff5..8bd9d2e 100644
--- a/window-picker-applet/src/task-title.c
+++ b/window-picker-applet/src/task-title.c
@@ -21,40 +21,33 @@
#include <config.h>
#endif
-#include "task-title.h"
-
#include <libwnck/libwnck.h>
-#include <panel-applet.h>
-#include <panel-applet-gconf.h>
#include <glib/gi18n-lib.h>
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-
-#include "common.h"
#include "task-list.h"
+#include "task-title.h"
-G_DEFINE_TYPE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX);
-
-#define TASK_TITLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
- TASK_TYPE_TITLE, \
- TaskTitlePrivate))
+struct _TaskTitlePrivate {
+ WnckScreen *screen;
+ WnckWindow *window;
+ GtkWidget *align;
+ GtkWidget *grid;
+ GtkWidget *label;
+ GtkWidget *button;
+ GtkWidget *button_image;
+ GdkPixbuf *quit_icon;
+ gboolean mouse_in_close_button;
+
+ WindowPicker *picker;
+};
-struct _TaskTitlePrivate
-{
- WnckScreen *screen;
- WnckWindow *window;
- GtkWidget *align;
- GtkWidget *grid;
- GtkWidget *label;
- GtkWidget *button;
- GtkWidget *button_image;
- GdkPixbuf *quit_icon;
- gboolean show_home_title;
- gboolean show_application_title;
- gboolean mouse_in_close_button;
+enum {
+ PROP_0,
+ PROP_WINDOW_PICKER
};
+G_DEFINE_TYPE_WITH_PRIVATE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX);
+
static void disconnect_window (TaskTitle *title);
/**
@@ -150,10 +143,10 @@ static void on_state_changed (WnckWindow *window,
if (priv->window != window)
return;
if (wnck_window_is_maximized (window)) {
- gtk_widget_set_state (GTK_WIDGET (title), GTK_STATE_ACTIVE);
+ gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_ACTIVE, TRUE);
gtk_widget_show (priv->grid);
} else {
- gtk_widget_set_state (GTK_WIDGET (title), GTK_STATE_NORMAL);
+ gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_NORMAL, TRUE);
gtk_widget_hide (priv->grid);
}
}
@@ -191,7 +184,7 @@ static void show_home_title(TaskTitle *title) {
* Hides the task title and resets its contents
*/
static void hide_title(TaskTitle *title) {
- gtk_widget_set_state (GTK_WIDGET (title), GTK_STATE_NORMAL);
+ gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_NORMAL, TRUE);
gtk_widget_set_tooltip_text (title->priv->button, NULL);
gtk_widget_set_tooltip_text (GTK_WIDGET (title), NULL);
gtk_widget_hide (title->priv->grid);
@@ -215,7 +208,7 @@ static void on_active_window_changed (WnckScreen *screen,
if(type == WNCK_WINDOW_DESKTOP) {
/* The current window is the desktop so we show the home title if
* the user has configured this, otherwise we hide the title */
- if (priv->show_home_title) {
+ if (window_picker_get_show_home_title (priv->picker)) {
show_home_title(title);
} else {
hide_title (title);
@@ -232,12 +225,12 @@ static void on_active_window_changed (WnckScreen *screen,
{
return;
} else { //for all other types
- if(wnck_window_is_maximized (act_window) && priv->show_application_title) {
+ if(wnck_window_is_maximized (act_window) && window_picker_get_show_application_title
(priv->picker)) {
//show normal title of window
gtk_label_set_text (GTK_LABEL (priv->label),
wnck_window_get_name (act_window));
- gtk_image_set_from_stock (GTK_IMAGE (priv->button_image),
- GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->button_image),
+ "window-close", GTK_ICON_SIZE_MENU);
gtk_widget_set_tooltip_text (GTK_WIDGET (title),
wnck_window_get_name (act_window));
gtk_widget_set_tooltip_text (priv->button, _("Close window"));
@@ -252,8 +245,8 @@ static void on_active_window_changed (WnckScreen *screen,
}
}
} else { //its not a window
- if (task_list_get_desktop_visible (TASK_LIST (task_list_get_default ()))
- && priv->show_home_title)
+ if (task_list_get_desktop_visible (TASK_LIST (window_picker_get_task_list (priv->picker)))
+ && window_picker_get_show_home_title (priv->picker))
{
show_home_title(title);
} else { //reset the task title and hide it
@@ -300,7 +293,7 @@ static gboolean on_draw (
cairo_t *cr,
gpointer userdata)
{
- if (gtk_widget_get_state(widget) == GTK_STATE_ACTIVE) {
+ if (gtk_widget_get_state_flags (widget) == GTK_STATE_FLAG_ACTIVE) {
//window is either maximized or we are on the desktop
GtkStyleContext *context = gtk_widget_get_style_context (widget);
gtk_render_frame (
@@ -362,36 +355,19 @@ static GtkWidget *getCloseButton(TaskTitle* title) {
return button;
}
-/**
- * This callback is used to listen to changed signals in the GSettings object.
- * If one of the values 'show-home-title' or 'show-application-title' changes,
- * then we need to update our private structure.
- */
-static void on_gsettings_key_changed (
- GSettings *settings,
- gchar *key,
- gpointer user_data)
+static void
+task_title_init (TaskTitle *title)
{
- TaskTitlePrivate *priv = (TaskTitlePrivate *) user_data;
- priv->show_application_title = g_settings_get_boolean (mainapp->settings,
- SHOW_APPLICATION_TITLE_KEY);
- priv->show_home_title = g_settings_get_boolean (mainapp->settings,
- SHOW_HOME_TITLE_KEY);
+ title->priv = task_title_get_instance_private (title);
}
-/* The following methods contain the GObject code for the class lifecycle */
-static void task_title_init (TaskTitle *title) {
- GSettings *gsettings = mainapp->settings;
+static void
+task_title_setup (TaskTitle *title)
+{
int width, height;
- TaskTitlePrivate *priv = title->priv = TASK_TITLE_GET_PRIVATE (title);
+ TaskTitlePrivate *priv = title->priv;
priv->screen = wnck_screen_get_default ();
priv->window = NULL;
- priv->show_home_title = g_settings_get_boolean (
- gsettings, SHOW_HOME_TITLE_KEY
- );
- priv->show_application_title = g_settings_get_boolean (
- gsettings, SHOW_APPLICATION_TITLE_KEY
- );
gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
priv->align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (priv->align),
@@ -419,12 +395,9 @@ static void task_title_init (TaskTitle *title) {
// Prepare and add the logoff icon to the title
GdkScreen *gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
GtkIconTheme *theme = gtk_icon_theme_get_for_screen (gdkscreen);
- GtkSettings *settings = gtk_settings_get_for_screen (gdkscreen);
- gtk_icon_size_lookup_for_settings (
- settings,
- GTK_ICON_SIZE_MENU,
- &width, &height
- );
+
+ width = height = 16;
+
//this shows a little green exit icon, like the ones on emergency exits
priv->quit_icon = gtk_icon_theme_load_icon (
theme, "gnome-logout", width, 0, NULL
@@ -437,8 +410,8 @@ static void task_title_init (TaskTitle *title) {
"power down the computer")
);
gtk_widget_set_tooltip_text (GTK_WIDGET (title), _("Home"));
- if (priv->show_home_title)
- gtk_widget_set_state (GTK_WIDGET (title), GTK_STATE_ACTIVE);
+ if (window_picker_get_show_home_title (priv->picker))
+ gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_ACTIVE, TRUE);
else
gtk_widget_hide (priv->grid);
gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
@@ -446,12 +419,27 @@ static void task_title_init (TaskTitle *title) {
G_CALLBACK (on_active_window_changed), title);
g_signal_connect (title, "button-press-event",
G_CALLBACK (on_button_press), NULL);
- g_signal_connect (mainapp->settings, "changed",
- G_CALLBACK (on_gsettings_key_changed), priv);
}
-/* Destructor for the task title*/
-static void task_title_finalize (GObject *object) {
+static GObject *
+task_title_constructor (GType type,
+ guint n_construct_params,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ TaskTitle *title;
+
+ object = G_OBJECT_CLASS (task_title_parent_class)->constructor (type, n_construct_params,
construct_params);
+ title = TASK_TITLE (object);
+
+ task_title_setup (title);
+
+ return object;
+}
+
+static void
+task_title_finalize (GObject *object)
+{
TaskTitlePrivate *priv;
priv = TASK_TITLE (object)->priv;
disconnect_window (TASK_TITLE (object));
@@ -459,20 +447,73 @@ static void task_title_finalize (GObject *object) {
G_OBJECT_CLASS (task_title_parent_class)->finalize (object);
}
-/* Class initialization */
-static void task_title_class_init (TaskTitleClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS (klass);
- obj_class->finalize = task_title_finalize;
- g_type_class_add_private (obj_class, sizeof (TaskTitlePrivate));
+static void
+task_title_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TaskTitle *title = TASK_TITLE (object);
+ g_return_if_fail (TASK_IS_TITLE (title));
+
+ switch (prop_id) {
+ case PROP_WINDOW_PICKER:
+ g_value_set_pointer (value, title->priv->picker);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
-/* Constructor for our task title, creates a new TaskTitle object */
-GtkWidget *task_title_new (void) {
- GtkWidget *title = g_object_new (TASK_TYPE_TITLE,
- "border-width", 0,
- "name", "tasklist-button",
- "visible-window", FALSE,
- NULL
- );
- return title;
+static void
+task_title_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ TaskTitle *title = TASK_TITLE (object);
+ g_return_if_fail (TASK_IS_TITLE (title));
+
+ switch (prop_id) {
+ case PROP_WINDOW_PICKER:
+ title->priv->picker = g_value_get_pointer (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+task_title_class_init (TaskTitleClass *class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS (class);
+
+ obj_class->constructor = task_title_constructor;
+ obj_class->finalize = task_title_finalize;
+ obj_class->set_property = task_title_set_property;
+ obj_class->get_property = task_title_get_property;
+
+ g_object_class_install_property (obj_class,
+ PROP_WINDOW_PICKER,
+ g_param_spec_pointer ("picker",
+ "Window Picker",
+ "The Window Picker",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+GtkWidget *
+task_title_new (WindowPicker *picker)
+{
+ GtkWidget *title;
+
+ title = g_object_new (TASK_TYPE_TITLE,
+ "border-width", 0,
+ "name", "tasklist-button",
+ "visible-window", FALSE,
+ "picker", picker,
+ NULL);
+
+ return title;
}
diff --git a/window-picker-applet/src/task-title.h b/window-picker-applet/src/task-title.h
index cf99a91..ff62efc 100644
--- a/window-picker-applet/src/task-title.h
+++ b/window-picker-applet/src/task-title.h
@@ -20,8 +20,7 @@
#ifndef _TASK_TITLE_H_
#define _TASK_TITLE_H_
-#include <glib.h>
-#include <gtk/gtk.h>
+#include "window-picker.h"
#define TASK_TYPE_TITLE (task_title_get_type ())
@@ -53,7 +52,7 @@ struct _TaskTitleClass {
GtkEventBoxClass parent_class;
};
-GType task_title_get_type (void) G_GNUC_CONST;
-GtkWidget * task_title_new (void);
+GType task_title_get_type (void);
+GtkWidget *task_title_new (WindowPicker *picker);
#endif /* _TASK_TITLE_H_ */
diff --git a/window-picker-applet/src/window-picker.c b/window-picker-applet/src/window-picker.c
new file mode 100644
index 0000000..19e4df3
--- /dev/null
+++ b/window-picker-applet/src/window-picker.c
@@ -0,0 +1,483 @@
+/*
+ * Copyright (C) 2008 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * 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/>.
+ *
+ * Authored by Neil Jagdish Patel <neil patel canonical com>
+ * GTK3 Port by Sebastian Geiger <sbastig gmx net>
+ *
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <glib/gi18n.h>
+#include <libwnck/libwnck.h>
+
+#include "window-picker.h"
+#include "task-list.h"
+#include "task-title.h"
+
+#define SETTINGS_SCHEMA "org.gnome.gnome-applets.window-picker-applet"
+#define KEY_SHOW_ALL_WINDOWS "show-all-windows"
+#define KEY_SHOW_APPLICATION_TITLE "show-application-title"
+#define KEY_SHOW_HOME_TITLE "show-home-title"
+#define KEY_ICONS_GREYSCALE "icons-greyscale"
+#define KEY_EXPAND_TASK_LIST "expand-task-list"
+
+struct _WindowPickerPrivate {
+ GtkWidget *tasks;
+ GtkWidget *title;
+
+ GSettings *settings;
+
+ gboolean show_all_windows;
+ gboolean show_application_title;
+ gboolean show_home_title;
+ gboolean icons_greyscale;
+ gboolean expand_task_list;
+};
+
+enum {
+ PROP_0,
+ PROP_SHOW_ALL_WINDOWS,
+ PROP_SHOW_APPLICATION_TITLE,
+ PROP_SHOW_HOME_TITLE,
+ PROP_ICONS_GREYSCALE,
+ PROP_EXPAND_TASK_LIST,
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (WindowPicker, window_picker, PANEL_TYPE_APPLET);
+
+static void display_about_dialog (GtkAction *action, WindowPicker *picker);
+static void display_prefs_dialog (GtkAction *action, WindowPicker *picker);
+
+static const GtkActionEntry menuActions [] = {
+ {"Preferences", GTK_STOCK_PREFERENCES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (display_prefs_dialog) },
+ { "About", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
+};
+
+static const gchar *close_window_authors [] = {
+ "Neil J. Patel <neil patel canonical com>",
+ "Sebastian Geiger <sbastig gmx net>",
+ NULL
+};
+
+static void
+loadAppletStyle (WindowPicker *picker)
+{
+ GtkWidget *widget = GTK_WIDGET (picker);
+ static gboolean first_time = TRUE;
+
+ if (first_time) {
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ //Prepare the provider for our applet specific CSS
+ GtkCssProvider *provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (
+ GTK_CSS_PROVIDER(provider),
+ ".na-tray-style {\n"
+ " -GtkWidget-focus-line-width: 0;\n"
+ " -GtkWidget-focus-padding: 0;\n"
+ "}\n",
+ -1, NULL);
+ gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+ //register the CSS style for the applets context
+ gtk_style_context_add_class (context, "na-tray-style");
+ first_time = FALSE;
+ }
+}
+
+static void
+setupPanelContextMenu (WindowPicker *picker)
+{
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+
+ action_group = gtk_action_group_new ("Window Picker Applet Actions");
+ ui_path = g_build_filename (WINDOW_PICKER_MENU_UI_DIR, "menu.xml", NULL);
+
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group, menuActions,
+ G_N_ELEMENTS (menuActions), picker);
+
+ panel_applet_setup_menu_from_file (PANEL_APPLET (picker), ui_path, action_group);
+
+ g_free (ui_path);
+ g_object_unref (action_group);
+}
+
+static gboolean
+load_window_picker (PanelApplet *applet)
+{
+ WindowPicker *picker;
+ WindowPickerPrivate *priv;
+ GtkWidget *grid;
+ int flags;
+ GSettings *settings;
+
+ picker = WINDOW_PICKER (applet);
+ priv = picker->priv;
+
+ picker->priv->settings = settings = panel_applet_settings_new (applet, SETTINGS_SCHEMA);
+
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
+ gtk_container_add (GTK_CONTAINER (applet), grid);
+
+ gtk_container_set_border_width (GTK_CONTAINER (applet), 0);
+ gtk_container_set_border_width (GTK_CONTAINER (grid), 0);
+
+ priv->tasks = task_list_new (picker);
+ gtk_widget_set_vexpand (priv->tasks, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), priv->tasks, 0, 0, 1, 1);
+
+ priv->title = task_title_new (picker);
+ gtk_widget_set_hexpand (priv->title, TRUE);
+ gtk_grid_attach (GTK_GRID (grid), priv->title, 1, 0, 1, 1);
+
+ priv->show_all_windows = g_settings_get_boolean (settings, KEY_SHOW_ALL_WINDOWS);
+ g_settings_bind (settings, KEY_SHOW_ALL_WINDOWS,
+ picker, KEY_SHOW_ALL_WINDOWS,
+ G_SETTINGS_BIND_GET);
+ priv->show_application_title = g_settings_get_boolean (settings, KEY_SHOW_APPLICATION_TITLE);
+ g_settings_bind (settings, KEY_SHOW_APPLICATION_TITLE,
+ picker, KEY_SHOW_APPLICATION_TITLE,
+ G_SETTINGS_BIND_GET);
+ priv->show_home_title = g_settings_get_boolean (settings, KEY_SHOW_HOME_TITLE);
+ g_settings_bind (settings, KEY_SHOW_HOME_TITLE,
+ picker, KEY_SHOW_HOME_TITLE,
+ G_SETTINGS_BIND_GET);
+ priv->icons_greyscale = g_settings_get_boolean (settings, KEY_ICONS_GREYSCALE);
+ g_settings_bind (settings, KEY_ICONS_GREYSCALE,
+ picker, KEY_ICONS_GREYSCALE,
+ G_SETTINGS_BIND_GET);
+ priv->expand_task_list = g_settings_get_boolean (settings, KEY_EXPAND_TASK_LIST);
+ g_settings_bind (settings, KEY_EXPAND_TASK_LIST,
+ picker, KEY_EXPAND_TASK_LIST,
+ G_SETTINGS_BIND_GET);
+
+ loadAppletStyle (picker);
+ setupPanelContextMenu (picker);
+
+ flags = PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE;
+ if (g_settings_get_boolean (picker->priv->settings, KEY_EXPAND_TASK_LIST))
+ flags |= PANEL_APPLET_EXPAND_MAJOR;
+
+ panel_applet_set_flags (applet, flags);
+ panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
+
+ gtk_widget_show_all (GTK_WIDGET (applet));
+
+ return TRUE;
+}
+
+static void
+display_about_dialog (GtkAction *action,
+ WindowPicker *picker)
+{
+ GtkWidget *panel_about_dialog = gtk_about_dialog_new ();
+ g_object_set (panel_about_dialog,
+ "name", _("Window Picker"),
+ "comments", _("Window Picker"),
+ "version", PACKAGE_VERSION,
+ "authors", close_window_authors,
+ "logo-icon-name", "system-preferences-windows",
+ "copyright", "Copyright \xc2\xa9 2008 Canonical Ltd\nand Sebastian Geiger",
+ NULL
+ );
+ char *logo_filename = g_build_filename (WINDOW_PICKER_MENU_UI_DIR, "window-picker-about-logo.png", NULL);
+ GdkPixbuf* logo = gdk_pixbuf_new_from_file(logo_filename, NULL);
+ gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(panel_about_dialog), logo);
+ if (logo)
+ g_object_unref (logo);
+ gtk_widget_show (panel_about_dialog);
+ g_signal_connect (panel_about_dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_present (GTK_WINDOW (panel_about_dialog));
+}
+
+static GtkWidget*
+prepareCheckBox (WindowPicker *picker,
+ const gchar *text,
+ const gchar *key)
+{
+ GtkWidget *check;
+ gboolean is_active;
+
+ check = gtk_check_button_new_with_label (text);
+ is_active = g_settings_get_boolean (picker->priv->settings, key);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), is_active);
+
+ g_settings_bind (picker->priv->settings, key,
+ check, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ return check;
+}
+
+static void
+display_prefs_dialog (GtkAction *action,
+ WindowPicker *picker)
+{
+ GtkWidget *window;
+ GtkWidget *notebook;
+ GtkWidget *check;
+ GtkWidget *button;
+ GtkWidget *grid;
+ int i;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (window), _("Preferences"));
+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 12);
+
+ notebook = gtk_notebook_new ();
+ gtk_container_add (GTK_CONTAINER (window), notebook);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK(notebook), FALSE);
+
+ grid = gtk_grid_new ();
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), grid, NULL);
+
+ i = -1;
+
+ check = prepareCheckBox (picker, _("Show windows from all workspaces"), KEY_SHOW_ALL_WINDOWS);
+ gtk_grid_attach (GTK_GRID (grid), check, 0, ++i, 1, 1);
+
+ check = prepareCheckBox (picker, _("Show the home title and\nlogout icon, when on the desktop"),
KEY_SHOW_HOME_TITLE);
+ gtk_grid_attach (GTK_GRID (grid), check, 0, ++i, 1, 1);
+
+ check = prepareCheckBox (picker, _("Show the application title and\nclose icon"),
KEY_SHOW_APPLICATION_TITLE);
+ gtk_grid_attach (GTK_GRID (grid), check, 0, ++i, 1, 1);
+
+ check = prepareCheckBox (picker, _("Grey out non active window icons"), KEY_ICONS_GREYSCALE);
+ gtk_grid_attach (GTK_GRID (grid), check, 0, ++i, 1, 1);
+
+ check = prepareCheckBox (picker, _("Automatically expand task list to use full space"),
KEY_EXPAND_TASK_LIST);
+ gtk_grid_attach (GTK_GRID (grid), check, 0, ++i, 1, 1);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ gtk_widget_set_halign (button, GTK_ALIGN_END);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 0);
+ gtk_grid_attach (GTK_GRID(grid), button, 0, ++i, 1, 1);
+
+ g_signal_connect (window, "delete-event", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), window);
+
+ gtk_widget_show_all (window);
+ gtk_window_present (GTK_WINDOW (window));
+}
+
+static void
+window_picker_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ WindowPicker *picker = WINDOW_PICKER (object);
+ g_return_if_fail (WINDOW_IS_PICKER (picker));
+
+ switch (prop_id) {
+ case PROP_SHOW_ALL_WINDOWS:
+ g_value_set_boolean (value, picker->priv->show_all_windows);
+ break;
+ case PROP_SHOW_APPLICATION_TITLE:
+ g_value_set_boolean (value, picker->priv->show_application_title);
+ break;
+ case PROP_SHOW_HOME_TITLE:
+ g_value_set_boolean (value, picker->priv->show_home_title);
+ break;
+ case PROP_ICONS_GREYSCALE:
+ g_value_set_boolean (value, picker->priv->icons_greyscale);
+ break;
+ case PROP_EXPAND_TASK_LIST:
+ g_value_set_boolean (value, picker->priv->expand_task_list);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+window_picker_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ WindowPicker *picker = WINDOW_PICKER (object);
+ g_return_if_fail (WINDOW_IS_PICKER (picker));
+
+ switch (prop_id) {
+ case PROP_SHOW_ALL_WINDOWS:
+ picker->priv->show_all_windows = g_value_get_boolean (value);
+ break;
+ case PROP_SHOW_APPLICATION_TITLE:
+ picker->priv->show_application_title = g_value_get_boolean (value);
+ break;
+ case PROP_SHOW_HOME_TITLE:
+ picker->priv->show_home_title = g_value_get_boolean (value);
+ break;
+ case PROP_ICONS_GREYSCALE:
+ picker->priv->icons_greyscale = g_value_get_boolean (value);
+ break;
+ case PROP_EXPAND_TASK_LIST:
+ picker->priv->expand_task_list = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+window_picker_finalize (GObject *object)
+{
+ WindowPicker *picker = WINDOW_PICKER (object);
+
+ if (picker->priv->settings) {
+ g_object_unref (picker->priv->settings);
+ picker->priv->settings = NULL;
+ }
+
+ G_OBJECT_CLASS (window_picker_parent_class)->finalize (object);
+}
+
+static void
+window_picker_init (WindowPicker *picker)
+{
+ picker->priv = window_picker_get_instance_private (picker);
+
+ picker->priv->tasks = NULL;
+ picker->priv->title = NULL;
+
+ picker->priv->settings = NULL;
+
+ picker->priv->show_all_windows = TRUE;
+ picker->priv->show_application_title = FALSE;
+ picker->priv->show_home_title = FALSE;
+ picker->priv->icons_greyscale = FALSE;
+ picker->priv->expand_task_list = FALSE;
+}
+
+static void
+window_picker_class_init (WindowPickerClass *class)
+{
+ GObjectClass *obj_class = G_OBJECT_CLASS (class);
+
+ obj_class->finalize = window_picker_finalize;
+ obj_class->set_property = window_picker_set_property;
+ obj_class->get_property = window_picker_get_property;
+
+ g_object_class_install_property (obj_class, PROP_SHOW_ALL_WINDOWS,
+ g_param_spec_boolean ("show-all-windows",
+ "Show All Windows",
+ "Show windows from all workspaces",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (obj_class, PROP_SHOW_APPLICATION_TITLE,
+ g_param_spec_boolean ("show-application-title",
+ "Show Application Title",
+ "Show the application title",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (obj_class, PROP_SHOW_HOME_TITLE,
+ g_param_spec_boolean ("show-home-title",
+ "Show Home Title",
+ "Show the home title and logout button",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (obj_class, PROP_ICONS_GREYSCALE,
+ g_param_spec_boolean ("icons-greyscale",
+ "Icons Greyscale",
+ "All icons except the current active window
icon are greyed out",
+ TRUE,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (obj_class, PROP_EXPAND_TASK_LIST,
+ g_param_spec_boolean ("expand-task-list",
+ "Expand Task List",
+ "Whether the task list will expand
automatically and use all available space",
+ TRUE,
+ G_PARAM_READWRITE));
+}
+
+static gboolean
+window_picker_factory (PanelApplet *applet,
+ const gchar *iid,
+ gpointer data)
+{
+ gboolean retval = FALSE;
+ static gboolean type_registered = FALSE;
+
+ if (!type_registered) {
+ wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
+ type_registered = TRUE;
+ }
+
+ if (strcmp (iid, "WindowPicker") == 0)
+ retval = load_window_picker (applet);
+
+ return retval;
+}
+
+GtkWidget *
+window_picker_get_task_list (WindowPicker *picker)
+{
+ return picker->priv->tasks;
+}
+
+gboolean
+window_picker_get_show_all_windows (WindowPicker *picker)
+{
+ return picker->priv->show_all_windows;
+}
+
+gboolean
+window_picker_get_show_application_title (WindowPicker *picker)
+{
+ return picker->priv->show_application_title;
+}
+
+gboolean
+window_picker_get_show_home_title (WindowPicker *picker)
+{
+ return picker->priv->show_home_title;
+}
+
+gboolean
+window_picker_get_icons_greyscale (WindowPicker *picker)
+{
+ return picker->priv->icons_greyscale;
+}
+
+gboolean
+window_picker_get_expand_task_list (WindowPicker *picker)
+{
+ return picker->priv->expand_task_list;
+}
+
+PANEL_APPLET_OUT_PROCESS_FACTORY ("WindowPickerFactory",
+ WINDOW_TYPE_PICKER,
+ window_picker_factory,
+ NULL);
diff --git a/window-picker-applet/src/window-picker.h b/window-picker-applet/src/window-picker.h
new file mode 100644
index 0000000..ed7fcec
--- /dev/null
+++ b/window-picker-applet/src/window-picker.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 Sebastian Geiger
+ *
+ * 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 3 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/>.
+ */
+
+#ifndef WINDOW_PICKER_H
+#define WINDOW_PICKER_H
+
+#include <panel-applet.h>
+
+G_BEGIN_DECLS
+
+#define WINDOW_TYPE_PICKER (window_picker_get_type())
+#define WINDOW_PICKER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), WINDOW_TYPE_PICKER, WindowPicker))
+#define WINDOW_PICKER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), WINDOW_TYPE_PICKER, WindowPickerClass))
+#define WINDOW_IS_PICKER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), WINDOW_TYPE_PICKER))
+#define WINDOW_IS_PICKER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), WINDOW_TYPE_PICKER))
+#define WINDOW_PICKER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), WINDOW_TYPE_PICKER, WindowPickerClass))
+
+typedef struct _WindowPicker WindowPicker;
+typedef struct _WindowPickerClass WindowPickerClass;
+typedef struct _WindowPickerPrivate WindowPickerPrivate;
+
+struct _WindowPicker {
+ PanelApplet parent;
+ WindowPickerPrivate *priv;
+};
+
+struct _WindowPickerClass {
+ PanelAppletClass parent_class;
+};
+
+GType window_picker_get_type (void);
+GtkWidget *window_picker_get_task_list (WindowPicker *picker);
+gboolean window_picker_get_show_all_windows (WindowPicker *picker);
+gboolean window_picker_get_show_application_title (WindowPicker *picker);
+gboolean window_picker_get_show_home_title (WindowPicker *picker);
+gboolean window_picker_get_icons_greyscale (WindowPicker *picker);
+gboolean window_picker_get_expand_task_list (WindowPicker *picker);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]