Permalink
Browse files

single instance

  • Loading branch information...
1 parent 67c25ad commit e38f90e7bc26a2c83bd0f748f5b621bde74cafeb @aligo committed Oct 3, 2012
Showing with 30 additions and 11 deletions.
  1. +1 −0 README.md
  2. +22 −9 src/main.vala
  3. +7 −2 wscript
View
1 README.md
@@ -22,6 +22,7 @@ Run Requirements
* glib-2.0 >= 2.6
* gtk+-2.0 >= 2.16
* vte >= 0.28
+ * unique-1.0
Installation
-
View
31 src/main.vala
@@ -6,22 +6,35 @@ private class Qiaoke.Appliction {
window.toggle();
}
- public static void main(string[] args) {
+ public static int main(string[] args) {
Gtk.init(ref args);
+ Unique.App app = new Unique.App("org.qiaoke.terminal", null);
+ if (app.is_running) {
+ app.send_message(Unique.Command.ACTIVATE, new Unique.MessageData());
+ } else {
+ app.message_received.connect(message_received_cb);
+ Config.init();
+ Hotkey.init();
+ Tomboy.keybinder_init();
+ Tomboy.keybinder_bind(Config.toggle, toggle_window, null);
+ window = new MainWindow();
+ window.toggle();
- Config.init();
- Hotkey.init();
- Tomboy.keybinder_init();
- Tomboy.keybinder_bind(Config.toggle, toggle_window, null);
- window = new MainWindow();
- window.toggle();
-
- Gtk.main();
+ Gtk.main();
+ }
+ return 0;
}
public static void quit() {
Config.write();
Gtk.main_quit();
}
+ private static Unique.Response message_received_cb(int command, Unique.MessageData message_data, uint time) {
+ if ( (Unique.Command)command == Unique.Command.ACTIVATE ) {
+ window.show();
+ }
+ return Unique.Response.OK;
+ }
+
}
View
9 wscript
@@ -67,6 +67,11 @@ def configure(conf):
atleast_version = '0.28',
args = '--cflags --libs')
+ conf.check_cfg(
+ package = 'unique-1.0',
+ uselib_store = 'UNIQUE',
+ args = '--cflags --libs')
+
CFLAGS.extend(['-I/usr/local/include', '-include', 'config.h'])
VALAFLAGS.extend(['--thread'])
conf.define('VERSION', VERSION)
@@ -87,10 +92,10 @@ def configure(conf):
def build(bld):
bld.program(
- packages = ['vte', 'config', 'posix', 'tomboykeybinder'],
+ packages = ['vte', 'unique-1.0', 'config', 'posix', 'tomboykeybinder'],
vapi_dirs = 'vapi',
target = APPNAME,
- uselib = ['GLIB', 'GOBJECT', 'GTHREAD', 'GTK', 'VTE'],
+ uselib = ['GLIB', 'GOBJECT', 'GTHREAD', 'GTK', 'VTE', 'UNIQUE'],
source = [
'src/main.vala',
'src/main-window.vala',

0 comments on commit e38f90e

Please sign in to comment.