Add application menu area to panel

This is a start at the "Active Appliction Item" component of the
shell design.  Currently we just show the currently focused
application.  When launching a new application, we show that as well.

The implementation here is not complete; basically when launching
we de-focus the active one, and the application well shows the
most recent startup sequence.

This kind of fails in the case of multiple sequences, and we
also don't correctly de-focus the current window in other
launch paths.
This commit is contained in:
Colin Walters
2009-08-11 11:32:58 -04:00
parent e330c5ea17
commit 74eac21870
5 changed files with 244 additions and 2 deletions

View File

@ -11,6 +11,10 @@
#include <gconf/gconf-client.h>
#include <dbus/dbus-glib.h>
#define SN_API_NOT_YET_FROZEN 1
#include <libsn/sn.h>
#include "shell-texture-cache.h"
#include "shell-app-monitor.h"
#include "shell-app-system.h"
#include "shell-global.h"
@ -151,6 +155,7 @@ struct AppUsage
enum {
CHANGED,
STARTUP_SEQUENCE_CHANGED,
LAST_SIGNAL
};
@ -198,6 +203,14 @@ static void shell_app_monitor_class_init(ShellAppMonitorClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[STARTUP_SEQUENCE_CHANGED] = g_signal_new ("startup-sequence-changed",
SHELL_TYPE_APP_MONITOR,
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1, SHELL_TYPE_STARTUP_SEQUENCE);
}
static void
@ -694,9 +707,19 @@ init_window_monitoring (ShellAppMonitor *self)
shell_app_monitor_on_n_workspaces_changed (screen, NULL, self);
}
static void
on_startup_sequence_changed (MetaScreen *screen,
SnStartupSequence *sequence,
ShellAppMonitor *self)
{
/* Just proxy the signal */
g_signal_emit (G_OBJECT (self), signals[STARTUP_SEQUENCE_CHANGED], 0, sequence);
}
static void
shell_app_monitor_init (ShellAppMonitor *self)
{
MetaScreen *screen;
GdkDisplay *display;
char *path;
char *shell_config_dir;
@ -704,6 +727,7 @@ shell_app_monitor_init (ShellAppMonitor *self)
/* FIXME: should we create as many monitors as there are GdkScreens? */
display = gdk_display_get_default ();
screen = shell_global_get_screen (shell_global_get ());
session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
self->session_proxy = dbus_g_proxy_new_for_name (session_bus, "org.gnome.SessionManager",
@ -735,6 +759,9 @@ shell_app_monitor_init (ShellAppMonitor *self)
load_initial_windows (self);
init_window_monitoring (self);
g_signal_connect (G_OBJECT (screen), "startup-sequence-changed",
G_CALLBACK (on_startup_sequence_changed), self);
self->gconf_client = gconf_client_get_default ();
gconf_client_add_dir (self->gconf_client, APP_MONITOR_GCONF_DIR,
GCONF_CLIENT_PRELOAD_NONE, NULL);
@ -1339,6 +1366,90 @@ on_enable_monitoring_key_changed (GConfClient *client,
update_enable_monitoring ((ShellAppMonitor *) monitor);
}
/**
* shell_app_monitor_get_startup_sequences:
* @self:
*
* Returns: (transfer none) (element-type ShellStartupSequence): Currently active startup sequences
*/
GSList *
shell_app_monitor_get_startup_sequences (ShellAppMonitor *self)
{
ShellGlobal *global = shell_global_get ();
MetaScreen *screen = shell_global_get_screen (global);
return meta_screen_get_startup_sequences (screen);
}
/* sn_startup_sequence_ref returns void, so make a
* wrapper which returns self */
SnStartupSequence *
sequence_ref (SnStartupSequence *sequence)
{
sn_startup_sequence_ref (sequence);
return sequence;
}
GType
shell_startup_sequence_get_type (void)
{
static GType gtype = G_TYPE_INVALID;
if (gtype == G_TYPE_INVALID)
{
gtype = g_boxed_type_register_static ("ShellStartupSequence",
(GBoxedCopyFunc)sequence_ref,
(GBoxedFreeFunc)sn_startup_sequence_unref);
}
return gtype;
}
const char *
shell_startup_sequence_get_id (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_id ((SnStartupSequence*)sequence);
}
const char *
shell_startup_sequence_get_name (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_name ((SnStartupSequence*)sequence);
}
gboolean
shell_startup_sequence_get_completed (ShellStartupSequence *sequence)
{
return sn_startup_sequence_get_completed ((SnStartupSequence*)sequence);
}
/**
* shell_startup_sequence_create_icon:
* @sequence:
* @size: Size in pixels of icon
*
* Returns: (transfer none): A new #ClutterTexture containing an icon for the sequence
*/
ClutterActor *
shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size)
{
GThemedIcon *themed;
const char *icon_name;
ClutterActor *texture;
icon_name = sn_startup_sequence_get_icon_name ((SnStartupSequence*)sequence);
if (!icon_name)
{
texture = clutter_texture_new ();
clutter_actor_set_size (texture, size, size);
return texture;
}
themed = (GThemedIcon*)g_themed_icon_new (icon_name);
texture = shell_texture_cache_load_gicon (shell_texture_cache_get_default (),
G_ICON (themed), size);
g_object_unref (G_OBJECT (themed));
return texture;
}
/**
* shell_app_monitor_get_default:
*

View File

@ -49,6 +49,18 @@ GSList *shell_app_monitor_get_windows_for_app (ShellAppMonitor *monitor, const c
/* Get whatever's running right now */
GSList *shell_app_monitor_get_running_app_ids (ShellAppMonitor *monitor, const char *context);
GSList *shell_app_monitor_get_startup_sequences (ShellAppMonitor *monitor);
/* Hidden typedef for SnStartupSequence */
typedef struct _ShellStartupSequence ShellStartupSequence;
#define SHELL_TYPE_STARTUP_SEQUENCE (shell_startup_sequence_get_type ())
GType shell_startup_sequence_get_type (void);
const char *shell_startup_sequence_get_id (ShellStartupSequence *sequence);
const char *shell_startup_sequence_get_name (ShellStartupSequence *sequence);
gboolean shell_startup_sequence_get_completed (ShellStartupSequence *sequence);
ClutterActor *shell_startup_sequence_create_icon (ShellStartupSequence *sequence, guint size);
G_END_DECLS
#endif /* __SHELL_APP_MONITOR_H__ */

View File

@ -8,6 +8,7 @@
#include <gtk/gtk.h>
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <clutter/clutter.h>
#include "shell-global.h"
#include "shell-texture-cache.h"
@ -922,7 +923,13 @@ shell_app_info_launch_full (ShellAppInfo *info,
display = meta_screen_get_display (screen);
if (timestamp == 0)
timestamp = meta_display_get_current_time (display);
timestamp = clutter_get_current_event_time ();
/* Shell design calls for on application launch, no window is focused,
* and we have startup notification displayed.
*/
meta_display_focus_the_no_focus_window (display, screen, timestamp);
if (workspace < 0)
workspace = meta_screen_get_active_workspace_index (screen);