aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-08-11 12:02:16 -0500
committerTed Gould <ted@gould.cx>2011-08-11 12:02:16 -0500
commit8c352cdc40eced52767ddca7036fa7b76bf42a6b (patch)
tree4a628c94c7913385dfcf098c85b63188eedc6200 /example
parentfc03ef7c10bf76edc87af4cc54194fe1bf6e28c2 (diff)
parent1bfe91a779b5d71cf3e6bf066182af38995fa4bf (diff)
downloadlibayatana-appindicator-8c352cdc40eced52767ddca7036fa7b76bf42a6b.tar.gz
libayatana-appindicator-8c352cdc40eced52767ddca7036fa7b76bf42a6b.tar.bz2
libayatana-appindicator-8c352cdc40eced52767ddca7036fa7b76bf42a6b.zip
Import upstream version 0.3.91
Diffstat (limited to 'example')
-rw-r--r--example/simple-client-vala.c199
-rw-r--r--example/simple-client-vala.vala13
-rw-r--r--example/simple-client.c103
3 files changed, 172 insertions, 143 deletions
diff --git a/example/simple-client-vala.c b/example/simple-client-vala.c
index 44dca9e..fa77cb5 100644
--- a/example/simple-client-vala.c
+++ b/example/simple-client-vala.c
@@ -1,4 +1,4 @@
-/* simple-client-vala.c generated by valac 0.11.6, the Vala compiler
+/* simple-client-vala.c generated by valac 0.12.1, the Vala compiler
* generated from simple-client-vala.vala, do not modify */
/*
@@ -117,20 +117,20 @@ static void _lambda1_ (Block1Data* _data1_);
static void __lambda1__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void _lambda2_ (SimpleClient* self);
static void __lambda2__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
+static void _lambda3_ (SimpleClient* self);
+static void __lambda3__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void simple_client_label_toggle (SimpleClient* self, GtkMenuItem* item);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (Block2Data* _data2_);
-static void _lambda3_ (gint delta, guint direction, SimpleClient* self);
-static void __lambda3__app_indicator_scroll_event (AppIndicator* _sender, gint indicator, guint delta, gpointer self);
-static gboolean _lambda4_ (SimpleClient* self);
-static gboolean __lambda4__gsource_func (gpointer self);
-static void _lambda5_ (SimpleClient* self);
-static void __lambda5__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _g_object_unref0_ (gpointer var);
-static void _g_slist_free__g_object_unref0_ (GSList* self);
+static void _lambda4_ (gint delta, guint direction, SimpleClient* self);
+static void __lambda4__app_indicator_scroll_event (AppIndicator* _sender, gint indicator, guint delta, gpointer self);
+static gboolean _lambda5_ (SimpleClient* self);
+static gboolean __lambda5__gsource_func (gpointer self);
static void _lambda6_ (SimpleClient* self);
static void __lambda6__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
-static void _lambda7_ (Block2Data* _data2_);
+static void _g_object_unref0_ (gpointer var);
+static void _g_slist_free__g_object_unref0_ (GSList* self);
+static void _lambda7_ (SimpleClient* self);
static void __lambda7__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void _lambda8_ (Block2Data* _data2_);
static void __lambda8__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
@@ -140,6 +140,8 @@ static void _lambda10_ (Block2Data* _data2_);
static void __lambda10__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void _lambda11_ (Block2Data* _data2_);
static void __lambda11__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
+static void _lambda12_ (Block2Data* _data2_);
+static void __lambda12__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void simple_client_finalize (SimpleClient* obj);
@@ -165,13 +167,11 @@ int main (int argc, char ** argv) {
SimpleClient* simple_client_construct (GType object_type, gchar** args, int args_length1) {
SimpleClient* self = NULL;
AppIndicator* _tmp0_ = NULL;
- AppIndicator* _tmp1_;
self = (SimpleClient*) g_type_create_instance (object_type);
gtk_init (&args_length1, &args);
_tmp0_ = app_indicator_new ("example-simple-client", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
- _tmp1_ = _tmp0_;
_g_object_unref0 (self->priv->ci);
- self->priv->ci = _tmp1_;
+ self->priv->ci = _tmp0_;
app_indicator_set_status (self->priv->ci, APP_INDICATOR_STATUS_ACTIVE);
app_indicator_set_attention_icon (self->priv->ci, "indicator-messages-new");
app_indicator_set_label (self->priv->ci, "1%", "100%");
@@ -247,6 +247,22 @@ static void __lambda2__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer se
}
+static void _lambda3_ (SimpleClient* self) {
+ AppIndicatorStatus _tmp0_;
+ _tmp0_ = app_indicator_get_status (self->priv->ci);
+ if (_tmp0_ == APP_INDICATOR_STATUS_ATTENTION) {
+ app_indicator_set_status (self->priv->ci, APP_INDICATOR_STATUS_ACTIVE);
+ } else {
+ app_indicator_set_status (self->priv->ci, APP_INDICATOR_STATUS_ATTENTION);
+ }
+}
+
+
+static void __lambda3__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda3_ (self);
+}
+
+
static void simple_client_append_submenu (SimpleClient* self, GtkMenuItem* item) {
Block1Data* _data1_;
GtkMenu* _tmp0_ = NULL;
@@ -254,11 +270,9 @@ static void simple_client_append_submenu (SimpleClient* self, GtkMenuItem* item)
GtkMenuItem* mi = NULL;
GtkMenuItem* _tmp1_ = NULL;
GtkMenuItem* _tmp2_;
- GtkMenuItem* _tmp3_;
+ GtkMenuItem* _tmp3_ = NULL;
GtkMenuItem* _tmp4_ = NULL;
- GtkMenuItem* _tmp5_;
- GtkMenuItem* _tmp6_ = NULL;
- GtkMenuItem* _tmp7_;
+ GtkMenuItem* _tmp5_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (item != NULL);
_data1_ = g_slice_new0 (Block1Data);
@@ -267,25 +281,28 @@ static void simple_client_append_submenu (SimpleClient* self, GtkMenuItem* item)
_tmp0_ = (GtkMenu*) gtk_menu_new ();
menu = g_object_ref_sink (_tmp0_);
_tmp1_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Sub 1");
- _tmp2_ = g_object_ref_sink (_tmp1_);
_g_object_unref0 (mi);
- mi = _tmp2_;
+ mi = g_object_ref_sink (_tmp1_);
gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) mi);
g_signal_connect (mi, "activate", (GCallback) __lambda0__gtk_menu_item_activate, self);
- _tmp3_ = _g_object_ref0 (mi);
- _data1_->prev_mi = _tmp3_;
- _tmp4_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Sub 2");
- _tmp5_ = g_object_ref_sink (_tmp4_);
+ _tmp2_ = _g_object_ref0 (mi);
+ _data1_->prev_mi = _tmp2_;
+ _tmp3_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Sub 2");
_g_object_unref0 (mi);
- mi = _tmp5_;
+ mi = g_object_ref_sink (_tmp3_);
gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) mi);
g_signal_connect_data (mi, "activate", (GCallback) __lambda1__gtk_menu_item_activate, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
- _tmp6_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Sub 3");
- _tmp7_ = g_object_ref_sink (_tmp6_);
+ _tmp4_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Sub 3");
_g_object_unref0 (mi);
- mi = _tmp7_;
+ mi = g_object_ref_sink (_tmp4_);
gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) mi);
g_signal_connect (mi, "activate", (GCallback) __lambda2__gtk_menu_item_activate, self);
+ _tmp5_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Toggle Attention");
+ _g_object_unref0 (mi);
+ mi = g_object_ref_sink (_tmp5_);
+ gtk_menu_shell_append ((GtkMenuShell*) menu, (GtkWidget*) mi);
+ g_signal_connect (mi, "activate", (GCallback) __lambda3__gtk_menu_item_activate, self);
+ app_indicator_set_secondary_activate_target (self->priv->ci, (GtkWidget*) mi);
gtk_widget_show_all ((GtkWidget*) menu);
gtk_menu_item_set_submenu (item, (GtkWidget*) menu);
_g_object_unref0 (mi);
@@ -326,7 +343,7 @@ static void block2_data_unref (Block2Data* _data2_) {
}
-static void _lambda3_ (gint delta, guint direction, SimpleClient* self) {
+static void _lambda4_ (gint delta, guint direction, SimpleClient* self) {
gchar* _tmp0_ = NULL;
gchar* _tmp1_;
gchar* _tmp2_ = NULL;
@@ -346,12 +363,12 @@ static void _lambda3_ (gint delta, guint direction, SimpleClient* self) {
}
-static void __lambda3__app_indicator_scroll_event (AppIndicator* _sender, gint indicator, guint delta, gpointer self) {
- _lambda3_ (indicator, delta, self);
+static void __lambda4__app_indicator_scroll_event (AppIndicator* _sender, gint indicator, guint delta, gpointer self) {
+ _lambda4_ (indicator, delta, self);
}
-static gboolean _lambda4_ (SimpleClient* self) {
+static gboolean _lambda5_ (SimpleClient* self) {
gboolean result = FALSE;
self->priv->percentage = (self->priv->percentage + 1) % 100;
if (self->priv->can_haz_label) {
@@ -374,20 +391,20 @@ static gboolean _lambda4_ (SimpleClient* self) {
}
-static gboolean __lambda4__gsource_func (gpointer self) {
+static gboolean __lambda5__gsource_func (gpointer self) {
gboolean result;
- result = _lambda4_ (self);
+ result = _lambda5_ (self);
return result;
}
-static void _lambda5_ (SimpleClient* self) {
+static void _lambda6_ (SimpleClient* self) {
g_print ("1\n");
}
-static void __lambda5__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda5_ (self);
+static void __lambda6__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda6_ (self);
}
@@ -402,29 +419,29 @@ static void _g_slist_free__g_object_unref0_ (GSList* self) {
}
-static void _lambda6_ (SimpleClient* self) {
+static void _lambda7_ (SimpleClient* self) {
g_print ("2\n");
}
-static void __lambda6__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda6_ (self);
+static void __lambda7__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda7_ (self);
}
-static void _lambda7_ (Block2Data* _data2_) {
+static void _lambda8_ (Block2Data* _data2_) {
SimpleClient * self;
self = _data2_->self;
simple_client_toggle_sensitivity (self, (GtkWidget*) _data2_->submenu);
}
-static void __lambda7__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda7_ (self);
+static void __lambda8__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda8_ (self);
}
-static void _lambda8_ (Block2Data* _data2_) {
+static void _lambda9_ (Block2Data* _data2_) {
SimpleClient * self;
GtkWidget* _tmp0_ = NULL;
GtkImage* _tmp1_;
@@ -438,12 +455,12 @@ static void _lambda8_ (Block2Data* _data2_) {
}
-static void __lambda8__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda8_ (self);
+static void __lambda9__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda9_ (self);
}
-static void _lambda9_ (Block2Data* _data2_) {
+static void _lambda10_ (Block2Data* _data2_) {
SimpleClient * self;
self = _data2_->self;
if (self->priv->active) {
@@ -458,24 +475,24 @@ static void _lambda9_ (Block2Data* _data2_) {
}
-static void __lambda9__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda9_ (self);
+static void __lambda10__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda10_ (self);
}
-static void _lambda10_ (Block2Data* _data2_) {
+static void _lambda11_ (Block2Data* _data2_) {
SimpleClient * self;
self = _data2_->self;
simple_client_label_toggle (self, _data2_->show);
}
-static void __lambda10__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda10_ (self);
+static void __lambda11__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda11_ (self);
}
-static void _lambda11_ (Block2Data* _data2_) {
+static void _lambda12_ (Block2Data* _data2_) {
SimpleClient * self;
gboolean _tmp0_;
self = _data2_->self;
@@ -488,78 +505,78 @@ static void _lambda11_ (Block2Data* _data2_) {
}
-static void __lambda11__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
- _lambda11_ (self);
+static void __lambda12__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
+ _lambda12_ (self);
}
void simple_client_run (SimpleClient* self) {
Block2Data* _data2_;
GtkMenu* _tmp0_ = NULL;
- GtkMenu* _tmp1_;
- GtkCheckMenuItem* _tmp2_ = NULL;
+ GtkCheckMenuItem* _tmp1_ = NULL;
GtkCheckMenuItem* chk;
- GSList* _tmp3_;
- GtkRadioMenuItem* _tmp4_ = NULL;
- GtkRadioMenuItem* _tmp5_;
+ GSList* _tmp2_;
+ GtkRadioMenuItem* _tmp3_ = NULL;
+ GtkRadioMenuItem* _tmp4_;
GtkRadioMenuItem* radio;
+ GtkMenuItem* _tmp5_ = NULL;
GtkMenuItem* _tmp6_ = NULL;
- GtkMenuItem* _tmp7_ = NULL;
GtkMenuItem* toggle_item;
- GtkImageMenuItem* _tmp8_ = NULL;
+ GtkImageMenuItem* _tmp7_ = NULL;
+ GtkMenuItem* _tmp8_ = NULL;
GtkMenuItem* _tmp9_ = NULL;
- GtkMenuItem* _tmp10_ = NULL;
- GtkCheckMenuItem* _tmp11_ = NULL;
+ GtkCheckMenuItem* _tmp10_ = NULL;
g_return_if_fail (self != NULL);
_data2_ = g_slice_new0 (Block2Data);
_data2_->_ref_count_ = 1;
_data2_->self = simple_client_ref (self);
- g_signal_connect (self->priv->ci, "scroll-event", (GCallback) __lambda3__app_indicator_scroll_event, self);
- g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, __lambda4__gsource_func, simple_client_ref (self), simple_client_unref);
+ g_signal_connect (self->priv->ci, "scroll-event", (GCallback) __lambda4__app_indicator_scroll_event, self);
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, __lambda5__gsource_func, simple_client_ref (self), simple_client_unref);
_tmp0_ = (GtkMenu*) gtk_menu_new ();
- _tmp1_ = g_object_ref_sink (_tmp0_);
_g_object_unref0 (self->priv->menu);
- self->priv->menu = _tmp1_;
- _tmp2_ = (GtkCheckMenuItem*) gtk_check_menu_item_new_with_label ("1");
- chk = g_object_ref_sink (_tmp2_);
- g_signal_connect ((GtkMenuItem*) chk, "activate", (GCallback) __lambda5__gtk_menu_item_activate, self);
+ self->priv->menu = g_object_ref_sink (_tmp0_);
+ _tmp1_ = (GtkCheckMenuItem*) gtk_check_menu_item_new_with_label ("1");
+ chk = g_object_ref_sink (_tmp1_);
+ g_signal_connect ((GtkMenuItem*) chk, "activate", (GCallback) __lambda6__gtk_menu_item_activate, self);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) chk));
gtk_widget_show ((GtkWidget*) chk);
- _tmp3_ = NULL;
- _tmp4_ = (GtkRadioMenuItem*) gtk_radio_menu_item_new_with_label (_tmp3_, "2");
- radio = (_tmp5_ = g_object_ref_sink (_tmp4_), __g_slist_free__g_object_unref0_0 (_tmp3_), _tmp5_);
- g_signal_connect ((GtkMenuItem*) radio, "activate", (GCallback) __lambda6__gtk_menu_item_activate, self);
+ _tmp2_ = NULL;
+ _tmp3_ = (GtkRadioMenuItem*) gtk_radio_menu_item_new_with_label (_tmp2_, "2");
+ _tmp4_ = g_object_ref_sink (_tmp3_);
+ __g_slist_free__g_object_unref0_0 (_tmp2_);
+ radio = _tmp4_;
+ g_signal_connect ((GtkMenuItem*) radio, "activate", (GCallback) __lambda7__gtk_menu_item_activate, self);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) radio));
gtk_widget_show ((GtkWidget*) radio);
- _tmp6_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("3");
- _data2_->submenu = g_object_ref_sink (_tmp6_);
+ _tmp5_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("3");
+ _data2_->submenu = g_object_ref_sink (_tmp5_);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) _data2_->submenu);
simple_client_append_submenu (self, _data2_->submenu);
gtk_widget_show ((GtkWidget*) _data2_->submenu);
- _tmp7_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Toggle 3");
- toggle_item = g_object_ref_sink (_tmp7_);
- g_signal_connect_data (toggle_item, "activate", (GCallback) __lambda7__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ _tmp6_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Toggle 3");
+ toggle_item = g_object_ref_sink (_tmp6_);
+ g_signal_connect_data (toggle_item, "activate", (GCallback) __lambda8__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) toggle_item);
gtk_widget_show ((GtkWidget*) toggle_item);
- _tmp8_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL);
- _data2_->imgitem = g_object_ref_sink (_tmp8_);
- g_signal_connect_data ((GtkMenuItem*) _data2_->imgitem, "activate", (GCallback) __lambda8__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ _tmp7_ = (GtkImageMenuItem*) gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL);
+ _data2_->imgitem = g_object_ref_sink (_tmp7_);
+ g_signal_connect_data ((GtkMenuItem*) _data2_->imgitem, "activate", (GCallback) __lambda9__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) _data2_->imgitem));
gtk_widget_show ((GtkWidget*) _data2_->imgitem);
- _tmp9_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Get Attention");
- _data2_->att = g_object_ref_sink (_tmp9_);
- g_signal_connect_data (_data2_->att, "activate", (GCallback) __lambda9__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ _tmp8_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Get Attention");
+ _data2_->att = g_object_ref_sink (_tmp8_);
+ g_signal_connect_data (_data2_->att, "activate", (GCallback) __lambda10__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) _data2_->att);
gtk_widget_show ((GtkWidget*) _data2_->att);
- _tmp10_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Show Label");
- _data2_->show = g_object_ref_sink (_tmp10_);
+ _tmp9_ = (GtkMenuItem*) gtk_menu_item_new_with_label ("Show Label");
+ _data2_->show = g_object_ref_sink (_tmp9_);
simple_client_label_toggle (self, _data2_->show);
- g_signal_connect_data (_data2_->show, "activate", (GCallback) __lambda10__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ g_signal_connect_data (_data2_->show, "activate", (GCallback) __lambda11__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) _data2_->show);
gtk_widget_show ((GtkWidget*) _data2_->show);
- _tmp11_ = (GtkCheckMenuItem*) gtk_check_menu_item_new_with_label ("Set Local Icon");
- _data2_->icon = g_object_ref_sink (_tmp11_);
- g_signal_connect_data ((GtkMenuItem*) _data2_->icon, "activate", (GCallback) __lambda11__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ _tmp10_ = (GtkCheckMenuItem*) gtk_check_menu_item_new_with_label ("Set Local Icon");
+ _data2_->icon = g_object_ref_sink (_tmp10_);
+ g_signal_connect_data ((GtkMenuItem*) _data2_->icon, "activate", (GCallback) __lambda12__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
gtk_menu_shell_append ((GtkMenuShell*) self->priv->menu, (GtkWidget*) ((GtkMenuItem*) _data2_->icon));
gtk_widget_show ((GtkWidget*) _data2_->icon);
app_indicator_set_menu (self->priv->ci, self->priv->menu);
diff --git a/example/simple-client-vala.vala b/example/simple-client-vala.vala
index 61e0c2f..8d661ce 100644
--- a/example/simple-client-vala.vala
+++ b/example/simple-client-vala.vala
@@ -72,6 +72,17 @@ class SimpleClient {
menu.append(mi);
mi.activate.connect(() => { print("Sub3\n"); });
+ mi = new MenuItem.with_label("Toggle Attention");
+ menu.append(mi);
+ mi.activate.connect(() => {
+ if (ci.get_status() == IndicatorStatus.ATTENTION)
+ ci.set_status(IndicatorStatus.ACTIVE);
+ else
+ ci.set_status(IndicatorStatus.ATTENTION);
+ });
+
+ ci.set_secondary_activate_target(mi);
+
menu.show_all();
item.set_submenu(menu);
}
@@ -109,7 +120,7 @@ class SimpleClient {
chk.show();
var radio = new RadioMenuItem.with_label(new SList<RadioMenuItem>(), "2");
- radio.activate.connect(() => { print("2\n"); });
+ radio.activate.connect(() => { print("2\n"); });
menu.append(radio);
radio.show();
diff --git a/example/simple-client.c b/example/simple-client.c
index 9e63e14..dcee81b 100644
--- a/example/simple-client.c
+++ b/example/simple-client.c
@@ -31,46 +31,46 @@ static gboolean can_haz_label = TRUE;
static void
label_toggle_cb (GtkWidget * widget, gpointer data)
{
- can_haz_label = !can_haz_label;
+ can_haz_label = !can_haz_label;
- if (can_haz_label) {
- gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label");
- } else {
- gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label");
- }
+ if (can_haz_label) {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Hide label");
+ } else {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Show label");
+ }
- return;
+ return;
}
static void
activate_clicked_cb (GtkWidget *widget, gpointer data)
{
- AppIndicator * ci = APP_INDICATOR(data);
-
- if (active) {
- app_indicator_set_status (ci, APP_INDICATOR_STATUS_ATTENTION);
- gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "I'm okay now");
- active = FALSE;
- } else {
- app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE);
- gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Get Attention");
- active = TRUE;
- }
+ AppIndicator * ci = APP_INDICATOR(data);
+
+ if (active) {
+ app_indicator_set_status (ci, APP_INDICATOR_STATUS_ATTENTION);
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "I'm okay now");
+ active = FALSE;
+ } else {
+ app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE);
+ gtk_menu_item_set_label(GTK_MENU_ITEM(widget), "Get Attention");
+ active = TRUE;
+ }
}
static void
local_icon_toggle_cb (GtkWidget *widget, gpointer data)
{
- AppIndicator * ci = APP_INDICATOR(data);
+ AppIndicator * ci = APP_INDICATOR(data);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- app_indicator_set_icon_full(ci, LOCAL_ICON, "Local Icon");
- } else {
- app_indicator_set_icon_full(ci, "indicator-messages", "System Icon");
- }
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
+ app_indicator_set_icon_full(ci, LOCAL_ICON, "Local Icon");
+ } else {
+ app_indicator_set_icon_full(ci, "indicator-messages", "System Icon");
+ }
- return;
+ return;
}
static void
@@ -98,9 +98,9 @@ image_clicked_cb (GtkWidget *widget, gpointer data)
}
static void
-scroll_event_cb (AppIndicator * ci, gint delta, guint direction)
+scroll_event_cb (AppIndicator * ci, gint delta, guint direction, gpointer data)
{
- g_print("Got scroll event! delta: %d, direction: %d\n", delta, direction);
+ g_print("Got scroll event! delta: %d, direction: %d\n", delta, direction);
}
static void
@@ -138,15 +138,15 @@ guint percentage = 0;
static gboolean
percent_change (gpointer user_data)
{
- percentage = (percentage + 1) % 100;
- if (can_haz_label) {
- gchar * percentstr = g_strdup_printf("%d%%", percentage + 1);
- app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%");
- g_free(percentstr);
- } else {
- app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL);
- }
- return TRUE;
+ percentage = (percentage + 1) % 100;
+ if (can_haz_label) {
+ gchar * percentstr = g_strdup_printf("%d%%", percentage + 1);
+ app_indicator_set_label (APP_INDICATOR(user_data), percentstr, "100%");
+ g_free(percentstr);
+ } else {
+ app_indicator_set_label (APP_INDICATOR(user_data), NULL, NULL);
+ }
+ return TRUE;
}
int
@@ -161,17 +161,17 @@ main (int argc, char ** argv)
"indicator-messages",
APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
- g_assert (IS_APP_INDICATOR (ci));
+ g_assert (IS_APP_INDICATOR (ci));
g_assert (G_IS_OBJECT (ci));
- app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE);
- app_indicator_set_attention_icon_full(ci, "indicator-messages-new", "System Messages Icon Highlighted");
- app_indicator_set_label (ci, "1%", "100%");
+ app_indicator_set_status (ci, APP_INDICATOR_STATUS_ACTIVE);
+ app_indicator_set_attention_icon_full(ci, "indicator-messages-new", "System Messages Icon Highlighted");
+ app_indicator_set_label (ci, "1%", "100%");
- g_signal_connect (ci, "scroll-event",
+ g_signal_connect (ci, "scroll-event",
G_CALLBACK (scroll_event_cb), NULL);
- g_timeout_add_seconds(1, percent_change, ci);
+ g_timeout_add_seconds(1, percent_change, ci);
menu = gtk_menu_new ();
GtkWidget *item = gtk_check_menu_item_new_with_label ("1");
@@ -195,37 +195,38 @@ main (int argc, char ** argv)
g_signal_connect (toggle_item, "activate",
G_CALLBACK (toggle_sensitivity_cb), item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), toggle_item);
- gtk_widget_show(toggle_item);
+ gtk_widget_show(toggle_item);
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL);
g_signal_connect (item, "activate",
G_CALLBACK (image_clicked_cb), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show(item);
+ gtk_widget_show(item);
item = gtk_menu_item_new_with_label ("Get Attention");
g_signal_connect (item, "activate",
G_CALLBACK (activate_clicked_cb), ci);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show(item);
+ gtk_widget_show(item);
+ app_indicator_set_secondary_activate_target(ci, item);
item = gtk_menu_item_new_with_label ("Show label");
- label_toggle_cb(item, ci);
+ label_toggle_cb(item, ci);
g_signal_connect (item, "activate",
G_CALLBACK (label_toggle_cb), ci);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show(item);
+ gtk_widget_show(item);
item = gtk_check_menu_item_new_with_label ("Set Local Icon");
g_signal_connect (item, "activate",
G_CALLBACK (local_icon_toggle_cb), ci);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show(item);
+ gtk_widget_show(item);
app_indicator_set_menu (ci, GTK_MENU (menu));
- mainloop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(mainloop);
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
- return 0;
+ return 0;
}