[gnome-applets/wip/muktupavels/window-picker/applet] window-picker: redo applet class
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/muktupavels/window-picker/applet] window-picker: redo applet class
- Date: Tue, 14 Jul 2015 11:39:02 +0000 (UTC)
commit 64ce7c475c451d73f6db5a7df6c63596a57a3a04
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Jul 14 14:38:07 2015 +0300
window-picker: redo applet class
po/POTFILES.in | 4 +-
windowpicker/data/Makefile.am | 1 -
windowpicker/src/Makefile.am | 5 +-
windowpicker/src/applet.c | 439 ---------------------
windowpicker/src/applet.h | 60 ---
windowpicker/src/task-item.c | 16 +-
windowpicker/src/task-item.h | 4 +-
windowpicker/src/task-list.c | 4 +-
windowpicker/src/task-list.h | 4 +-
windowpicker/src/task-title.c | 17 +-
windowpicker/src/task-title.h | 4 +-
windowpicker/src/wp-applet.c | 478 +++++++++++++++++++++++
windowpicker/src/wp-applet.h | 55 +++
windowpicker/{data/menu.xml => src/wp-menu.xml} | 0
windowpicker/src/wp-resources.gresource.xml | 7 +-
15 files changed, 564 insertions(+), 534 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 445e3f8..3c600b6 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
-[type: gettext/glade]windowpicker/data/menu.xml
-windowpicker/src/applet.c
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
diff --git a/windowpicker/data/Makefile.am b/windowpicker/data/Makefile.am
index 7a2c143..ed5e2b7 100644
--- a/windowpicker/data/Makefile.am
+++ b/windowpicker/data/Makefile.am
@@ -6,7 +6,6 @@ APPLET_LOCATION=$(pkglibdir)/$(LIBPANEL_APPLET_API_VERSION)/libwindow-picker-app
uidir = $(datadir)/$(PACKAGE)/ui
ui_DATA = \
- menu.xml \
window-picker-about-logo.png
$(applet_in_files): $(applet_in_files).in Makefile
diff --git a/windowpicker/src/Makefile.am b/windowpicker/src/Makefile.am
index fe0c324..d01992a 100644
--- a/windowpicker/src/Makefile.am
+++ b/windowpicker/src/Makefile.am
@@ -33,10 +33,10 @@ libwindow_picker_applet_la_LIBADD = \
libwindow_picker_applet_la_SOURCES = \
wp-about-dialog.c \
wp-about-dialog.h \
+ wp-applet.c \
+ wp-applet.h \
wp-preferences-dialog.c \
wp-preferences-dialog.h \
- applet.c \
- applet.h \
task-item.c \
task-item.h \
task-list.c \
@@ -47,6 +47,7 @@ libwindow_picker_applet_la_SOURCES = \
wp-resources.h
EXTRA_DIST = \
+ wp-menu.xml \
wp-resources.gresource.xml
CLEANFILES = \
diff --git a/windowpicker/src/task-item.c b/windowpicker/src/task-item.c
index babae4d..f3091b1 100644
--- a/windowpicker/src/task-item.c
+++ b/windowpicker/src/task-item.c
@@ -20,7 +20,6 @@
#include "task-item.h"
#include "task-list.h"
-#include "applet.h"
#include <math.h>
#include <glib/gi18n.h>
@@ -44,7 +43,7 @@ struct _TaskItemPrivate {
GTimeVal urgent_time;
guint blink_timer;
gboolean mouse_over;
- WindowPickerApplet *windowPickerApplet;
+ WpApplet *windowPickerApplet;
};
enum {
@@ -164,7 +163,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 = window_picker_applet_get_show_all_windows (priv->windowPickerApplet);
+ gboolean show_all = wp_applet_get_show_all_windows (priv->windowPickerApplet);
gboolean show_window = FALSE;
if (!wnck_window_is_skip_tasklist (window)) {
if(workspace != NULL) { //this can happen sometimes
@@ -244,7 +243,7 @@ static GdkPixbuf *task_item_sized_pixbuf_for_window (
static gboolean task_item_draw (
GtkWidget *widget,
cairo_t *cr,
- WindowPickerApplet* windowPickerApplet)
+ WpApplet* windowPickerApplet)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (TASK_IS_ITEM (widget), FALSE);
@@ -259,7 +258,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 = window_picker_applet_get_icons_greyscale (priv->windowPickerApplet);
+ gboolean icons_greyscale = wp_applet_get_icons_greyscale (priv->windowPickerApplet);
gboolean attention = wnck_window_or_transient_needs_attention (priv->window);
if (GDK_IS_PIXBUF (pbuf) &&
gdk_pixbuf_get_width (pbuf) != size &&
@@ -666,14 +665,14 @@ static void on_drag_received_data (
gint active;
switch (target_type) {
case TARGET_WIDGET_DRAGGED: {
- GtkWidget *taskList = window_picker_applet_get_tasks(item->priv->windowPickerApplet);
+ GtkWidget *taskList = wp_applet_get_tasks(item->priv->windowPickerApplet);
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(window_picker_applet_get_tasks(item->priv->windowPickerApplet), widget);
+ gint target_position = grid_get_pos(wp_applet_get_tasks(item->priv->windowPickerApplet),
widget);
g_object_ref(taskItem);
gtk_box_reorder_child(GTK_BOX(taskList), taskItem, target_position);
g_object_unref(taskItem);
@@ -769,7 +768,7 @@ static void task_item_init (TaskItem *item) {
priv->blink_timer = 0;
}
-GtkWidget *task_item_new (WindowPickerApplet* windowPickerApplet, WnckWindow *window) {
+GtkWidget *task_item_new (WpApplet* windowPickerApplet, WnckWindow *window) {
g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
TaskItem *taskItem;
TaskItemPrivate *priv;
@@ -781,7 +780,6 @@ GtkWidget *task_item_new (WindowPickerApplet* windowPickerApplet, WnckWindow *wi
"above-child", TRUE,
NULL
);
- gtk_widget_set_vexpand(item, TRUE);
gtk_widget_add_events (item, GDK_ALL_EVENTS_MASK);
gtk_container_set_border_width (GTK_CONTAINER (item), 0);
taskItem = TASK_ITEM (item);
diff --git a/windowpicker/src/task-item.h b/windowpicker/src/task-item.h
index 9b8a3ff..dcb9a0e 100644
--- a/windowpicker/src/task-item.h
+++ b/windowpicker/src/task-item.h
@@ -21,7 +21,7 @@
#ifndef _TASK_ITEM_H_
#define _TASK_ITEM_H_
-#include "applet.h"
+#include "wp-applet.h"
#include <glib.h>
#include <gtk/gtk.h>
@@ -49,6 +49,6 @@ struct _TaskItemClass {
};
GType task_item_get_type (void) G_GNUC_CONST;
-GtkWidget * task_item_new (WindowPickerApplet *windowPickerApplet, WnckWindow *window);
+GtkWidget * task_item_new (WpApplet *windowPickerApplet, WnckWindow *window);
#endif /* _TASK_ITEM_H_ */
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 5e71c5a..624eb80 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -26,7 +26,7 @@
struct _TaskListPrivate {
WnckScreen *screen;
- WindowPickerApplet *windowPickerApplet;
+ WpApplet *windowPickerApplet;
};
G_DEFINE_TYPE_WITH_PRIVATE (TaskList, task_list, GTK_TYPE_BOX);
@@ -119,7 +119,7 @@ static void task_list_init (TaskList *list) {
gtk_container_set_border_width (GTK_CONTAINER (list), 0);
}
-GtkWidget *task_list_new (WindowPickerApplet *windowPickerApplet) {
+GtkWidget *task_list_new (WpApplet *windowPickerApplet) {
PanelAppletOrient panel_orientation = panel_applet_get_orient(PANEL_APPLET(windowPickerApplet));
GtkOrientation orientation;
switch(panel_orientation) {
diff --git a/windowpicker/src/task-list.h b/windowpicker/src/task-list.h
index 0ddf4c0..d17c57a 100644
--- a/windowpicker/src/task-list.h
+++ b/windowpicker/src/task-list.h
@@ -20,7 +20,7 @@
#ifndef _TASK_LIST_H_
#define _TASK_LIST_H_
-#include "applet.h"
+#include "wp-applet.h"
#include <glib.h>
#include <gtk/gtk.h>
@@ -56,7 +56,7 @@ struct _TaskListClass {
};
GType task_list_get_type (void) G_GNUC_CONST;
-GtkWidget * task_list_new (WindowPickerApplet* windowPickerApplet);
+GtkWidget * task_list_new (WpApplet* windowPickerApplet);
gboolean task_list_get_desktop_visible (TaskList *list);
#endif /* _TASK_LIST_H_ */
diff --git a/windowpicker/src/task-title.c b/windowpicker/src/task-title.c
index db9e003..633d8a9 100644
--- a/windowpicker/src/task-title.c
+++ b/windowpicker/src/task-title.c
@@ -39,7 +39,7 @@ struct _TaskTitlePrivate {
GtkWidget *button_image;
GdkPixbuf *quit_icon;
gboolean mouse_in_close_button;
- WindowPickerApplet *windowPickerApplet;
+ WpApplet *windowPickerApplet;
};
G_DEFINE_TYPE_WITH_PRIVATE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX);
@@ -205,7 +205,7 @@ 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 (window_picker_applet_get_show_home_title (priv->windowPickerApplet)) {
+ if (wp_applet_get_show_home_title (priv->windowPickerApplet)) {
show_home_title(title);
} else {
hide_title (title);
@@ -222,7 +222,7 @@ on_active_window_changed (WnckScreen *screen,
{
return;
} else { //for all other types
- if(wnck_window_is_maximized (act_window) && window_picker_applet_get_show_application_title
(priv->windowPickerApplet)) {
+ if(wnck_window_is_maximized (act_window) && wp_applet_get_show_application_title
(priv->windowPickerApplet)) {
//show normal title of window
gtk_label_set_text (GTK_LABEL (priv->label),
wnck_window_get_name (act_window));
@@ -242,8 +242,8 @@ on_active_window_changed (WnckScreen *screen,
}
}
} else { //its not a window
- if (task_list_get_desktop_visible (TASK_LIST (window_picker_applet_get_tasks
(priv->windowPickerApplet)))
- && window_picker_applet_get_show_home_title (priv->windowPickerApplet))
+ if (task_list_get_desktop_visible (TASK_LIST (wp_applet_get_tasks (priv->windowPickerApplet)))
+ && wp_applet_get_show_home_title (priv->windowPickerApplet))
{
show_home_title(title);
} else { //reset the task title and hide it
@@ -318,9 +318,6 @@ static GtkWidget *getTitleLabel() {
pango_attr_list_insert (attr_list, attr);
gtk_label_set_attributes (GTK_LABEL (label), attr_list);
pango_attr_list_unref (attr_list);
- gtk_widget_set_hexpand (label, TRUE);
- gtk_widget_set_vexpand (label, TRUE);
- gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
return label;
}
@@ -449,7 +446,7 @@ task_title_class_init (TaskTitleClass *klass)
}
GtkWidget *
-task_title_new (WindowPickerApplet *windowPickerApplet)
+task_title_new (WpApplet *windowPickerApplet)
{
TaskTitle *title = g_object_new (TASK_TYPE_TITLE,
"border-width", 0,
@@ -459,7 +456,7 @@ task_title_new (WindowPickerApplet *windowPickerApplet)
title->priv->windowPickerApplet = windowPickerApplet;
- if (window_picker_applet_get_show_home_title (title->priv->windowPickerApplet)) {
+ if (wp_applet_get_show_home_title (title->priv->windowPickerApplet)) {
gtk_widget_set_state_flags (GTK_WIDGET (title), GTK_STATE_FLAG_ACTIVE, TRUE);
} else {
gtk_widget_hide (title->priv->grid);
diff --git a/windowpicker/src/task-title.h b/windowpicker/src/task-title.h
index d6ccee3..9cee7a4 100644
--- a/windowpicker/src/task-title.h
+++ b/windowpicker/src/task-title.h
@@ -20,7 +20,7 @@
#ifndef _TASK_TITLE_H_
#define _TASK_TITLE_H_
-#include "applet.h"
+#include "wp-applet.h"
#include <glib.h>
#include <gtk/gtk.h>
@@ -47,6 +47,6 @@ struct _TaskTitleClass {
};
GType task_title_get_type (void) G_GNUC_CONST;
-GtkWidget * task_title_new (WindowPickerApplet *windowPickerApplet);
+GtkWidget * task_title_new (WpApplet *windowPickerApplet);
#endif /* _TASK_TITLE_H_ */
diff --git a/windowpicker/src/wp-applet.c b/windowpicker/src/wp-applet.c
new file mode 100644
index 0000000..927b441
--- /dev/null
+++ b/windowpicker/src/wp-applet.c
@@ -0,0 +1,478 @@
+/*
+ * 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 <gdk/gdk.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#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"
+
+#define SETTINGS_SCHEMA "org.gnome.gnome-applets.window-picker-applet"
+#define GRESOURCE "/org/gnome/gnome-applets/window-picker/"
+
+struct _WpApplet
+{
+ PanelApplet parent;
+
+ GSettings *settings;
+
+ GtkWidget *about_dialog;
+ GtkWidget *preferences_dialog;
+
+ gboolean show_all_windows;
+ gboolean show_application_title;
+ gboolean show_home_title;
+ gboolean icons_greyscale;
+ gboolean expand_task_list;
+
+ GtkWidget *container;
+ GtkWidget *tasks;
+ GtkWidget *title;
+};
+
+enum
+{
+ PROP_0,
+ PROP_SHOW_ALL_WINDOWS,
+ PROP_SHOW_APPLICATION_TITLE,
+ PROP_SHOW_HOME_TITLE,
+ PROP_ICONS_GREYSCALE,
+ PROP_EXPAND_TASK_LIST,
+ LAST_PROP
+};
+
+static GParamSpec *properties[LAST_PROP] = { NULL };
+
+G_DEFINE_TYPE (WpApplet, wp_applet, PANEL_TYPE_APPLET)
+
+static void
+wp_about_dialog_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (user_data);
+
+ if (applet->about_dialog == NULL)
+ return;
+
+ gtk_widget_destroy (applet->about_dialog);
+ applet->about_dialog = NULL;
+}
+
+static void
+display_about_dialog (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (user_data);
+
+ if (applet->about_dialog == NULL)
+ {
+ applet->about_dialog = wp_about_dialog_new ();
+
+ g_signal_connect (applet->about_dialog, "response",
+ G_CALLBACK (wp_about_dialog_response_cb), applet);
+ }
+
+ gtk_window_present (GTK_WINDOW (applet->about_dialog));
+}
+
+static void
+wp_preferences_dialog_response_cb (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (user_data);
+
+ if (applet->preferences_dialog == NULL)
+ return;
+
+ gtk_widget_destroy (applet->preferences_dialog);
+ applet->preferences_dialog = NULL;
+}
+
+static void
+display_prefs_dialog (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ WpApplet *applet;
+ GSettings *settings;
+
+ applet = WP_APPLET (user_data);
+ settings = applet->settings;
+
+ if (applet->preferences_dialog == NULL)
+ {
+ applet->preferences_dialog = wp_preferences_dialog_new (settings);
+
+ g_signal_connect (applet->preferences_dialog, "response",
+ G_CALLBACK (wp_preferences_dialog_response_cb), applet);
+ }
+
+ gtk_window_present (GTK_WINDOW (applet->preferences_dialog));
+}
+
+static const GActionEntry menu_actions[] = {
+ { "preferences", display_prefs_dialog },
+ { "about", display_about_dialog }
+};
+
+static void
+wp_applet_setup_menu (PanelApplet *applet)
+{
+ GSimpleActionGroup *action_group;
+ const gchar *resource_name;
+
+ action_group = g_simple_action_group_new ();
+ resource_name = GRESOURCE "wp-menu.xml";
+
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group), menu_actions,
+ G_N_ELEMENTS (menu_actions), applet);
+
+ panel_applet_setup_menu_from_resource (applet, resource_name, action_group,
+ GETTEXT_PACKAGE);
+
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "window-picker-applet",
+ G_ACTION_GROUP (action_group));
+
+ g_object_unref (action_group);
+}
+
+static void
+wp_applet_load (PanelApplet *panel_applet)
+{
+ WpApplet *applet;
+ GtkOrientation orientation;
+
+ applet = WP_APPLET (panel_applet);
+
+ applet->settings = panel_applet_settings_new (panel_applet, SETTINGS_SCHEMA);
+
+ orientation = panel_applet_get_gtk_orientation (panel_applet);
+ applet->container = gtk_box_new (orientation, 10);
+ gtk_container_add (GTK_CONTAINER (applet), applet->container);
+
+ applet->tasks = task_list_new (applet);
+ gtk_box_pack_start (GTK_BOX (applet->container), applet->tasks,
+ FALSE, FALSE, 0);
+
+ applet->title = task_title_new (applet);
+ gtk_box_pack_start (GTK_BOX (applet->container), applet->title,
+ FALSE, FALSE, 0);
+
+ 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);
+
+ g_settings_bind (applet->settings, KEY_SHOW_HOME_TITLE,
+ applet, KEY_SHOW_HOME_TITLE, G_SETTINGS_BIND_GET);
+
+ g_settings_bind (applet->settings, KEY_ICONS_GREYSCALE,
+ applet, KEY_ICONS_GREYSCALE, G_SETTINGS_BIND_GET);
+
+ g_settings_bind (applet->settings, KEY_EXPAND_TASK_LIST,
+ applet, KEY_EXPAND_TASK_LIST, G_SETTINGS_BIND_GET);
+
+ gtk_widget_show_all (GTK_WIDGET (applet));
+}
+
+static gboolean
+wp_applet_factory (PanelApplet *applet,
+ const gchar *iid,
+ gpointer data)
+{
+ static gboolean client_type_registered = FALSE;
+
+ if (client_type_registered == FALSE)
+ {
+ wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
+ client_type_registered = TRUE;
+ }
+
+ if (g_strcmp0 (iid, "WindowPicker") != 0)
+ return FALSE;
+
+ wp_applet_load (applet);
+
+ return TRUE;
+}
+
+static void
+wp_applet_dispose (GObject *object)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (object);
+
+ g_clear_object (&applet->settings);
+
+ if (applet->about_dialog != NULL)
+ {
+ gtk_widget_destroy (applet->about_dialog);
+ applet->about_dialog = NULL;
+ }
+
+ if (applet->preferences_dialog != NULL)
+ {
+ gtk_widget_destroy (applet->preferences_dialog);
+ applet->preferences_dialog = NULL;
+ }
+
+ G_OBJECT_CLASS (wp_applet_parent_class)->dispose (object);
+}
+
+static void
+wp_applet_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ WpApplet *applet;
+ gboolean expand_task_list;
+
+ applet = WP_APPLET (object);
+
+ switch (property_id)
+ {
+ case PROP_SHOW_ALL_WINDOWS:
+ 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;
+
+ case PROP_EXPAND_TASK_LIST:
+ expand_task_list = g_value_get_boolean (value);
+
+ if (applet->expand_task_list != expand_task_list)
+ {
+ PanelApplet *panel_applet;
+ PanelAppletFlags flags;
+
+ panel_applet = PANEL_APPLET (applet);
+ flags = panel_applet_get_flags (panel_applet);
+
+ if (expand_task_list == TRUE)
+ flags |= PANEL_APPLET_EXPAND_MAJOR;
+ else
+ flags &= ~PANEL_APPLET_EXPAND_MAJOR;
+
+ panel_applet_set_flags (panel_applet, flags);
+
+ applet->expand_task_list = expand_task_list;
+
+ gtk_widget_queue_resize (GTK_WIDGET (applet));
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+wp_applet_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ WpApplet *applet;
+
+ applet = WP_APPLET (object);
+
+ switch (property_id)
+ {
+ case PROP_SHOW_ALL_WINDOWS:
+ 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;
+
+ case PROP_EXPAND_TASK_LIST:
+ g_value_set_boolean (value, applet->expand_task_list);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+wp_applet_change_orient (PanelApplet *panel_applet,
+ PanelAppletOrient orient)
+{
+ WpApplet *applet;
+ GtkOrientation orientation;
+
+ applet = WP_APPLET (panel_applet);
+ orientation = panel_applet_get_gtk_orientation (panel_applet);
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (applet->container),
+ orientation);
+
+ gtk_widget_queue_resize (GTK_WIDGET (applet));
+}
+
+static void
+wp_applet_class_init (WpAppletClass *applet_class)
+{
+ GObjectClass *object_class;
+ PanelAppletClass *panel_applet_class;
+
+ object_class = G_OBJECT_CLASS (applet_class);
+ panel_applet_class = PANEL_APPLET_CLASS (applet_class);
+
+ object_class->dispose = wp_applet_dispose;
+ object_class->set_property = wp_applet_set_property;
+ object_class->get_property = wp_applet_get_property;
+
+ panel_applet_class->change_orient = wp_applet_change_orient;
+
+ properties[PROP_SHOW_ALL_WINDOWS] =
+ g_param_spec_boolean ("show-all-windows",
+ "Show All Windows",
+ "Show windows from all workspaces",
+ 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",
+ "All icons except the current active window icon are greyed out",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ properties[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",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ g_object_class_install_properties (object_class, LAST_PROP, properties);
+}
+
+static void
+wp_applet_init (WpApplet *applet)
+{
+ PanelApplet *panel_applet;
+ PanelAppletFlags flags;
+
+ panel_applet = PANEL_APPLET (applet);
+ flags = PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE;
+
+ panel_applet_set_flags (panel_applet, flags);
+ wp_applet_setup_menu (panel_applet);
+}
+
+GtkWidget *
+wp_applet_get_tasks (WpApplet *applet)
+{
+ return applet->tasks;
+}
+
+gboolean
+wp_applet_get_show_all_windows(WpApplet *applet)
+{
+ return applet->show_all_windows;
+}
+
+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;
+}
+
+gboolean
+wp_applet_get_expand_task_list (WpApplet *applet)
+{
+ return applet->expand_task_list;
+}
+
+PANEL_APPLET_IN_PROCESS_FACTORY ("WindowPickerFactory", WP_TYPE_APPLET,
+ wp_applet_factory, NULL);
diff --git a/windowpicker/src/wp-applet.h b/windowpicker/src/wp-applet.h
new file mode 100644
index 0000000..c54eeb1
--- /dev/null
+++ b/windowpicker/src/wp-applet.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 Sebastian Geiger
+ * 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>
+ * Sebastian Geiger <sbastig gmx net>
+ */
+
+#ifndef WP_APPLET_H
+#define WP_APPLET_H
+
+#include <panel-applet.h>
+
+G_BEGIN_DECLS
+
+#define WP_TYPE_APPLET (wp_applet_get_type ())
+#define WP_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), WP_TYPE_APPLET, WpApplet))
+#define WP_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), WP_TYPE_APPLET, WpAppletClass))
+#define WP_IS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), WP_TYPE_APPLET))
+#define WP_IS_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), WP_TYPE_APPLET))
+#define WP_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), WP_TYPE_APPLET, WpAppletClass))
+
+typedef struct _WpApplet WpApplet;
+typedef struct _WpAppletClass WpAppletClass;
+
+struct _WpAppletClass
+{
+ PanelAppletClass parent_class;
+};
+
+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);
+
+G_END_DECLS
+
+#endif
diff --git a/windowpicker/data/menu.xml b/windowpicker/src/wp-menu.xml
similarity index 100%
rename from windowpicker/data/menu.xml
rename to windowpicker/src/wp-menu.xml
diff --git a/windowpicker/src/wp-resources.gresource.xml b/windowpicker/src/wp-resources.gresource.xml
index 9a8073b..729ac57 100644
--- a/windowpicker/src/wp-resources.gresource.xml
+++ b/windowpicker/src/wp-resources.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/gnome-applets/window-picker">
- <file compressed="true">wp-preferences-dialog.ui</file>
- </gresource>
+ <gresource prefix="/org/gnome/gnome-applets/window-picker">
+ <file compressed="true">wp-preferences-dialog.ui</file>
+ <file compressed="true">wp-menu.xml</file>
+ </gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]