Rename ShellAppMonitor to ShellAppSystem
This makes it clearer that really we're now an API, not just a monitor.
This commit is contained in:
parent
56644dfada
commit
b632801c7c
@ -226,9 +226,9 @@ AppDisplay.prototype = {
|
||||
this._appCategories = {};
|
||||
|
||||
let me = this;
|
||||
this._appMonitor = new Shell.AppMonitor();
|
||||
this._appSystem = new Shell.AppSystem();
|
||||
this._appsStale = true;
|
||||
this._appMonitor.connect('changed', function(mon) {
|
||||
this._appSystem.connect('changed', function(mon) {
|
||||
me._appsStale = true;
|
||||
// We still need to determine what events other than search can trigger
|
||||
// a change in the set of applications that are being shown while the
|
||||
@ -334,7 +334,7 @@ AppDisplay.prototype = {
|
||||
this._activeMenu.setState(MENU_UNSELECTED);
|
||||
this._activeMenuIndex = menuIndex;
|
||||
this._activeMenu = display;
|
||||
this._activeMenuApps = this._appMonitor.get_applications_for_menu(menu.id);
|
||||
this._activeMenuApps = this._appSystem.get_applications_for_menu(menu.id);
|
||||
}
|
||||
this._redisplay();
|
||||
}));
|
||||
@ -352,7 +352,7 @@ AppDisplay.prototype = {
|
||||
this._allItems = {};
|
||||
this._appCategories = {};
|
||||
|
||||
this._menus = this._appMonitor.get_menus();
|
||||
this._menus = this._appSystem.get_menus();
|
||||
|
||||
let apps = Gio.app_info_get_all();
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
|
@ -49,8 +49,8 @@ CLEANFILES += $(SHELL_STAMP_FILES)
|
||||
libgnome_shell_la_SOURCES = \
|
||||
$(shell_built_sources) \
|
||||
gnome-shell-plugin.c \
|
||||
shell-app-monitor.c \
|
||||
shell-app-monitor.h \
|
||||
shell-app-system.c \
|
||||
shell-app-system.h \
|
||||
shell-arrow.c \
|
||||
shell-arrow.h \
|
||||
shell-gtkwindow-actor.c \
|
||||
|
@ -1,48 +0,0 @@
|
||||
#ifndef __SHELL_APP_MONITOR_H__
|
||||
#define __SHELL_APP_MONITOR_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#define SHELL_TYPE_APP_MONITOR (shell_app_monitor_get_type ())
|
||||
#define SHELL_APP_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_APP_MONITOR, ShellAppMonitor))
|
||||
#define SHELL_APP_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_APP_MONITOR, ShellAppMonitorClass))
|
||||
#define SHELL_IS_APP_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_APP_MONITOR))
|
||||
#define SHELL_IS_APP_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_APP_MONITOR))
|
||||
#define SHELL_APP_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_APP_MONITOR, ShellAppMonitorClass))
|
||||
|
||||
typedef struct _ShellAppMonitor ShellAppMonitor;
|
||||
typedef struct _ShellAppMonitorClass ShellAppMonitorClass;
|
||||
typedef struct _ShellAppMonitorPrivate ShellAppMonitorPrivate;
|
||||
|
||||
struct _ShellAppMonitor
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
ShellAppMonitorPrivate *priv;
|
||||
};
|
||||
|
||||
struct _ShellAppMonitorClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*changed)(ShellAppMonitor *menuwrapper, gpointer data);
|
||||
};
|
||||
|
||||
GType shell_app_monitor_get_type (void) G_GNUC_CONST;
|
||||
ShellAppMonitor* shell_app_monitor_new(void);
|
||||
|
||||
GList *shell_app_monitor_get_applications_for_menu (ShellAppMonitor *monitor, const char *menu);
|
||||
|
||||
typedef struct _ShellAppMenuEntry ShellAppMenuEntry;
|
||||
|
||||
struct _ShellAppMenuEntry {
|
||||
char *name;
|
||||
char *id;
|
||||
char *icon;
|
||||
};
|
||||
|
||||
GType shell_app_menu_entry_get_type (void);
|
||||
|
||||
GList *shell_app_monitor_get_menus (ShellAppMonitor *monitor);
|
||||
|
||||
#endif /* __SHELL_APP_MONITOR_H__ */
|
@ -1,6 +1,6 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#include "shell-app-monitor.h"
|
||||
#include "shell-app-system.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@ -19,18 +19,18 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
struct _ShellAppMonitorPrivate {
|
||||
struct _ShellAppSystemPrivate {
|
||||
GMenuTree *tree;
|
||||
GMenuTreeDirectory *trunk;
|
||||
|
||||
GList *cached_menus;
|
||||
};
|
||||
|
||||
static void shell_app_monitor_finalize (GObject *object);
|
||||
static void shell_app_system_finalize (GObject *object);
|
||||
static void on_tree_changed (GMenuTree *tree, gpointer user_data);
|
||||
static void reread_menus (ShellAppMonitor *self);
|
||||
static void reread_menus (ShellAppSystem *self);
|
||||
|
||||
G_DEFINE_TYPE(ShellAppMonitor, shell_app_monitor, G_TYPE_OBJECT);
|
||||
G_DEFINE_TYPE(ShellAppSystem, shell_app_system, G_TYPE_OBJECT);
|
||||
|
||||
static gpointer
|
||||
shell_app_menu_entry_copy (gpointer entryp)
|
||||
@ -55,31 +55,31 @@ shell_app_menu_entry_free (gpointer entryp)
|
||||
g_free (entry);
|
||||
}
|
||||
|
||||
static void shell_app_monitor_class_init(ShellAppMonitorClass *klass)
|
||||
static void shell_app_system_class_init(ShellAppSystemClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *)klass;
|
||||
|
||||
gobject_class->finalize = shell_app_monitor_finalize;
|
||||
gobject_class->finalize = shell_app_system_finalize;
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
SHELL_TYPE_APP_MONITOR,
|
||||
SHELL_TYPE_APP_SYSTEM,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (ShellAppMonitorClass, changed),
|
||||
G_STRUCT_OFFSET (ShellAppSystemClass, changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (ShellAppMonitorPrivate));
|
||||
g_type_class_add_private (gobject_class, sizeof (ShellAppSystemPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
shell_app_monitor_init (ShellAppMonitor *self)
|
||||
shell_app_system_init (ShellAppSystem *self)
|
||||
{
|
||||
ShellAppMonitorPrivate *priv;
|
||||
ShellAppSystemPrivate *priv;
|
||||
self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||
SHELL_TYPE_APP_MONITOR,
|
||||
ShellAppMonitorPrivate);
|
||||
SHELL_TYPE_APP_SYSTEM,
|
||||
ShellAppSystemPrivate);
|
||||
|
||||
priv->tree = gmenu_tree_lookup ("applications.menu", GMENU_TREE_FLAGS_NONE);
|
||||
|
||||
@ -91,19 +91,24 @@ shell_app_monitor_init (ShellAppMonitor *self)
|
||||
}
|
||||
|
||||
static void
|
||||
shell_app_monitor_finalize (GObject *object)
|
||||
shell_app_system_finalize (GObject *object)
|
||||
{
|
||||
ShellAppMonitor *self = SHELL_APP_MONITOR (object);
|
||||
ShellAppSystem *self = SHELL_APP_SYSTEM (object);
|
||||
ShellAppSystemPrivate *priv = self->priv;
|
||||
|
||||
G_OBJECT_CLASS (shell_app_monitor_parent_class)->finalize(object);
|
||||
gmenu_tree_remove_monitor (priv->tree, on_tree_changed, self);
|
||||
|
||||
gmenu_tree_unref (priv->tree);
|
||||
|
||||
G_OBJECT_CLASS (shell_app_system_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
reread_menus (ShellAppMonitor *self)
|
||||
reread_menus (ShellAppSystem *self)
|
||||
{
|
||||
GSList *entries = gmenu_tree_directory_get_contents (self->priv->trunk);
|
||||
GSList *iter;
|
||||
ShellAppMonitorPrivate *priv = self->priv;
|
||||
ShellAppSystemPrivate *priv = self->priv;
|
||||
|
||||
g_list_foreach (self->priv->cached_menus, (GFunc)shell_app_menu_entry_free, NULL);
|
||||
g_list_free (self->priv->cached_menus);
|
||||
@ -141,7 +146,7 @@ reread_menus (ShellAppMonitor *self)
|
||||
static void
|
||||
on_tree_changed (GMenuTree *monitor, gpointer user_data)
|
||||
{
|
||||
ShellAppMonitor *self = SHELL_APP_MONITOR (user_data);
|
||||
ShellAppSystem *self = SHELL_APP_SYSTEM (user_data);
|
||||
|
||||
g_signal_emit (self, signals[CHANGED], 0);
|
||||
|
||||
@ -162,12 +167,12 @@ shell_app_menu_entry_get_type (void)
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_app_monitor_get_applications_for_menu:
|
||||
* shell_app_system_get_applications_for_menu:
|
||||
*
|
||||
* Return value: (transfer full) (element-type utf8): List of desktop file ids
|
||||
*/
|
||||
GList *
|
||||
shell_app_monitor_get_applications_for_menu (ShellAppMonitor *monitor,
|
||||
shell_app_system_get_applications_for_menu (ShellAppSystem *monitor,
|
||||
const char *menu)
|
||||
{
|
||||
GList *ret = NULL;
|
||||
@ -206,12 +211,12 @@ shell_app_monitor_get_applications_for_menu (ShellAppMonitor *monitor,
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_app_monitor_get_menus:
|
||||
* shell_app_system_get_menus:
|
||||
*
|
||||
* Return value: (transfer none) (element-type AppMenuEntry): List of toplevel menus
|
||||
*/
|
||||
GList *
|
||||
shell_app_monitor_get_menus (ShellAppMonitor *monitor)
|
||||
shell_app_system_get_menus (ShellAppSystem *monitor)
|
||||
{
|
||||
return monitor->priv->cached_menus;
|
||||
}
|
48
src/shell-app-system.h
Normal file
48
src/shell-app-system.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef __SHELL_APP_SYSTEM_H__
|
||||
#define __SHELL_APP_SYSTEM_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#define SHELL_TYPE_APP_SYSTEM (shell_app_system_get_type ())
|
||||
#define SHELL_APP_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHELL_TYPE_APP_SYSTEM, ShellAppSystem))
|
||||
#define SHELL_APP_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SHELL_TYPE_APP_SYSTEM, ShellAppSystemClass))
|
||||
#define SHELL_IS_APP_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SHELL_TYPE_APP_SYSTEM))
|
||||
#define SHELL_IS_APP_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SHELL_TYPE_APP_SYSTEM))
|
||||
#define SHELL_APP_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SHELL_TYPE_APP_SYSTEM, ShellAppSystemClass))
|
||||
|
||||
typedef struct _ShellAppSystem ShellAppSystem;
|
||||
typedef struct _ShellAppSystemClass ShellAppSystemClass;
|
||||
typedef struct _ShellAppSystemPrivate ShellAppSystemPrivate;
|
||||
|
||||
struct _ShellAppSystem
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
ShellAppSystemPrivate *priv;
|
||||
};
|
||||
|
||||
struct _ShellAppSystemClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*changed)(ShellAppSystem *appsys, gpointer data);
|
||||
};
|
||||
|
||||
GType shell_app_system_get_type (void) G_GNUC_CONST;
|
||||
ShellAppSystem* shell_app_system_new(void);
|
||||
|
||||
GList *shell_app_system_get_applications_for_menu (ShellAppSystem *monitor, const char *menu);
|
||||
|
||||
typedef struct _ShellAppMenuEntry ShellAppMenuEntry;
|
||||
|
||||
struct _ShellAppMenuEntry {
|
||||
char *name;
|
||||
char *id;
|
||||
char *icon;
|
||||
};
|
||||
|
||||
GType shell_app_menu_entry_get_type (void);
|
||||
|
||||
GList *shell_app_system_get_menus (ShellAppSystem *monitor);
|
||||
|
||||
#endif /* __SHELL_APP_SYSTEM_H__ */
|
Loading…
Reference in New Issue
Block a user