From 3e4c1446edddfbe016a3553100d9e5f79ce44d57 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 25 Jan 2012 03:06:40 +0100 Subject: Modernize things a bit --- .gitignore | 5 +++-- Makefile | 4 ++-- gudev-1.0.vapi | 55 ------------------------------------------------------- udev-browse.vala | 35 +++++++++++++++-------------------- 4 files changed, 20 insertions(+), 79 deletions(-) delete mode 100644 gudev-1.0.vapi diff --git a/.gitignore b/.gitignore index 63e77ac..89a3074 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -udev-browse -*.tar.gz +/udev-browse.c +/udev-browse +/*.tar.gz diff --git a/Makefile b/Makefile index a21bddc..02129e8 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -udev-browse: udev-browse.vala gudev-1.0.vapi - valac --pkg gee-1.0 --pkg gtk+-2.0 --pkg gudev-1.0 --pkg gnu --vapidir=. --Xcc=-D_GNU_SOURCE --Xcc=-DG_UDEV_API_IS_SUBJECT_TO_CHANGE udev-browse.vala +udev-browse: udev-browse.vala + valac --save-temps --pkg gee-1.0 --pkg gtk+-3.0 --pkg gudev-1.0 --pkg gnu --vapidir=. --Xcc=-D_GNU_SOURCE udev-browse.vala clean: rm -f udev-browse udev-browse.c diff --git a/gudev-1.0.vapi b/gudev-1.0.vapi deleted file mode 100644 index 8ecf8b6..0000000 --- a/gudev-1.0.vapi +++ /dev/null @@ -1,55 +0,0 @@ -/*** - This file is part of udev-browse. - - Copyright 2009 Lennart Poettering - - dbus-browse is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - dbus-browse is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with dbus-browse; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -[CCode(cprefix="GUdev", lower_case_cprefix="g_udev_", cheader_filename="gudev/gudev.h")] -namespace Udev { - - public class Device : GLib.Object { - public unowned string get_name(); - public unowned string get_subsystem(); - public unowned string get_sysfs_path(); - public unowned string? get_devtype(); - public unowned string? get_driver(); - public unowned string? get_device_file(); - public unowned string? get_number(); - public unowned Device? get_parent(); - - public unowned string? get_property(string key); - - [CCode (array_length = false, array_null_terminated = true)] - public unowned string[] get_property_keys(); - - [CCode (array_length = false, array_null_terminated = true)] - public unowned string[] get_device_file_symlinks(); - - public uint64 get_seqnum(); - } - - public class Client : GLib.Object { - - public Client([CCode (array_length = false)] string[]? subsystems = null); - - public GLib.List query_by_subsystem(string? subsystem = null); - public Device query_by_sysfs_path(string sysfs_path); - - public signal void uevent(string action, Device d); - } -} diff --git a/udev-browse.vala b/udev-browse.vala index b414e87..fe97f6d 100644 --- a/udev-browse.vala +++ b/udev-browse.vala @@ -19,7 +19,7 @@ USA. ***/ -using Udev; +using GUdev; using Gtk; using GLib; using Pango; @@ -52,7 +52,7 @@ public class RightLabel : Label { } public class MainWindow : Window { - private Udev.Client client; + private GUdev.Client client; private TreeView device_view; private TreeView property_view; @@ -83,7 +83,7 @@ public class MainWindow : Window { string ss[1]; title = "udev-browse"; - position = WindowPosition.CENTER; + set_position(WindowPosition.CENTER); set_default_size(1000, 700); set_border_width(12); @@ -93,7 +93,7 @@ public class MainWindow : Window { seqnums = new HashMap(); ss[0] = null; - client = new Udev.Client(ss); + client = new GUdev.Client(ss); client.uevent.connect(uevent); @@ -111,7 +111,7 @@ public class MainWindow : Window { property_view.insert_column_with_attributes(-1, "Property", new CellRendererText(), "text", 0); property_view.insert_column_with_attributes(-1, "Value", new CellRendererText(), "text", 1); - Paned hpaned = new HPaned(); + Paned hpaned = new Paned(Orientation.HORIZONTAL); add(hpaned); ScrolledWindow scroll = new ScrolledWindow(null, null); @@ -120,7 +120,7 @@ public class MainWindow : Window { scroll.add(device_view); hpaned.pack1(scroll, true, false); - Box vbox = new VBox(false, 6); + Box vbox = new Box(Orientation.VERTICAL, 6); hpaned.pack2(vbox, true, false); Table table = new Table(11, 2, false); @@ -189,7 +189,7 @@ public class MainWindow : Window { else { string psysfs = p.get_sysfs_path(); - if (psysfs in rows) { + if (rows.has_key(psysfs)) { TreeIter pi; device_model.get_iter(out pi, rows[psysfs].get_path()); @@ -209,19 +209,19 @@ public class MainWindow : Window { public void remove_device(Device d) { string sysfs = d.get_sysfs_path(); - if (!(sysfs in rows)) + if (!rows.has_key(sysfs)) return; TreeIter i; device_model.get_iter(out i, rows[sysfs].get_path()); device_model.remove(i); - rows.remove(sysfs); - seqnums.remove(sysfs); + rows.unset(sysfs); + seqnums.unset(sysfs); } public void add_all_devices() { - foreach (Device d in client.query_by_subsystem()) + foreach (Device d in client.query_by_subsystem(null)) add_device(d); device_view.expand_all(); @@ -246,7 +246,7 @@ public class MainWindow : Window { public void set_current_device(Device? d) { string sysfs = d.get_sysfs_path(); - if (sysfs in rows) + if (rows.has_key(sysfs)) device_view.set_cursor(rows[sysfs].get_path(), null, false); } @@ -351,12 +351,12 @@ public class MainWindow : Window { } else { string psysfs = p.get_sysfs_path(); - parent_button.set_sensitive(psysfs in rows); + parent_button.set_sensitive(rows.has_key(psysfs)); parent_button.set_uri(psysfs); parent_sysfs_path_label.set_text_or_na(psysfs); } - if (sysfs in seqnums) + if (seqnums.has_key(sysfs)) seqnum_label.set_text_or_na("%llu".printf(seqnums[sysfs])); else seqnum_label.set_text_or_na(); @@ -384,7 +384,7 @@ public class MainWindow : Window { device_view.expand_all(); } - if (sysfs in rows) { + if (rows.has_key(sysfs)) { seqnums[sysfs] = d.get_seqnum(); if ((action == "change" && follow_change_check_button.get_active()) || @@ -407,13 +407,8 @@ public class MainWindow : Window { } } -void uri_hook(LinkButton button, string uri) { - /* nop */ -} - int main (string[] args) { Gtk.init(ref args); - LinkButton.set_uri_hook(uri_hook); MainWindow window = new MainWindow(); window.set_current_device_by_sysfs_path(args.length > 1 ? args[1] : null); -- cgit