aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Yelavich <luke.yelavich@canonical.com>2011-02-11 07:47:26 +1100
committerLuke Yelavich <luke.yelavich@canonical.com>2011-02-11 07:47:26 +1100
commitb63c137778bbec1fb010f095e08750817744fced (patch)
tree960f8b383fdc012dcaeb689c58484f1009eae1ec
parentfffab2e1e8d991a41cc591ceaca77c8a40f31f33 (diff)
parent409fc00a5a2f60dad3c1adb62d82c896cdfb2a2a (diff)
downloadlibayatana-appindicator-b63c137778bbec1fb010f095e08750817744fced.tar.gz
libayatana-appindicator-b63c137778bbec1fb010f095e08750817744fced.tar.bz2
libayatana-appindicator-b63c137778bbec1fb010f095e08750817744fced.zip
Merge from trunk
-rw-r--r--.bzrignore7
-rw-r--r--bindings/Makefile.am7
-rw-r--r--bindings/vala/Makefile.am36
-rw-r--r--bindings/vala/examples/Makefile.am13
-rw-r--r--bindings/vala/examples/indicator-example.vala64
-rw-r--r--configure.ac10
-rw-r--r--example/Makefile.am29
-rw-r--r--example/simple-client-vala.vala170
-rw-r--r--example/simple-client.c9
-rw-r--r--src/AppIndicator-0.1.metadata1
-rw-r--r--src/AppIndicator-0.1.metadata.in3
-rw-r--r--src/AppIndicator3-0.1.metadata.in3
-rw-r--r--src/Makefile.am37
-rw-r--r--src/app-indicator.c2
-rw-r--r--src/app-indicator.h2
15 files changed, 362 insertions, 31 deletions
diff --git a/.bzrignore b/.bzrignore
index e120c11..56f006e 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -129,3 +129,10 @@ src/gen-notification-watcher.xml.c
src/gen-notification-watcher.xml.h
src/libappindicator_la-gen-notification-item.xml.lo
src/libappindicator_la-gen-notification-watcher.xml.lo
+bindings/vala/appindicator-0.1.deps
+bindings/vala/appindicator-0.1.vapi
+bindings/vala/examples/indicator-example
+bindings/vala/examples/indicator-example.c
+example/simple-client-vala
+example/simple-client-vala.c
+src/AppIndicator-0.1.metadata
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
index f74dec5..8e621e4 100644
--- a/bindings/Makefile.am
+++ b/bindings/Makefile.am
@@ -1,7 +1,10 @@
if USE_GTK3
-SUBDIRS = mono
+SUBDIRS = \
+ mono \
+ vala
else
SUBDIRS = \
mono \
- python
+ python \
+ vala
endif
diff --git a/bindings/vala/Makefile.am b/bindings/vala/Makefile.am
new file mode 100644
index 0000000..f80b48c
--- /dev/null
+++ b/bindings/vala/Makefile.am
@@ -0,0 +1,36 @@
+if HAVE_INTROSPECTION
+if HAVE_VAPIGEN
+
+SUBDIRS = . examples
+
+#########################
+# VAPI Files
+#########################
+
+if USE_GTK3
+GTKVAPI = gtk+-3.0
+VER=3
+else
+GTKVAPI = gtk+-2.0
+VER=
+endif
+
+vapidir = $(datadir)/vala/vapi
+vapiprefix = appindicator$(VER)-0.1
+vapi_DATA = $(vapiprefix).vapi $(vapiprefix).deps
+DEPS = $(GTKVAPI)
+
+$(vapiprefix).deps:
+ echo $(DEPS) > $@
+
+$(vapiprefix).vapi: $(top_builddir)/src/AppIndicator$(VER)-0.1.gir \
+ $(top_builddir)/src/AppIndicator$(VER)-0.1.metadata \
+ $(vapiprefix).deps
+ $(VALA_API_GEN) --library=$(vapiprefix) --girdir=$(srcdir)/src \
+ $<
+
+
+CLEANFILES = $(vapi_DATA)
+
+endif
+endif
diff --git a/bindings/vala/examples/Makefile.am b/bindings/vala/examples/Makefile.am
new file mode 100644
index 0000000..32a695b
--- /dev/null
+++ b/bindings/vala/examples/Makefile.am
@@ -0,0 +1,13 @@
+
+VALAFILES = indicator-example.vala
+CLEANFILES = $(TESTS) *.c
+EXTRA_DIST = $(VALAFILES)
+
+VALAFLAGS = --pkg appindicator-0.1 --vapidir=$(top_builddir)/bindings/vala --save-temps
+
+if HAVE_VALAC
+indicator-example: $(VALAFILES) Makefile.am
+ $(VALAC) $(VALAFLAGS) $(srcdir)/$(VALAFILES)
+
+check: indicator-example
+endif
diff --git a/bindings/vala/examples/indicator-example.vala b/bindings/vala/examples/indicator-example.vala
new file mode 100644
index 0000000..621c962
--- /dev/null
+++ b/bindings/vala/examples/indicator-example.vala
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, 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:
+ * Marco Trevisan (TreviƱo) <mail@3v1n0.net>
+ */
+
+using Gtk;
+using AppIndicator;
+
+public class IndicatorExample {
+ public static int main(string[] args) {
+ Gtk.init(ref args);
+
+ var win = new Window();
+ win.title = "Indicator Test";
+ win.resize(200, 200);
+ win.destroy.connect(Gtk.main_quit);
+
+ var label = new Label("Hello, world!");
+ win.add(label);
+
+ var indicator = new Indicator(win.title, "indicator-messages",
+ IndicatorCategory.APPLICATION_STATUS);
+
+ indicator.set_status(IndicatorStatus.ACTIVE);
+ indicator.set_attention_icon("indicator-messages-new");
+
+ var menu = new Menu();
+
+ var item = new MenuItem.with_label("Foo");
+ item.activate.connect(() => {
+ indicator.set_status(IndicatorStatus.ATTENTION);
+ });
+ item.show();
+ menu.append(item);
+
+ item = new MenuItem.with_label("Bar");
+ item.show();
+ item.activate.connect(() => {
+ indicator.set_status(IndicatorStatus.ATTENTION);
+ });
+ menu.append(item);
+
+ indicator.set_menu(menu);
+
+ win.show_all();
+
+ Gtk.main();
+ return 0;
+ }
+}
diff --git a/configure.ac b/configure.ac
index 6f78786..758914b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,6 +94,14 @@ AM_CONDITIONAL(INTROSPECTION_TEN, [test "x$introspection_ten" = "xyes"])
###########################
AC_PATH_PROG([VALA_API_GEN], [vapigen])
+AM_CONDITIONAL(HAVE_VAPIGEN, [test "x$VALA_API_GEN" != "x"])
+
+###########################
+# Vala Compiler support
+###########################
+
+AM_PROG_VALAC([0.11.0])
+AM_CONDITIONAL(HAVE_VALAC, [test "x$VALAC" != "x"])
###########################
# Check for Mono support
@@ -205,6 +213,8 @@ bindings/mono/appindicator-sharp-0.1.pc
bindings/mono/examples/Makefile
bindings/mono/examples/indicator-example
bindings/python/Makefile
+bindings/vala/Makefile
+bindings/vala/examples/Makefile
tests/Makefile
example/Makefile
docs/Makefile
diff --git a/example/Makefile.am b/example/Makefile.am
index 0900baf..606317c 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -4,9 +4,11 @@ else
VER=
endif
+CLEANFILES =
check_PROGRAMS = \
- simple-client
+ simple-client \
+ simple-client-vala
#########################################
## simple-client
@@ -27,3 +29,28 @@ simple_client_LDADD = \
EXTRA_DIST = \
simple-client-test-icon.png
+
+#########################################
+## simple-client-vala
+#########################################
+if HAVE_VALAC
+
+VALAFLAGS = \
+ --pkg appindicator$(VER)-0.1 \
+ --vapidir=$(top_builddir)/bindings/vala
+
+BUILT_SOURCES = simple-client-vala.c
+simple-client-vala.c: $(srcdir)/simple-client-vala.vala
+ $(VALAC) $(VALAFLAGS) -C $< -o $@
+ $(SED) -i "s|#include\s*<\s*libappindicator/app-indicator.h\s*>||g" $@
+
+simple_client_vala_SOURCES = simple-client-vala.c
+simple_client_vala_CFLAGS = \
+ $(simple_client_CFLAGS) \
+ -include $(top_srcdir)/src/app-indicator.h
+
+simple_client_vala_LDADD = $(simple_client_LDADD)
+
+CLEANFILES += *.stamp *-vala.c
+
+endif
diff --git a/example/simple-client-vala.vala b/example/simple-client-vala.vala
new file mode 100644
index 0000000..61e0c2f
--- /dev/null
+++ b/example/simple-client-vala.vala
@@ -0,0 +1,170 @@
+/*
+A small piece of sample code demonstrating a very simple application
+with an indicator.
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Marco Trevisan <mail@3v1n0.net>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, 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/>.
+*/
+
+using Gtk;
+using AppIndicator;
+
+static int main(string[] args) {
+ var sc = new SimpleClient(args);
+ sc.run();
+ return 0;
+}
+
+class SimpleClient {
+ Menu menu;
+ Indicator ci;
+ int percentage;
+ bool active;
+ bool can_haz_label;
+
+ public SimpleClient(string[] args) {
+ Gtk.init(ref args);
+
+ ci = new Indicator("example-simple-client",
+ "indicator-messages",
+ IndicatorCategory.APPLICATION_STATUS);
+
+ ci.set_status(IndicatorStatus.ACTIVE);
+ ci.set_attention_icon("indicator-messages-new");
+ ci.set_label("1%", "100%");
+
+ active = true;
+ can_haz_label = true;
+ }
+
+ private void toggle_sensitivity(Widget widget) {
+ widget.set_sensitive(!widget.is_sensitive());
+ }
+
+ private void append_submenu(MenuItem item) {
+ var menu = new Menu();
+ MenuItem mi;
+
+ mi = new MenuItem.with_label("Sub 1");
+ menu.append(mi);
+ mi.activate.connect(() => { print("Sub1\n"); });
+
+ MenuItem prev_mi = mi;
+ mi = new MenuItem.with_label("Sub 2");
+ menu.append(mi);
+ mi.activate.connect(() => { toggle_sensitivity(prev_mi); });
+
+ mi = new MenuItem.with_label("Sub 3");
+ menu.append(mi);
+ mi.activate.connect(() => { print("Sub3\n"); });
+
+ menu.show_all();
+ item.set_submenu(menu);
+ }
+
+ private void label_toggle(MenuItem item) {
+ can_haz_label = !can_haz_label;
+
+ if (can_haz_label) {
+ item.set_label("Hide label");
+ } else {
+ item.set_label("Show label");
+ }
+ }
+
+ public void run() {
+
+ ci.scroll_event.connect((delta, direction) => {
+ print(@"Got scroll event! delta: $delta, direction: $direction\n");
+ });
+
+ Timeout.add_seconds(1, () => {
+ percentage = (percentage + 1) % 100;
+ if (can_haz_label) {
+ ci.set_label(@"$(percentage+1)%", "");
+ } else {
+ ci.set_label("", "");
+ }
+ return true;
+ });
+
+ menu = new Menu();
+ var chk = new CheckMenuItem.with_label("1");
+ chk.activate.connect(() => { print("1\n"); });
+ menu.append(chk);
+ chk.show();
+
+ var radio = new RadioMenuItem.with_label(new SList<RadioMenuItem>(), "2");
+ radio.activate.connect(() => { print("2\n"); });
+ menu.append(radio);
+ radio.show();
+
+ var submenu = new MenuItem.with_label("3");
+ menu.append(submenu);
+ append_submenu(submenu);
+ submenu.show();
+
+ var toggle_item = new MenuItem.with_label("Toggle 3");
+ toggle_item.activate.connect(() => { toggle_sensitivity(submenu); });
+ menu.append(toggle_item);
+ toggle_item.show();
+
+ var imgitem = new ImageMenuItem.from_stock(Stock.NEW, null);
+ imgitem.activate.connect(() => {
+ Image img = (Image) imgitem.get_image();
+ img.set_from_stock(Stock.OPEN, IconSize.MENU);
+ });
+ menu.append(imgitem);
+ imgitem.show();
+
+ var att = new MenuItem.with_label("Get Attention");
+ att.activate.connect(() => {
+ if (active) {
+ ci.set_status(IndicatorStatus.ATTENTION);
+ att.set_label("I'm okay now");
+ active = false;
+ } else {
+ ci.set_status(IndicatorStatus.ACTIVE);
+ att.set_label("Get Attention");
+ active = false;
+ }
+ });
+ menu.append(att);
+ att.show();
+
+ var show = new MenuItem.with_label("Show Label");
+ label_toggle(show);
+ show.activate.connect(() => { label_toggle(show); });
+ menu.append(show);
+ show.show();
+
+ var icon = new CheckMenuItem.with_label("Set Local Icon");
+ icon.activate.connect(() => {
+ if (icon.get_active()) {
+ ci.set_icon("simple-client-test-icon.png");
+ } else {
+ ci.set_icon("indicator-messages");
+ }
+ });
+ menu.append(icon);
+ icon.show();
+
+ ci.set_menu(menu);
+
+ Gtk.main();
+ }
+}
diff --git a/example/simple-client.c b/example/simple-client.c
index d5c9ad8..5d464ac 100644
--- a/example/simple-client.c
+++ b/example/simple-client.c
@@ -113,6 +113,12 @@ image_clicked_cb (GtkWidget *widget, gpointer data)
}
static void
+scroll_event_cb (AppIndicator * ci, gint delta, guint direction)
+{
+ g_print("Got scroll event! delta: %d, direction: %d\n", delta, direction);
+}
+
+static void
append_submenu (GtkWidget *item)
{
GtkWidget *menu;
@@ -184,6 +190,9 @@ main (int argc, char ** argv)
app_indicator_set_attention_icon(ci, "indicator-messages-new");
app_indicator_set_label (ci, "1%", "100%");
+ g_signal_connect (ci, "scroll-event",
+ G_CALLBACK (scroll_event_cb), NULL);
+
g_timeout_add_seconds(1, percent_change, ci);
menu = gtk_menu_new ();
diff --git a/src/AppIndicator-0.1.metadata b/src/AppIndicator-0.1.metadata
deleted file mode 100644
index e4d068e..0000000
--- a/src/AppIndicator-0.1.metadata
+++ /dev/null
@@ -1 +0,0 @@
-AppIndicator name="AppIndicator"
diff --git a/src/AppIndicator-0.1.metadata.in b/src/AppIndicator-0.1.metadata.in
new file mode 100644
index 0000000..5790ddb
--- /dev/null
+++ b/src/AppIndicator-0.1.metadata.in
@@ -0,0 +1,3 @@
+AppIndicator name="AppIndicator"
+Indicator.priv hidden="1"
+IndicatorPrivate hidden="1"
diff --git a/src/AppIndicator3-0.1.metadata.in b/src/AppIndicator3-0.1.metadata.in
new file mode 100644
index 0000000..5790ddb
--- /dev/null
+++ b/src/AppIndicator3-0.1.metadata.in
@@ -0,0 +1,3 @@
+AppIndicator name="AppIndicator"
+Indicator.priv hidden="1"
+IndicatorPrivate hidden="1"
diff --git a/src/Makefile.am b/src/Makefile.am
index b9ee3e1..f83a6c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,12 +2,10 @@ if USE_GTK3
VER=3
lib_LTLIBRARIES = libappindicator3.la
GTKGIR = Gtk-3.0
-GTKVAPI = gtk+-3.0
else
VER=
lib_LTLIBRARIES = libappindicator.la
GTKGIR = Gtk-2.0
-GTKVAPI = gtk+-2.0
endif
CLEANFILES =
@@ -16,7 +14,7 @@ BUILT_SOURCES =
EXTRA_DIST = \
appindicator-0.1.pc.in \
appindicator3-0.1.pc.in \
- AppIndicator-0.1.metadata
+ AppIndicator$(VER)-0.1.metadata.in
include $(top_srcdir)/Makefile.am.enum
include $(top_srcdir)/Makefile.am.marshal
@@ -45,7 +43,8 @@ glib_enum_headers = $(addprefix $(srcdir)/, $(libappindicator_headers))
DISTCLEANFILES += app-indicator-enum-types.c
-libappindicatorincludedir=$(includedir)/libappindicator-0.1/libappindicator
+libappindicatorincludefolder=libappindicator
+libappindicatorincludedir=$(includedir)/libappindicator-0.1/$(libappindicatorincludefolder)
libappindicator_headers = \
app-indicator.h
@@ -133,13 +132,13 @@ INTROSPECTION_GIRS =
if INTROSPECTION_TEN
INTROSPECTION_SCANNER_ARGS = \
--add-include-path=$(srcdir) \
- $(addprefix --c-include=src/, $(introspection_sources)) \
+ $(addprefix --c-include=$(libappindicatorincludefolder)/, $(libappindicator_headers)) \
--symbol-prefix=app \
--identifier-prefix=App
else
INTROSPECTION_SCANNER_ARGS = \
--add-include-path=$(srcdir) \
- $(addprefix --c-include=src/, $(introspection_sources))
+ $(addprefix --c-include=$(libappindicatorincludefolder)/, $(libappindicator_headers))
endif
INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir)
@@ -165,6 +164,12 @@ AppIndicator3_0_1_gir_FILES = $(AppIndicator_0_1_gir_FILES)
INTROSPECTION_GIRS += AppIndicator$(VER)-0.1.gir
+AppIndicator$(VER)-0.1.metadata: AppIndicator$(VER)-0.1.gir
+ cp -f $(srcdir)/$@.in $@
+
+BUILT_SOURCES += AppIndicator$(VER)-0.1.metadata
+CLEANFILES += AppIndicator$(VER)-0.1.metadata
+
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
@@ -174,23 +179,3 @@ typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelib_DATA)
endif
-
-#########################
-# VAPI Files
-#########################
-
-if HAVE_INTROSPECTION
-
-vapidir = $(datadir)/vala/vapi
-vapi_DATA = AppIndicator$(VER)-0.1.vapi
-
-AppIndicator$(VER)-0.1.vapi: AppIndicator$(VER)-0.1.gir Makefile.am
- $(VALA_API_GEN) --library=AppIndicator$(VER)-0.1 \
- --pkg $(GTKVAPI) \
- --vapidir=$(top_builddir)/src \
- $<
-
-CLEANFILES += $(vapi_DATA)
-
-endif
-
diff --git a/src/app-indicator.c b/src/app-indicator.c
index a5045e3..c3da8ed 100644
--- a/src/app-indicator.c
+++ b/src/app-indicator.c
@@ -513,6 +513,8 @@ app_indicator_class_init (AppIndicatorClass *klass)
/**
AppIndicator::scroll-event:
@arg0: The #AppIndicator object
+ @arg1: How many steps the scroll wheel has taken
+ @arg2: (type Gdk.ScrollDirection) Which direction the wheel went in
Signaled when there is a new icon set for the
object.
diff --git a/src/app-indicator.h b/src/app-indicator.h
index 0807eee..0e693bd 100644
--- a/src/app-indicator.h
+++ b/src/app-indicator.h
@@ -222,7 +222,7 @@ struct _AppIndicatorClass {
void (* scroll_event) (AppIndicator * indicator,
gint delta,
- guint direction,
+ GdkScrollDirection direction,
gpointer user_data);
void (*app_indicator_reserved_ats)(void);