|
Packit |
15f964 |
/*
|
|
Packit |
15f964 |
* e-shell-taskbar.c
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This program is free software; you can redistribute it and/or modify it
|
|
Packit |
15f964 |
* under the terms of the GNU Lesser General Public License as published by
|
|
Packit |
15f964 |
* the Free Software Foundation.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This program is distributed in the hope that it will be useful, but
|
|
Packit |
15f964 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
15f964 |
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
15f964 |
* for more details.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
15f964 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
*/
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* SECTION: e-shell-taskbar
|
|
Packit |
15f964 |
* @short_description: the bottom of the main window
|
|
Packit |
15f964 |
* @include: shell/e-shell-taskbar.h
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "evolution-config.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "e-shell-taskbar.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include <libebackend/libebackend.h>
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#include "e-shell-view.h"
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
#define E_SHELL_TASKBAR_GET_PRIVATE(obj) \
|
|
Packit |
15f964 |
(G_TYPE_INSTANCE_GET_PRIVATE \
|
|
Packit |
15f964 |
((obj), E_TYPE_SHELL_TASKBAR, EShellTaskbarPrivate))
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
struct _EShellTaskbarPrivate {
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gpointer shell_view; /* weak pointer */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Keep a reference to the shell backend since
|
|
Packit |
15f964 |
* we connect to its "activity-added" signal. */
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GtkWidget *label;
|
|
Packit |
15f964 |
GtkWidget *hbox;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
GHashTable *proxy_table;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gint fixed_height;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Basically the main() thread, aka UI thread, where the gtk calls
|
|
Packit |
15f964 |
* can be done. */
|
|
Packit |
15f964 |
GThread *main_thread;
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
enum {
|
|
Packit |
15f964 |
PROP_0,
|
|
Packit |
15f964 |
PROP_MESSAGE,
|
|
Packit |
15f964 |
PROP_SHELL_VIEW
|
|
Packit |
15f964 |
};
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
G_DEFINE_TYPE_WITH_CODE (
|
|
Packit |
15f964 |
EShellTaskbar,
|
|
Packit |
15f964 |
e_shell_taskbar,
|
|
Packit |
15f964 |
GTK_TYPE_BOX,
|
|
Packit |
15f964 |
G_IMPLEMENT_INTERFACE (
|
|
Packit |
15f964 |
E_TYPE_EXTENSIBLE, NULL))
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
typedef struct {
|
|
Packit |
15f964 |
EShellTaskbar *shell_taskbar;
|
|
Packit |
15f964 |
EActivity *activity;
|
|
Packit |
15f964 |
GtkWidget *proxy; /* not referenced */
|
|
Packit |
15f964 |
} EShellTaskbarIdleData;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_free_idle_data (gpointer data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbarIdleData *idle_data = data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_clear_object (&idle_data->shell_taskbar);
|
|
Packit |
15f964 |
g_clear_object (&idle_data->activity);
|
|
Packit |
15f964 |
g_free (idle_data);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_remove_proxy_container (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
GtkWidget *proxy)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GList *children;
|
|
Packit |
15f964 |
GtkContainer *container;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
container = GTK_CONTAINER (shell_taskbar->priv->hbox);
|
|
Packit |
15f964 |
gtk_container_remove (container, proxy);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
children = gtk_container_get_children (container);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (children == NULL)
|
|
Packit |
15f964 |
gtk_widget_hide (GTK_WIDGET (container));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_list_free (children);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
shell_taskbar_remove_proxy_container_idle_cb (gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbarIdleData *idle_data = user_data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data != NULL, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data->shell_taskbar != NULL, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data->proxy != NULL, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar_remove_proxy_container (idle_data->shell_taskbar, idle_data->proxy);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_weak_notify_cb (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
GObject *where_the_activity_was)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkWidget *proxy;
|
|
Packit |
15f964 |
GHashTable *proxy_table;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
proxy_table = shell_taskbar->priv->proxy_table;
|
|
Packit |
15f964 |
proxy = g_hash_table_lookup (proxy_table, where_the_activity_was);
|
|
Packit |
15f964 |
g_hash_table_remove (proxy_table, where_the_activity_was);
|
|
Packit |
15f964 |
g_return_if_fail (proxy != NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (shell_taskbar->priv->main_thread == g_thread_self ()) {
|
|
Packit |
15f964 |
shell_taskbar_remove_proxy_container (shell_taskbar, proxy);
|
|
Packit |
15f964 |
} else {
|
|
Packit |
15f964 |
EShellTaskbarIdleData *idle_data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
idle_data = g_new0 (EShellTaskbarIdleData, 1);
|
|
Packit |
15f964 |
idle_data->shell_taskbar = g_object_ref (shell_taskbar);
|
|
Packit |
15f964 |
idle_data->proxy = proxy;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_idle_add_full (
|
|
Packit |
15f964 |
G_PRIORITY_DEFAULT,
|
|
Packit |
15f964 |
shell_taskbar_remove_proxy_container_idle_cb,
|
|
Packit |
15f964 |
idle_data, shell_taskbar_free_idle_data);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_activity_add (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
EActivity *activity)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkBox *box;
|
|
Packit |
15f964 |
GtkWidget *proxy;
|
|
Packit |
15f964 |
EActivityState state;
|
|
Packit |
15f964 |
GHashTable *proxy_table;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Sanity check the activity state. */
|
|
Packit |
15f964 |
state = e_activity_get_state (activity);
|
|
Packit |
15f964 |
g_return_if_fail (state == E_ACTIVITY_RUNNING);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Make sure it hasn't already been added. */
|
|
Packit |
15f964 |
proxy_table = shell_taskbar->priv->proxy_table;
|
|
Packit |
15f964 |
proxy = g_hash_table_lookup (proxy_table, activity);
|
|
Packit |
15f964 |
g_return_if_fail (proxy == NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Proxy widgets manage their own visibility.
|
|
Packit |
15f964 |
* Don't call gtk_widget_show() on it here. */
|
|
Packit |
15f964 |
proxy = e_activity_proxy_new (activity);
|
|
Packit |
15f964 |
box = GTK_BOX (shell_taskbar->priv->hbox);
|
|
Packit |
15f964 |
gtk_box_pack_start (box, proxy, TRUE, TRUE, 0);
|
|
Packit |
15f964 |
gtk_box_reorder_child (box, proxy, 0);
|
|
Packit |
15f964 |
gtk_widget_show (GTK_WIDGET (box));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* The proxy widget also holds a weak reference to the activity,
|
|
Packit |
15f964 |
* so the activity should get finalized in the normal course of
|
|
Packit |
15f964 |
* operation. When that happens we remove the corresponding
|
|
Packit |
15f964 |
* proxy widget from the taskbar. */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_weak_ref (
|
|
Packit |
15f964 |
G_OBJECT (activity), (GWeakNotify)
|
|
Packit |
15f964 |
shell_taskbar_weak_notify_cb, shell_taskbar);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_hash_table_insert (proxy_table, activity, proxy);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
shell_taskbar_add_activity_idle_cb (gpointer user_data)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbarIdleData *idle_data = user_data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data != NULL, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data->shell_taskbar != NULL, FALSE);
|
|
Packit |
15f964 |
g_return_val_if_fail (idle_data->activity != NULL, FALSE);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar_activity_add (idle_data->shell_taskbar, idle_data->activity);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return FALSE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_activity_added_cb (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
EActivity *activity)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
if (shell_taskbar->priv->main_thread == g_thread_self ()) {
|
|
Packit |
15f964 |
shell_taskbar_activity_add (shell_taskbar, activity);
|
|
Packit |
15f964 |
} else {
|
|
Packit |
15f964 |
EShellTaskbarIdleData *idle_data;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
idle_data = g_new0 (EShellTaskbarIdleData, 1);
|
|
Packit |
15f964 |
idle_data->shell_taskbar = g_object_ref (shell_taskbar);
|
|
Packit |
15f964 |
idle_data->activity = g_object_ref (activity);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_idle_add_full (
|
|
Packit |
15f964 |
G_PRIORITY_DEFAULT,
|
|
Packit |
15f964 |
shell_taskbar_add_activity_idle_cb,
|
|
Packit |
15f964 |
idle_data, shell_taskbar_free_idle_data);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static gboolean
|
|
Packit |
15f964 |
shell_taskbar_weak_unref (EActivity *activity,
|
|
Packit |
15f964 |
EActivityProxy *proxy,
|
|
Packit |
15f964 |
EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_object_weak_unref (
|
|
Packit |
15f964 |
G_OBJECT (activity), (GWeakNotify)
|
|
Packit |
15f964 |
shell_taskbar_weak_notify_cb, shell_taskbar);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return TRUE;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_set_shell_view (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (shell_taskbar->priv->shell_view == NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar->priv->shell_view = shell_view;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_add_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (shell_view),
|
|
Packit |
15f964 |
&shell_taskbar->priv->shell_view);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_set_property (GObject *object,
|
|
Packit |
15f964 |
guint property_id,
|
|
Packit |
15f964 |
const GValue *value,
|
|
Packit |
15f964 |
GParamSpec *pspec)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
switch (property_id) {
|
|
Packit |
15f964 |
case PROP_MESSAGE:
|
|
Packit |
15f964 |
e_shell_taskbar_set_message (
|
|
Packit |
15f964 |
E_SHELL_TASKBAR (object),
|
|
Packit |
15f964 |
g_value_get_string (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_VIEW:
|
|
Packit |
15f964 |
shell_taskbar_set_shell_view (
|
|
Packit |
15f964 |
E_SHELL_TASKBAR (object),
|
|
Packit |
15f964 |
g_value_get_object (value));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_get_property (GObject *object,
|
|
Packit |
15f964 |
guint property_id,
|
|
Packit |
15f964 |
GValue *value,
|
|
Packit |
15f964 |
GParamSpec *pspec)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
switch (property_id) {
|
|
Packit |
15f964 |
case PROP_MESSAGE:
|
|
Packit |
15f964 |
g_value_set_string (
|
|
Packit |
15f964 |
value, e_shell_taskbar_get_message (
|
|
Packit |
15f964 |
E_SHELL_TASKBAR (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
case PROP_SHELL_VIEW:
|
|
Packit |
15f964 |
g_value_set_object (
|
|
Packit |
15f964 |
value, e_shell_taskbar_get_shell_view (
|
|
Packit |
15f964 |
E_SHELL_TASKBAR (object)));
|
|
Packit |
15f964 |
return;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_dispose (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbarPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = E_SHELL_TASKBAR_GET_PRIVATE (object);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_hash_table_foreach_remove (
|
|
Packit |
15f964 |
priv->proxy_table, (GHRFunc)
|
|
Packit |
15f964 |
shell_taskbar_weak_unref, object);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->shell_view != NULL) {
|
|
Packit |
15f964 |
g_object_remove_weak_pointer (
|
|
Packit |
15f964 |
G_OBJECT (priv->shell_view), &priv->shell_view);
|
|
Packit |
15f964 |
priv->shell_view = NULL;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (priv->shell_backend != NULL) {
|
|
Packit |
15f964 |
g_signal_handlers_disconnect_matched (
|
|
Packit |
15f964 |
priv->shell_backend, G_SIGNAL_MATCH_DATA,
|
|
Packit |
15f964 |
0, 0, NULL, NULL, object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_clear_object (&priv->shell_backend);
|
|
Packit |
15f964 |
g_clear_object (&priv->label);
|
|
Packit |
15f964 |
g_clear_object (&priv->hbox);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's dispose() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (e_shell_taskbar_parent_class)->dispose (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_finalize (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbarPrivate *priv;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
priv = E_SHELL_TASKBAR_GET_PRIVATE (object);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_hash_table_destroy (priv->proxy_table);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's finalize() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (e_shell_taskbar_parent_class)->finalize (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_constructed (GObject *object)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellView *shell_view;
|
|
Packit |
15f964 |
EShellBackend *shell_backend;
|
|
Packit |
15f964 |
EShellTaskbar *shell_taskbar;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar = E_SHELL_TASKBAR (object);
|
|
Packit |
15f964 |
shell_view = e_shell_taskbar_get_shell_view (shell_taskbar);
|
|
Packit |
15f964 |
shell_backend = e_shell_view_get_shell_backend (shell_view);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Keep a reference to the shell backend so we can
|
|
Packit |
15f964 |
* disconnect the signal handler during dispose(). */
|
|
Packit |
15f964 |
shell_taskbar->priv->shell_backend = g_object_ref (shell_backend);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_signal_connect_swapped (
|
|
Packit |
15f964 |
shell_backend, "activity-added",
|
|
Packit |
15f964 |
G_CALLBACK (shell_taskbar_activity_added_cb), shell_taskbar);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_extensible_load_extensions (E_EXTENSIBLE (object));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's constructed() method. */
|
|
Packit |
15f964 |
G_OBJECT_CLASS (e_shell_taskbar_parent_class)->constructed (object);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_size_allocate (GtkWidget *widget,
|
|
Packit |
15f964 |
GtkAllocation *allocation)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbar *shell_taskbar;
|
|
Packit |
15f964 |
gint fixed_height, minimum_height = 0, natural_height = 0;
|
|
Packit |
15f964 |
gboolean height_changed;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (GTK_WIDGET_CLASS (e_shell_taskbar_parent_class)->get_preferred_height)
|
|
Packit |
15f964 |
GTK_WIDGET_CLASS (e_shell_taskbar_parent_class)->get_preferred_height (widget, &minimum_height, &natural_height);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar = E_SHELL_TASKBAR (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Maximum height allocation sticks. */
|
|
Packit |
15f964 |
fixed_height = shell_taskbar->priv->fixed_height;
|
|
Packit |
15f964 |
fixed_height = MAX (fixed_height, MAX (allocation->height, minimum_height));
|
|
Packit |
15f964 |
height_changed = fixed_height != shell_taskbar->priv->fixed_height;
|
|
Packit |
15f964 |
shell_taskbar->priv->fixed_height = fixed_height;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/* Chain up to parent's size_allocate() method. */
|
|
Packit |
15f964 |
GTK_WIDGET_CLASS (e_shell_taskbar_parent_class)->
|
|
Packit |
15f964 |
size_allocate (widget, allocation);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (height_changed)
|
|
Packit |
15f964 |
g_object_set (G_OBJECT (shell_taskbar), "height-request", fixed_height, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_get_preferred_height (GtkWidget *widget,
|
|
Packit |
15f964 |
gint *minimum_height,
|
|
Packit |
15f964 |
gint *natural_height)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
EShellTaskbar *shell_taskbar;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar = E_SHELL_TASKBAR (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (minimum_height != NULL)
|
|
Packit |
15f964 |
*minimum_height = shell_taskbar->priv->fixed_height;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (natural_height != NULL)
|
|
Packit |
15f964 |
*natural_height = shell_taskbar->priv->fixed_height;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
shell_taskbar_get_preferred_width (GtkWidget *widget,
|
|
Packit |
15f964 |
gint *minimum_width,
|
|
Packit |
15f964 |
gint *natural_width)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
/* to never get larger than allocated size (which changes window width) */
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (minimum_width != NULL)
|
|
Packit |
15f964 |
*minimum_width = 1;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (natural_width != NULL)
|
|
Packit |
15f964 |
*natural_width = 1;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
e_shell_taskbar_class_init (EShellTaskbarClass *class)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GObjectClass *object_class;
|
|
Packit |
15f964 |
GtkWidgetClass *widget_class;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_type_class_add_private (class, sizeof (EShellTaskbarPrivate));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
object_class = G_OBJECT_CLASS (class);
|
|
Packit |
15f964 |
object_class->set_property = shell_taskbar_set_property;
|
|
Packit |
15f964 |
object_class->get_property = shell_taskbar_get_property;
|
|
Packit |
15f964 |
object_class->dispose = shell_taskbar_dispose;
|
|
Packit |
15f964 |
object_class->finalize = shell_taskbar_finalize;
|
|
Packit |
15f964 |
object_class->constructed = shell_taskbar_constructed;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget_class = GTK_WIDGET_CLASS (class);
|
|
Packit |
15f964 |
widget_class->size_allocate = shell_taskbar_size_allocate;
|
|
Packit |
15f964 |
widget_class->get_preferred_height = shell_taskbar_get_preferred_height;
|
|
Packit |
15f964 |
widget_class->get_preferred_width = shell_taskbar_get_preferred_width;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellTaskbar:message
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The message to display in the taskbar.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_MESSAGE,
|
|
Packit |
15f964 |
g_param_spec_string (
|
|
Packit |
15f964 |
"message",
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_CONSTRUCT |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* EShellTaskbar:shell-view
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* The #EShellView to which the taskbar widget belongs.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
g_object_class_install_property (
|
|
Packit |
15f964 |
object_class,
|
|
Packit |
15f964 |
PROP_SHELL_VIEW,
|
|
Packit |
15f964 |
g_param_spec_object (
|
|
Packit |
15f964 |
"shell-view",
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
NULL,
|
|
Packit |
15f964 |
E_TYPE_SHELL_VIEW,
|
|
Packit |
15f964 |
G_PARAM_READWRITE |
|
|
Packit |
15f964 |
G_PARAM_CONSTRUCT_ONLY |
|
|
Packit |
15f964 |
G_PARAM_STATIC_STRINGS));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
static void
|
|
Packit |
15f964 |
e_shell_taskbar_init (EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkWidget *widget;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
shell_taskbar->priv = E_SHELL_TASKBAR_GET_PRIVATE (shell_taskbar);
|
|
Packit |
15f964 |
shell_taskbar->priv->proxy_table = g_hash_table_new (NULL, NULL);
|
|
Packit |
15f964 |
shell_taskbar->priv->main_thread = g_thread_self ();
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
gtk_box_set_spacing (GTK_BOX (shell_taskbar), 12);
|
|
Packit |
15f964 |
gtk_orientable_set_orientation (GTK_ORIENTABLE (shell_taskbar), GTK_ORIENTATION_HORIZONTAL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget = gtk_label_new (NULL);
|
|
Packit |
15f964 |
gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END);
|
|
Packit |
15f964 |
gtk_box_pack_start (GTK_BOX (shell_taskbar), widget, TRUE, TRUE, 0);
|
|
Packit |
15f964 |
gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
|
|
Packit |
15f964 |
shell_taskbar->priv->label = g_object_ref (widget);
|
|
Packit |
15f964 |
gtk_widget_hide (widget);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
|
|
Packit |
15f964 |
gtk_box_pack_start (GTK_BOX (shell_taskbar), widget, TRUE, TRUE, 0);
|
|
Packit |
15f964 |
shell_taskbar->priv->hbox = g_object_ref (widget);
|
|
Packit |
15f964 |
gtk_widget_hide (widget);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_new:
|
|
Packit |
15f964 |
* @shell_view: an #EShellView
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Creates a new #EShellTaskbar instance belonging to @shell_view.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: a new #EShellTaskbar instance
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
GtkWidget *
|
|
Packit |
15f964 |
e_shell_taskbar_new (EShellView *shell_view)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return g_object_new (
|
|
Packit |
15f964 |
E_TYPE_SHELL_TASKBAR, "shell-view", shell_view, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_get_shell_view:
|
|
Packit |
15f964 |
* @shell_taskbar: an #EShellTaskbar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the #EShellView that was passed to e_shell_taskbar_new().
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the #EShellView to which @shell_taskbar belongs
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
EShellView *
|
|
Packit |
15f964 |
e_shell_taskbar_get_shell_view (EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return shell_taskbar->priv->shell_view;
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_get_message:
|
|
Packit |
15f964 |
* @shell_taskbar: an #EShellTaskbar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the message currently shown in the taskbar, or an empty string
|
|
Packit |
15f964 |
* if no message is shown. Taskbar messages are used primarily for menu
|
|
Packit |
15f964 |
* tooltips.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the current taskbar message
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
const gchar *
|
|
Packit |
15f964 |
e_shell_taskbar_get_message (EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkWidget *label;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), NULL);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
label = shell_taskbar->priv->label;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return gtk_label_get_text (GTK_LABEL (label));
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_set_message:
|
|
Packit |
15f964 |
* @shell_taskbar: an #EShellTaskbar
|
|
Packit |
15f964 |
* @message: the message to show
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Shows a message in the taskbar. If @message is %NULL or an empty string,
|
|
Packit |
15f964 |
* the taskbar message is cleared. Taskbar messages are used primarily for
|
|
Packit |
15f964 |
* menu tooltips.
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_taskbar_set_message (EShellTaskbar *shell_taskbar,
|
|
Packit |
15f964 |
const gchar *message)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
GtkWidget *label;
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
label = shell_taskbar->priv->label;
|
|
Packit |
15f964 |
gtk_label_set_text (GTK_LABEL (label), message);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
if (message != NULL && *message != '\0')
|
|
Packit |
15f964 |
gtk_widget_show (label);
|
|
Packit |
15f964 |
else
|
|
Packit |
15f964 |
gtk_widget_hide (label);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
g_object_notify (G_OBJECT (shell_taskbar), "message");
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_unset_message:
|
|
Packit |
15f964 |
* @shell_taskbar: an #EShellTaskbar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* This is equivalent to passing a %NULL message to
|
|
Packit |
15f964 |
* e_shell_taskbar_set_message().
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
void
|
|
Packit |
15f964 |
e_shell_taskbar_unset_message (EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar));
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
e_shell_taskbar_set_message (shell_taskbar, NULL);
|
|
Packit |
15f964 |
}
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
/**
|
|
Packit |
15f964 |
* e_shell_taskbar_get_activity_count:
|
|
Packit |
15f964 |
* @shell_taskbar: an #EShellTaskbar
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns the number of active #EActivity instances being tracked.
|
|
Packit |
15f964 |
*
|
|
Packit |
15f964 |
* Returns: the number of #EActivity instances
|
|
Packit |
15f964 |
**/
|
|
Packit |
15f964 |
guint
|
|
Packit |
15f964 |
e_shell_taskbar_get_activity_count (EShellTaskbar *shell_taskbar)
|
|
Packit |
15f964 |
{
|
|
Packit |
15f964 |
g_return_val_if_fail (E_IS_SHELL_TASKBAR (shell_taskbar), 0);
|
|
Packit |
15f964 |
|
|
Packit |
15f964 |
return g_hash_table_size (shell_taskbar->priv->proxy_table);
|
|
Packit |
15f964 |
}
|