ruby-libappindicator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ Rakefile
3
+ ext/libappindicator/extconf.rb
4
+ ext/libappindicator/libappindicator.c
5
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Ruby-libappindicator
2
+
3
+ Ruby bindings for libappindicator
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('ruby-libappindicator', '0.1.0') do |p|
6
+ p.summary = "Ruby bindings for libappindicator"
7
+ p.url = "http://github.com/leander256/ruby-libappindicator"
8
+ p.author = "Leander256"
9
+ p.email = "leander256@gmail.com"
10
+ p.development_dependencies = ["pkg-config", "gtk2"]
11
+ end
12
+
13
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,20 @@
1
+
2
+ require 'mkmf'
3
+ require 'rubygems'
4
+ require 'pkg-config'
5
+
6
+ def failure(msg)
7
+ puts "Error: #{msg}"
8
+ exit 1
9
+ end
10
+
11
+ package_id = 'appindicator-0.1'
12
+ PKGConfig.have_package(package_id) || failure("Couldn't find #{package_id}")
13
+
14
+ [['glib2','rbgobject.h'],['gtk2','rbgtk.h']].each do |g,h|
15
+ (h_fp = Gem::required_location(g,h)) || failure("Couldn't find #{h} file in #{g} gem")
16
+ find_header(h, h_fp.rpartition("/")[0])
17
+ end
18
+
19
+ create_makefile 'ruby_libappindicator'
20
+
@@ -0,0 +1,128 @@
1
+
2
+ #include <libappindicator/app-indicator.h>
3
+
4
+ #include <ruby.h>
5
+ #include <rbgobject.h>
6
+ #include <rbgtk.h>
7
+
8
+
9
+ /*
10
+ * This macro helps to define every setter method with one argument since
11
+ * the only difference between them is the method name and the cast
12
+ */
13
+ #define APP_INDICATOR_SETTER1(suffix, cast) \
14
+ static VALUE ai_set_##suffix(VALUE self, VALUE val) { \
15
+ VALUE rAI = rb_iv_get(self,"@ai_instance"); \
16
+ app_indicator_set_##suffix(RVAL2GOBJ(rAI), cast(val)); \
17
+ return Qnil; \
18
+ }
19
+
20
+ /*
21
+ * This macro helps to define every setter method with two arguments since
22
+ * the only difference between them is the method name and the cast
23
+ */
24
+ #define APP_INDICATOR_SETTER2(suffix, cast1, cast2) \
25
+ static VALUE ai_set_##suffix(VALUE self, VALUE val1, VALUE val2) { \
26
+ VALUE rAI = rb_iv_get(self,"@ai_instance"); \
27
+ app_indicator_set_##suffix(RVAL2GOBJ(rAI), cast1(val1), cast2(val2)); \
28
+ return Qnil; \
29
+ }
30
+
31
+ /*
32
+ * This macro helps to define *every* getter method of the object since
33
+ * the only difference between them is the method name and the cast
34
+ */
35
+ #define APP_INDICATOR_GETTER(suffix, cast) \
36
+ static VALUE ai_get_##suffix(VALUE self) { \
37
+ VALUE rAppIndicator = rb_iv_get(self,"@ai_instance"); \
38
+ return cast(app_indicator_get_##suffix(RVAL2GOBJ(rAppIndicator))); \
39
+ }
40
+
41
+ static VALUE ai_initialize(int argc, VALUE* argv, VALUE self) {
42
+ VALUE id, icon_name, category, icon_theme_path;
43
+
44
+ rb_scan_args(argc, argv, "31", &id, &icon_name, &category, &icon_theme_path);
45
+
46
+ AppIndicator* pAI;
47
+ if(NIL_P(icon_theme_path))
48
+ pAI = app_indicator_new(RVAL2CSTR(id), RVAL2CSTR(icon_name), NUM2INT(category));
49
+ else
50
+ pAI = app_indicator_new_with_path(RVAL2CSTR(id), RVAL2CSTR(icon_name), NUM2INT(category), RVAL2CSTR(icon_theme_path));
51
+
52
+ rb_iv_set(self, "@ai_instance", GOBJ2RVAL(pAI));
53
+ return self;
54
+ }
55
+
56
+ APP_INDICATOR_SETTER1(status, NUM2INT);
57
+ APP_INDICATOR_SETTER1(attention_icon, RVAL2CSTR);
58
+ APP_INDICATOR_SETTER2(attention_icon_full, RVAL2CSTR, RVAL2CSTR);
59
+ APP_INDICATOR_SETTER1(menu, RVAL2GOBJ);
60
+ APP_INDICATOR_SETTER1(icon, RVAL2CSTR);
61
+ APP_INDICATOR_SETTER2(icon_full, RVAL2CSTR, RVAL2CSTR);
62
+ APP_INDICATOR_SETTER2(label, RVAL2CSTR, RVAL2CSTR);
63
+ APP_INDICATOR_SETTER1(icon_theme_path, RVAL2CSTR);
64
+ APP_INDICATOR_SETTER1(ordering_index, NUM2UINT);
65
+
66
+ APP_INDICATOR_GETTER(id, CSTR2RVAL)
67
+ APP_INDICATOR_GETTER(category, INT2NUM)
68
+ APP_INDICATOR_GETTER(status, INT2NUM)
69
+ APP_INDICATOR_GETTER(icon, CSTR2RVAL)
70
+ APP_INDICATOR_GETTER(icon_desc, CSTR2RVAL)
71
+ APP_INDICATOR_GETTER(icon_theme_path, CSTR2RVAL)
72
+ APP_INDICATOR_GETTER(attention_icon, CSTR2RVAL)
73
+ APP_INDICATOR_GETTER(attention_icon_desc, CSTR2RVAL)
74
+ APP_INDICATOR_GETTER(menu, GOBJ2RVAL)
75
+ APP_INDICATOR_GETTER(label, CSTR2RVAL)
76
+ APP_INDICATOR_GETTER(label_guide, CSTR2RVAL)
77
+ APP_INDICATOR_GETTER(ordering_index, UINT2NUM)
78
+
79
+ static VALUE ai_build_menu_from_desktop(VALUE self, VALUE desktop_file, VALUE desktop_profile) {
80
+ VALUE rAppIndicator = rb_iv_get(self,"@ai_instance");
81
+ app_indicator_build_menu_from_desktop(RVAL2GOBJ(rAppIndicator), RVAL2CSTR(desktop_file), RVAL2CSTR(desktop_profile));
82
+ return Qnil;
83
+ }
84
+
85
+
86
+ Init_ruby_libappindicator() {
87
+ VALUE mAppIndicator = rb_define_module("AppIndicator");
88
+
89
+ VALUE cStatus = rb_define_class_under(mAppIndicator, "Status", rb_cObject);
90
+ rb_define_const(cStatus, "PASSIVE", INT2FIX(APP_INDICATOR_STATUS_PASSIVE));
91
+ rb_define_const(cStatus, "ACTIVE", INT2FIX(APP_INDICATOR_STATUS_ACTIVE));
92
+ rb_define_const(cStatus, "ATTENTION", INT2FIX(APP_INDICATOR_STATUS_ATTENTION));
93
+
94
+ VALUE cCategory = rb_define_class_under(mAppIndicator, "Category", rb_cObject);
95
+ rb_define_const(cCategory, "APPLICATION_STATUS", INT2FIX(APP_INDICATOR_CATEGORY_APPLICATION_STATUS));
96
+ rb_define_const(cCategory, "COMMUNICATIONS", INT2FIX(APP_INDICATOR_CATEGORY_COMMUNICATIONS));
97
+ rb_define_const(cCategory, "SYSTEM_SERVICES", INT2FIX(APP_INDICATOR_CATEGORY_SYSTEM_SERVICES));
98
+ rb_define_const(cCategory, "HARDWARE", INT2FIX(APP_INDICATOR_CATEGORY_HARDWARE));
99
+ rb_define_const(cCategory, "OTHER", INT2FIX(APP_INDICATOR_CATEGORY_OTHER));
100
+
101
+ VALUE cAppIndicator = rb_define_class_under(mAppIndicator, "AppIndicator", rb_cObject);
102
+ rb_define_method(cAppIndicator, "initialize", ai_initialize, -1);
103
+
104
+ rb_define_method(cAppIndicator, "set_status", ai_set_status, 1);
105
+ rb_define_method(cAppIndicator, "set_attention_icon", ai_set_attention_icon, 1);
106
+ rb_define_method(cAppIndicator, "set_attention_icon_full", ai_set_attention_icon_full, 2);
107
+ rb_define_method(cAppIndicator, "set_menu", ai_set_menu, 1);
108
+ rb_define_method(cAppIndicator, "set_icon", ai_set_icon, 1);
109
+ rb_define_method(cAppIndicator, "set_icon_full", ai_set_icon_full, 2);
110
+ rb_define_method(cAppIndicator, "set_label", ai_set_label, 2);
111
+ rb_define_method(cAppIndicator, "set_icon_theme_path", ai_set_icon_theme_path, 1);
112
+ rb_define_method(cAppIndicator, "set_ordering_index", ai_set_ordering_index, 1);
113
+
114
+ rb_define_method(cAppIndicator, "get_id", ai_get_id, 0);
115
+ rb_define_method(cAppIndicator, "get_category", ai_get_category, 0);
116
+ rb_define_method(cAppIndicator, "get_status", ai_get_status, 0);
117
+ rb_define_method(cAppIndicator, "get_icon", ai_get_icon, 0);
118
+ rb_define_method(cAppIndicator, "get_icon_desc", ai_get_icon_desc, 0);
119
+ rb_define_method(cAppIndicator, "get_icon_theme_path", ai_get_icon_theme_path, 0);
120
+ rb_define_method(cAppIndicator, "get_attention_icon", ai_get_attention_icon, 0);
121
+ rb_define_method(cAppIndicator, "get_attention_icon_desc", ai_get_attention_icon_desc, 0);
122
+ rb_define_method(cAppIndicator, "get_menu", ai_get_menu, 0);
123
+ rb_define_method(cAppIndicator, "get_label", ai_get_label, 0);
124
+ rb_define_method(cAppIndicator, "get_label_guide", ai_get_label_guide, 0);
125
+ rb_define_method(cAppIndicator, "get_ordering_index", ai_get_ordering_index, 0);
126
+
127
+ rb_define_method(cAppIndicator, "build_menu_from_desktop", ai_build_menu_from_desktop, 2);
128
+ }
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{ruby-libappindicator}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Leander256"]
9
+ s.date = %q{2011-03-31}
10
+ s.description = %q{Ruby bindings for libappindicator}
11
+ s.email = %q{leander256@gmail.com}
12
+ s.extensions = ["ext/libappindicator/extconf.rb"]
13
+ s.extra_rdoc_files = ["README.rdoc", "ext/libappindicator/extconf.rb", "ext/libappindicator/libappindicator.c"]
14
+ s.files = ["README.rdoc", "Rakefile", "ext/libappindicator/extconf.rb", "ext/libappindicator/libappindicator.c", "Manifest", "ruby-libappindicator.gemspec"]
15
+ s.homepage = %q{http://github.com/leander256/ruby-libappindicator}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruby-libappindicator", "--main", "README.rdoc"]
17
+ s.require_paths = ["ext"]
18
+ s.rubyforge_project = %q{ruby-libappindicator}
19
+ s.rubygems_version = %q{1.6.2}
20
+ s.summary = %q{Ruby bindings for libappindicator}
21
+
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<pkg-config>, [">= 0"])
27
+ s.add_development_dependency(%q<gtk2>, [">= 0"])
28
+ else
29
+ s.add_dependency(%q<pkg-config>, [">= 0"])
30
+ s.add_dependency(%q<gtk2>, [">= 0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<pkg-config>, [">= 0"])
34
+ s.add_dependency(%q<gtk2>, [">= 0"])
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-libappindicator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Leander256
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-31 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: pkg-config
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: gtk2
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: Ruby bindings for libappindicator
50
+ email: leander256@gmail.com
51
+ executables: []
52
+
53
+ extensions:
54
+ - ext/libappindicator/extconf.rb
55
+ extra_rdoc_files:
56
+ - README.rdoc
57
+ - ext/libappindicator/extconf.rb
58
+ - ext/libappindicator/libappindicator.c
59
+ files:
60
+ - README.rdoc
61
+ - Rakefile
62
+ - ext/libappindicator/extconf.rb
63
+ - ext/libappindicator/libappindicator.c
64
+ - Manifest
65
+ - ruby-libappindicator.gemspec
66
+ has_rdoc: true
67
+ homepage: http://github.com/leander256/ruby-libappindicator
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --line-numbers
73
+ - --inline-source
74
+ - --title
75
+ - Ruby-libappindicator
76
+ - --main
77
+ - README.rdoc
78
+ require_paths:
79
+ - ext
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 11
95
+ segments:
96
+ - 1
97
+ - 2
98
+ version: "1.2"
99
+ requirements: []
100
+
101
+ rubyforge_project: ruby-libappindicator
102
+ rubygems_version: 1.6.2
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Ruby bindings for libappindicator
106
+ test_files: []
107
+