From 28d217863f9c72d0ca3f1e16fe7f7da058b43346 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 13 Jul 2022 23:32:15 +0200 Subject: Whitespace fix --- example/simple-client-vala.vala | 306 ++++++++++++++++++++-------------------- 1 file changed, 153 insertions(+), 153 deletions(-) (limited to 'example/simple-client-vala.vala') diff --git a/example/simple-client-vala.vala b/example/simple-client-vala.vala index c30bf34..510056a 100644 --- a/example/simple-client-vala.vala +++ b/example/simple-client-vala.vala @@ -7,16 +7,16 @@ Copyright 2011 Canonical Ltd. Authors: Marco Trevisan -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 +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 +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 +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -24,159 +24,159 @@ using Gtk; using AppIndicator; static int main(string[] args) { - var sc = new SimpleClient(args); - sc.run(); - return 0; + var sc = new SimpleClient(args); + sc.run(); + return 0; } class SimpleClient { - Gtk.Menu menu; - Indicator ci; - int percentage; - bool active; - bool can_haz_label; + Gtk.Menu menu; + Indicator ci; + int percentage; + bool active; + bool can_haz_label; - public SimpleClient(string[] args) { - Gtk.init(ref args); + public SimpleClient(string[] args) { + Gtk.init(ref args); - ci = new Indicator("example-simple-client", + 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%"); - ci.set_title("Test Indicator (vala)"); - - active = true; - can_haz_label = true; - } - - private void toggle_sensitivity(Widget widget) { - widget.set_sensitive(!widget.is_sensitive()); - } - - private void append_submenu(Gtk.MenuItem item) { - var menu = new Gtk.Menu(); - Gtk.MenuItem mi; - - mi = new Gtk.MenuItem.with_label("Sub 1"); - menu.append(mi); - mi.activate.connect(() => { print("Sub1\n"); }); - - Gtk.MenuItem prev_mi = mi; - mi = new Gtk.MenuItem.with_label("Sub 2"); - menu.append(mi); - mi.activate.connect(() => { toggle_sensitivity(prev_mi); }); - - mi = new Gtk.MenuItem.with_label("Sub 3"); - menu.append(mi); - mi.activate.connect(() => { print("Sub3\n"); }); - - mi = new Gtk.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); - } - - private void label_toggle(Gtk.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"); - }); - - GLib.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 Gtk.Menu(); - var chk = new CheckMenuItem.with_label("1"); - chk.activate.connect(() => { print("1\n"); }); - menu.append(chk); - chk.show(); - - var radio = new Gtk.RadioMenuItem.with_label(new SList(), "2"); - radio.activate.connect(() => { print("2\n"); }); - menu.append(radio); - radio.show(); - - var submenu = new Gtk.MenuItem.with_label("3"); - menu.append(submenu); - append_submenu(submenu); - submenu.show(); - - var toggle_item = new Gtk.MenuItem.with_label("Toggle 3"); - toggle_item.activate.connect(() => { toggle_sensitivity(submenu); }); - menu.append(toggle_item); - toggle_item.show(); - - var imgitem = new Gtk.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 Gtk.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 Gtk.MenuItem.with_label("Show Label"); - label_toggle(show); - show.activate.connect(() => { label_toggle(show); }); - menu.append(show); - show.show(); - - var icon = new Gtk.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(); - } + ci.set_status(IndicatorStatus.ACTIVE); + ci.set_attention_icon("indicator-messages-new"); + ci.set_label("1%", "100%"); + ci.set_title("Test Indicator (vala)"); + + active = true; + can_haz_label = true; + } + + private void toggle_sensitivity(Widget widget) { + widget.set_sensitive(!widget.is_sensitive()); + } + + private void append_submenu(Gtk.MenuItem item) { + var menu = new Gtk.Menu(); + Gtk.MenuItem mi; + + mi = new Gtk.MenuItem.with_label("Sub 1"); + menu.append(mi); + mi.activate.connect(() => { print("Sub1\n"); }); + + Gtk.MenuItem prev_mi = mi; + mi = new Gtk.MenuItem.with_label("Sub 2"); + menu.append(mi); + mi.activate.connect(() => { toggle_sensitivity(prev_mi); }); + + mi = new Gtk.MenuItem.with_label("Sub 3"); + menu.append(mi); + mi.activate.connect(() => { print("Sub3\n"); }); + + mi = new Gtk.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); + } + + private void label_toggle(Gtk.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"); + }); + + GLib.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 Gtk.Menu(); + var chk = new CheckMenuItem.with_label("1"); + chk.activate.connect(() => { print("1\n"); }); + menu.append(chk); + chk.show(); + + var radio = new Gtk.RadioMenuItem.with_label(new SList(), "2"); + radio.activate.connect(() => { print("2\n"); }); + menu.append(radio); + radio.show(); + + var submenu = new Gtk.MenuItem.with_label("3"); + menu.append(submenu); + append_submenu(submenu); + submenu.show(); + + var toggle_item = new Gtk.MenuItem.with_label("Toggle 3"); + toggle_item.activate.connect(() => { toggle_sensitivity(submenu); }); + menu.append(toggle_item); + toggle_item.show(); + + var imgitem = new Gtk.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 Gtk.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 Gtk.MenuItem.with_label("Show Label"); + label_toggle(show); + show.activate.connect(() => { label_toggle(show); }); + menu.append(show); + show.show(); + + var icon = new Gtk.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(); + } } -- cgit v1.2.3 From 44a82a050cf69f8b04429f1f7e06d3ad7bf58ca7 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Thu, 14 Jul 2022 23:38:23 +0200 Subject: Fix remaining deprecation warnings --- .../vala/examples/ayatana-indicator-example.vala | 4 ++- docs/reference/scangobj.sh.in | 2 +- example/simple-client-vala.vala | 21 ++++++++++----- example/simple-client.c | 30 +++++++++++++++++++--- src/application-service-marshal.list | 26 ++++++++++--------- 5 files changed, 59 insertions(+), 24 deletions(-) (limited to 'example/simple-client-vala.vala') diff --git a/bindings/vala/examples/ayatana-indicator-example.vala b/bindings/vala/examples/ayatana-indicator-example.vala index 4804314..55535ab 100644 --- a/bindings/vala/examples/ayatana-indicator-example.vala +++ b/bindings/vala/examples/ayatana-indicator-example.vala @@ -1,5 +1,6 @@ /* * Copyright 2011 Canonical Ltd. + * Copyright 2022 Robert Tari * * 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 @@ -15,6 +16,7 @@ * * Authors: * Marco Trevisan (TreviƱo) + * Robert Tari */ using Gtk; @@ -37,7 +39,7 @@ public class IndicatorExample { if (!(indicator is Indicator)) return -1; indicator.set_status(IndicatorStatus.ACTIVE); - indicator.set_attention_icon("indicator-messages-new"); + indicator.set_attention_icon_full("indicator-messages-new", null); var menu = new Gtk.Menu(); diff --git a/docs/reference/scangobj.sh.in b/docs/reference/scangobj.sh.in index 8cb2500..1863f61 100644 --- a/docs/reference/scangobj.sh.in +++ b/docs/reference/scangobj.sh.in @@ -1 +1 @@ -LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${CMAKE_BINARY_DIR}/src" CFLAGS="-I${GTKDOC_SCANGOBJ_INCLUDE_DIRS}" LDFLAGS="-l${GTKDOC_SCANGOBJ_LIBRARIES} -L${CMAKE_BINARY_DIR}/src -l${SCANGOBJ_AYATANA_APPINDICATOR}" gtkdoc-scangobj --type-init-func="g_type_init()" --module=libayatana-appindicator > /dev/null +LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${CMAKE_BINARY_DIR}/src" CFLAGS="-I${GTKDOC_SCANGOBJ_INCLUDE_DIRS}" LDFLAGS="-l${GTKDOC_SCANGOBJ_LIBRARIES} -L${CMAKE_BINARY_DIR}/src -l${SCANGOBJ_AYATANA_APPINDICATOR}" gtkdoc-scangobj --module=libayatana-appindicator > /dev/null diff --git a/example/simple-client-vala.vala b/example/simple-client-vala.vala index 510056a..5b3af11 100644 --- a/example/simple-client-vala.vala +++ b/example/simple-client-vala.vala @@ -3,9 +3,11 @@ A small piece of sample code demonstrating a very simple application with an indicator. Copyright 2011 Canonical Ltd. +Copyright 2022 Robert Tari Authors: Marco Trevisan + Robert Tari 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 @@ -44,7 +46,7 @@ class SimpleClient { IndicatorCategory.APPLICATION_STATUS); ci.set_status(IndicatorStatus.ACTIVE); - ci.set_attention_icon("indicator-messages-new"); + ci.set_attention_icon_full("indicator-messages-new", null); ci.set_label("1%", "100%"); ci.set_title("Test Indicator (vala)"); @@ -135,10 +137,17 @@ class SimpleClient { menu.append(toggle_item); toggle_item.show(); - var imgitem = new Gtk.ImageMenuItem.from_stock(Stock.NEW, null); + var pImage = new Gtk.Image.from_icon_name("document-new", IconSize.MENU); + var pLabel = new Gtk.Label("New"); + var pGrid = new Gtk.Grid(); + pGrid.add(pImage); + pGrid.add(pLabel); + var imgitem = new Gtk.MenuItem(); + imgitem.add(pGrid); imgitem.activate.connect(() => { - Image img = (Image) imgitem.get_image(); - img.set_from_stock(Stock.OPEN, IconSize.MENU); + Grid pGridLocal = (Grid)imgitem.get_children().nth_data(0); + Image img = (Image) pGridLocal.get_children().nth_data(1); + img.set_from_icon_name("document-open", IconSize.MENU); }); menu.append(imgitem); imgitem.show(); @@ -167,9 +176,9 @@ class SimpleClient { var icon = new Gtk.CheckMenuItem.with_label("Set Local Icon"); icon.activate.connect(() => { if (icon.get_active()) { - ci.set_icon("simple-client-test-icon.png"); + ci.set_icon_full("simple-client-test-icon.png", null); } else { - ci.set_icon("indicator-messages"); + ci.set_icon_full("indicator-messages", null); } }); menu.append(icon); diff --git a/example/simple-client.c b/example/simple-client.c index fbea377..9155257 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -3,9 +3,11 @@ A small piece of sample code demonstrating a very simple application with an indicator. Copyright 2009 Canonical Ltd. +Copyright 2022 Robert Tari Authors: Ted Gould + Robert Tari 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 @@ -92,9 +94,15 @@ toggle_sensitivity_cb (GtkWidget *widget, gpointer data) static void image_clicked_cb (GtkWidget *widget, gpointer data) { - gtk_image_set_from_stock (GTK_IMAGE (gtk_image_menu_item_get_image ( - GTK_IMAGE_MENU_ITEM (widget))), - GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU); + GList *pList = gtk_container_get_children(GTK_CONTAINER(widget)); + GtkContainer *pContainer = GTK_CONTAINER(g_list_nth_data(pList, 0)); + pList = gtk_container_get_children(pContainer); +#if GTK_MAJOR_VERSION >= 3 + GtkImage *pImage = GTK_IMAGE(g_list_nth_data(pList, 1)); +#else + GtkImage *pImage = GTK_IMAGE(g_list_nth_data(pList, 0)); +#endif + gtk_image_set_from_icon_name(pImage, "document-open", GTK_ICON_SIZE_MENU); } static void @@ -198,7 +206,21 @@ main (int argc, char ** argv) gtk_menu_shell_append (GTK_MENU_SHELL (menu), toggle_item); gtk_widget_show(toggle_item); - item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL); + GtkWidget *pImage = gtk_image_new_from_icon_name("document-new", GTK_ICON_SIZE_MENU); + GtkWidget *pLabel = gtk_label_new("New"); +#if GTK_MAJOR_VERSION >= 3 + GtkWidget *pGrid = gtk_grid_new(); + gtk_container_add(GTK_CONTAINER(pGrid), pImage); + gtk_container_add(GTK_CONTAINER(pGrid), pLabel); + item = gtk_menu_item_new(); + gtk_container_add(GTK_CONTAINER(item), pGrid); +#else + GtkWidget *pBox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(pBox), pImage, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(pBox), pLabel, FALSE, FALSE, 0); + item = gtk_menu_item_new(); + gtk_container_add(GTK_CONTAINER(item), pBox); +#endif g_signal_connect (item, "activate", G_CALLBACK (image_clicked_cb), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 7b62a21..b6dc87a 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -1,25 +1,27 @@ # Marshaller definitions to be generated. -# +# # Copyright 2009 Canonical Ltd. -# +# Copyright 2022 Robert Tari +# # Authors: # Ted Gould -# -# 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 +# Robert Tari +# +# 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 +# +# 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 +# +# You should have received a copy of the GNU General Public License along # with this program. If not, see . VOID: STRING, INT, STRING, STRING, STRING, STRING, STRING VOID: INT, STRING, STRING VOID: INT, STRING VOID: STRING, STRING -VOID: BOOL, STRING, OBJECT +VOID: BOOLEAN, STRING, OBJECT VOID: INT, UINT VOID: INT, INT -- cgit v1.2.3