summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac11
-rw-r--r--data/Makefile.am25
-rw-r--r--data/org.raspberrypi.weston-gtk-shell.gschema.xml.in.in14
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/favorites.c134
-rw-r--r--shell/favorites.h38
-rw-r--r--shell/gtk-shell.c20
8 files changed, 240 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index c43d8f9..fd9d709 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1 +1 @@
-SUBDIRS = protocol shell
+SUBDIRS = data protocol shell po
diff --git a/configure.ac b/configure.ac
index 18bc5b3..b252c18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,13 @@ AM_SILENT_RULES([yes])
# Check for programs
AC_PROG_CC
+IT_PROG_INTLTOOL([0.40])
+
+GETTEXT_PACKAGE=weston-gtk-shell
+AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
+ [The prefix for our gettext translation domains.])
+
PKG_PROG_PKG_CONFIG()
PKG_CHECK_MODULES([GTK], [
@@ -22,10 +29,14 @@ PKG_CHECK_MODULES([GTK], [
gnome-desktop-3.0
])
+GLIB_GSETTINGS
+
WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
AC_CONFIG_FILES([Makefile
+ data/Makefile
shell/Makefile
+ po/Makefile.in
protocol/Makefile
])
AC_OUTPUT
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..f7378ef
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,25 @@
+gsettings_SCHEMAS = org.raspberrypi.weston-gtk-shell.gschema.xml
+
+@INTLTOOL_XML_NOMERGE_RULE@
+
+%.gschema.xml.in: %.gschema.xml.in.in Makefile
+ $(AM_V_GEN) sed -e 's|@GETTEXT_PACKAGE[@]|$(GETTEXT_PACKAGE)|g' \
+ $< > $@ || rm $@
+
+@GSETTINGS_RULES@
+
+# We need to compile schemas at make time
+# to run from source tree
+gschemas.compiled: $(gsettings_SCHEMAS:.xml=.valid)
+ $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --targetdir=. .
+
+all-local: gschemas.compiled
+
+EXTRA_DIST = \
+ org.raspberrypi.weston-gtk-shell.gschema.xml.in.in
+
+CLEANFILES = \
+ gschemas.compiled \
+ org.raspberrypi.weston-gtk-shell.gschema.valid \
+ $(gsettings_SCHEMAS) \
+ $(gsettings_SCHEMAS).in
diff --git a/data/org.raspberrypi.weston-gtk-shell.gschema.xml.in.in b/data/org.raspberrypi.weston-gtk-shell.gschema.xml.in.in
new file mode 100644
index 0000000..34d1136
--- /dev/null
+++ b/data/org.raspberrypi.weston-gtk-shell.gschema.xml.in.in
@@ -0,0 +1,14 @@
+<schemalist>
+ <schema id="org.raspberrypi.weston-gtk-shell"
+ path="/org/raspberrypi/weston-gtk-shell/"
+ gettext-domain="@GETTEXT_PACKAGE@">
+ <key name="favorites" type="as">
+ <default>[ 'epiphany.desktop', 'libreoffice-writer.desktop', 'nautilus.desktop' ]</default>
+ <_summary>List of desktop file IDs for favorite applications</_summary>
+ <_description>
+ The applications corresponding to these identifiers
+ will be displayed in the panel.
+ </_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 9fbaa93..44433f0 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -15,6 +15,8 @@ weston_gtk_shell_SOURCES = \
app-launcher.h \
clock.c \
clock.h \
+ favorites.c \
+ favorites.h \
launcher-grid.c \
launcher-grid.h \
shell-app-system.c \
diff --git a/shell/favorites.c b/shell/favorites.c
new file mode 100644
index 0000000..9d3d021
--- /dev/null
+++ b/shell/favorites.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2013 Collabora Ltd.
+ *
+ * Author: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
+ */
+
+#include "config.h"
+
+#include "favorites.h"
+
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
+#include <gtk/gtk.h>
+
+enum {
+ PROP_0,
+};
+
+struct WestonGtkFavoritesPrivate {
+ GSettings *settings;
+};
+
+G_DEFINE_TYPE(WestonGtkFavorites, weston_gtk_favorites, GTK_TYPE_BOX)
+
+static void
+favorite_clicked (GtkButton *button,
+ WestonGtkFavorites *self)
+{
+ GAppInfo *info = g_object_get_data (G_OBJECT(button), "info");
+ GError *error = NULL;
+
+ g_app_info_launch (info, NULL, NULL, &error);
+ if (error)
+ {
+ g_warning ("Could not launch app %s: %s",
+ g_app_info_get_name (info),
+ error->message);
+ g_clear_error (&error);
+ }
+}
+
+static void
+add_favorite (WestonGtkFavorites *self,
+ const gchar *favorite)
+{
+ GDesktopAppInfo *info;
+ GtkWidget *button, *image;
+ GIcon *icon;
+
+ info = g_desktop_app_info_new (favorite);
+
+ if (!info)
+ return;
+
+ icon = g_app_info_get_icon (G_APP_INFO (info));
+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button), image);
+
+ g_object_set_data_full (G_OBJECT (button), "info", info, g_object_unref);
+
+ g_signal_connect (button, "clicked", G_CALLBACK (favorite_clicked), self);
+
+ gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
+}
+
+static void
+remove_favorite (GtkWidget *favorite,
+ gpointer user_data)
+{
+ gtk_widget_destroy (favorite);
+}
+
+static void
+favorites_changed (GSettings *settings,
+ const gchar *key,
+ WestonGtkFavorites *self)
+{
+ gchar **favorites = g_settings_get_strv (settings, key);
+ gint i;
+
+ /* Remove all favorites first */
+ gtk_container_foreach (GTK_CONTAINER (self), remove_favorite, NULL);
+
+ for (i = 0; i < g_strv_length (favorites); i++)
+ {
+ gchar *fav = favorites[i];
+
+ add_favorite (self, fav);
+ }
+
+ g_strfreev (favorites);
+}
+
+static void
+weston_gtk_favorites_dispose (GObject *object)
+{
+ WestonGtkFavorites *self = WESTON_GTK_FAVORITES (object);
+
+ g_clear_object (&self->priv->settings);
+
+ G_OBJECT_CLASS (weston_gtk_favorites_parent_class)->dispose (object);
+}
+
+static void
+weston_gtk_favorites_init (WestonGtkFavorites *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ WESTON_GTK_TYPE_FAVORITES,
+ WestonGtkFavoritesPrivate);
+
+ self->priv->settings = g_settings_new ("org.raspberrypi.weston-gtk-shell");
+ g_signal_connect (self->priv->settings, "changed::favorites",
+ G_CALLBACK (favorites_changed), self);
+ favorites_changed (self->priv->settings, "favorites", self);
+
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL);
+}
+
+static void
+weston_gtk_favorites_class_init (WestonGtkFavoritesClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *)klass;
+
+ object_class->dispose = weston_gtk_favorites_dispose;
+
+ g_type_class_add_private (object_class, sizeof (WestonGtkFavoritesPrivate));
+}
+
+GtkWidget *
+weston_gtk_favorites_new (void)
+{
+ return g_object_new (WESTON_GTK_TYPE_FAVORITES, NULL);
+}
diff --git a/shell/favorites.h b/shell/favorites.h
new file mode 100644
index 0000000..4c192e1
--- /dev/null
+++ b/shell/favorites.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Collabora Ltd.
+ *
+ * Author: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
+ */
+
+#ifndef __WESTON_GTK_FAVORITES_H__
+#define __WESTON_GTK_FAVORITES_H__
+
+#include <gtk/gtk.h>
+
+#define WESTON_GTK_TYPE_FAVORITES (weston_gtk_favorites_get_type ())
+#define WESTON_GTK_FAVORITES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WESTON_GTK_TYPE_FAVORITES, WestonGtkFavorites))
+#define WESTON_GTK_FAVORITES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WESTON_GTK_TYPE_FAVORITES, WestonGtkFavoritesClass))
+#define WESTON_GTK_IS_FAVORITES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WESTON_GTK_TYPE_FAVORITES))
+#define WESTON_GTK_IS_FAVORITES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WESTON_GTK_TYPE_FAVORITES))
+#define WESTON_GTK_FAVORITES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WESTON_GTK_TYPE_FAVORITES, WestonGtkFavoritesClass))
+
+typedef struct WestonGtkFavorites WestonGtkFavorites;
+typedef struct WestonGtkFavoritesClass WestonGtkFavoritesClass;
+typedef struct WestonGtkFavoritesPrivate WestonGtkFavoritesPrivate;
+
+struct WestonGtkFavorites
+{
+ GtkBox parent;
+
+ WestonGtkFavoritesPrivate *priv;
+};
+
+struct WestonGtkFavoritesClass
+{
+ GtkBoxClass parent_class;
+};
+
+GType weston_gtk_favorites_get_type (void) G_GNUC_CONST;
+GtkWidget *weston_gtk_favorites_new (void);
+
+#endif /* __WESTON_GTK_FAVORITES_H__ */
diff --git a/shell/gtk-shell.c b/shell/gtk-shell.c
index dc94591..2d6dc13 100644
--- a/shell/gtk-shell.c
+++ b/shell/gtk-shell.c
@@ -5,8 +5,9 @@
#include <gdk/gdkwayland.h>
#include "desktop-shell-client-protocol.h"
-#include "launcher-grid.h"
#include "clock.h"
+#include "favorites.h"
+#include "launcher-grid.h"
extern char **environ; /* defined by libc */
@@ -112,7 +113,7 @@ panel_create(struct desktop *desktop)
{
GdkWindow *gdk_window;
struct element *panel;
- GtkWidget *box1, *button;
+ GtkWidget *box1, *box2, *button;
panel = malloc(sizeof *panel);
memset(panel, 0, sizeof *panel);
@@ -126,13 +127,22 @@ panel_create(struct desktop *desktop)
box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (panel->window), box1);
+ /* We have a box on the left and a box on the right set to expand
+ * so that they both have the same size and thus the favorites end
+ * exactly in the middle of the panel.
+ */
+ box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
button = gtk_button_new_with_label ("Menu");
g_signal_connect (button, "clicked",
G_CALLBACK (launcher_grid_toggle), desktop);
- gtk_box_pack_start (GTK_BOX(box1), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
+
+ gtk_box_pack_start (GTK_BOX (box1), weston_gtk_favorites_new (), FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX(box1), weston_gtk_clock_new (), FALSE, FALSE, 6);
+ box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_pack_end (GTK_BOX (box2), weston_gtk_clock_new (), FALSE, FALSE, 6);
+ gtk_box_pack_end (GTK_BOX (box1), box2, TRUE, TRUE, 0);
gtk_widget_show_all (box1);