Browse Source

more work on the applet, now using gconf

Enrico Tassi 12 years ago
parent
commit
025e06f400
3 changed files with 177 additions and 7 deletions
  1. 4
    1
      Makefile
  2. 143
    0
      smd-applet.ui
  3. 30
    6
      smd-applet.vala

+ 4
- 1
Makefile View File

@@ -1,5 +1,5 @@
1 1
 PROJECTNAME=syncmaildir
2
-BINARIES=mddiff
2
+BINARIES=mddiff smd-applet
3 3
 MANPAGES=mddiff.1 smd-server.1 smd-client.1 smd-pull.1 smd-push.1
4 4
 HTML=index.html design.html
5 5
 PREFIX=usr/local
@@ -8,6 +8,9 @@ VERSION=0.9.5
8 8
 
9 9
 all: check-build $(BINARIES) 
10 10
 
11
+%: %.vala 
12
+	valac --pkg gtk+-2.0 --pkg libnotify --pkg gconf-2.0 -o $@ $<
13
+
11 14
 %: %.c
12 15
 	gcc -Wall -Wextra -g $< -o $@ \
13 16
 		`pkg-config --cflags --libs glib-2.0` \

+ 143
- 0
smd-applet.ui View File

@@ -4,6 +4,16 @@
4 4
   <!-- interface-naming-policy project-wide -->
5 5
   <object class="GtkMenu" id="mMain">
6 6
     <property name="visible">True</property>
7
+    <child>
8
+      <object class="GtkImageMenuItem" id="miPrefs">
9
+        <property name="label">gtk-preferences</property>
10
+        <property name="visible">True</property>
11
+        <property name="tooltip_text" translatable="yes">Configure smd-applet</property>
12
+        <property name="use_underline">True</property>
13
+        <property name="use_stock">True</property>
14
+        <property name="always_show_image">True</property>
15
+      </object>
16
+    </child>
7 17
     <child>
8 18
       <object class="GtkImageMenuItem" id="miAbout">
9 19
         <property name="label">gtk-about</property>
@@ -24,4 +34,137 @@
24 34
       </object>
25 35
     </child>
26 36
   </object>
37
+  <object class="GtkListStore" id="namelist">
38
+    <columns>
39
+      <!-- column-name hosts -->
40
+      <column type="gchar"/>
41
+    </columns>
42
+  </object>
43
+  <object class="GtkWindow" id="wPrefs">
44
+    <child>
45
+      <object class="GtkHBox" id="hbox1">
46
+        <property name="visible">True</property>
47
+        <child>
48
+          <object class="GtkVBox" id="vbox1">
49
+            <property name="visible">True</property>
50
+            <property name="orientation">vertical</property>
51
+            <child>
52
+              <object class="GtkVBox" id="vbox2">
53
+                <property name="visible">True</property>
54
+                <property name="orientation">vertical</property>
55
+                <property name="spacing">2</property>
56
+                <child>
57
+                  <object class="GtkFrame" id="frame1">
58
+                    <property name="visible">True</property>
59
+                    <property name="label_xalign">0</property>
60
+                    <child>
61
+                      <object class="GtkAlignment" id="alignment1">
62
+                        <property name="visible">True</property>
63
+                        <property name="top_padding">12</property>
64
+                        <property name="bottom_padding">12</property>
65
+                        <property name="left_padding">12</property>
66
+                        <property name="right_padding">12</property>
67
+                        <child>
68
+                          <object class="GtkVBox" id="vbox3">
69
+                            <property name="visible">True</property>
70
+                            <property name="orientation">vertical</property>
71
+                            <child>
72
+                              <object class="GtkCheckButton" id="cbIcon">
73
+                                <property name="label" translatable="yes">Display icon only on errors</property>
74
+                                <property name="visible">True</property>
75
+                                <property name="can_focus">True</property>
76
+                                <property name="receives_default">False</property>
77
+                                <property name="draw_indicator">True</property>
78
+                              </object>
79
+                              <packing>
80
+                                <property name="position">0</property>
81
+                              </packing>
82
+                            </child>
83
+                            <child>
84
+                              <object class="GtkCheckButton" id="cbNotify">
85
+                                <property name="label" translatable="yes">Notify when new mail is pulled</property>
86
+                                <property name="visible">True</property>
87
+                                <property name="can_focus">True</property>
88
+                                <property name="receives_default">False</property>
89
+                                <property name="draw_indicator">True</property>
90
+                              </object>
91
+                              <packing>
92
+                                <property name="position">1</property>
93
+                              </packing>
94
+                            </child>
95
+                            <child>
96
+                              <placeholder/>
97
+                            </child>
98
+                          </object>
99
+                        </child>
100
+                      </object>
101
+                    </child>
102
+                    <child type="label">
103
+                      <object class="GtkLabel" id="label1">
104
+                        <property name="visible">True</property>
105
+                        <property name="label" translatable="yes">&lt;b&gt;Preferences&lt;/b&gt;</property>
106
+                        <property name="use_markup">True</property>
107
+                      </object>
108
+                    </child>
109
+                  </object>
110
+                  <packing>
111
+                    <property name="position">0</property>
112
+                  </packing>
113
+                </child>
114
+                <child>
115
+                  <object class="GtkHButtonBox" id="hbuttonbox1">
116
+                    <property name="visible">True</property>
117
+                    <property name="layout_style">end</property>
118
+                    <child>
119
+                      <object class="GtkButton" id="bClose">
120
+                        <property name="label" translatable="yes">gtk-close</property>
121
+                        <property name="visible">True</property>
122
+                        <property name="can_focus">True</property>
123
+                        <property name="receives_default">True</property>
124
+                        <property name="use_stock">True</property>
125
+                      </object>
126
+                      <packing>
127
+                        <property name="expand">False</property>
128
+                        <property name="fill">False</property>
129
+                        <property name="position">0</property>
130
+                      </packing>
131
+                    </child>
132
+                  </object>
133
+                  <packing>
134
+                    <property name="expand">False</property>
135
+                    <property name="padding">4</property>
136
+                    <property name="position">1</property>
137
+                  </packing>
138
+                </child>
139
+              </object>
140
+              <packing>
141
+                <property name="padding">6</property>
142
+                <property name="position">0</property>
143
+              </packing>
144
+            </child>
145
+          </object>
146
+          <packing>
147
+            <property name="padding">6</property>
148
+            <property name="position">0</property>
149
+          </packing>
150
+        </child>
151
+      </object>
152
+    </child>
153
+  </object>
154
+  <object class="GtkAdjustment" id="adjPull">
155
+    <property name="value">5</property>
156
+    <property name="lower">1</property>
157
+    <property name="upper">60</property>
158
+    <property name="step_increment">1</property>
159
+    <property name="page_increment">10</property>
160
+    <property name="page_size">10</property>
161
+  </object>
162
+  <object class="GtkAdjustment" id="adjPush">
163
+    <property name="value">10</property>
164
+    <property name="lower">1</property>
165
+    <property name="upper">60</property>
166
+    <property name="step_increment">1</property>
167
+    <property name="page_increment">10</property>
168
+    <property name="page_size">10</property>
169
+  </object>
27 170
 </interface>

+ 30
- 6
smd-applet.vala View File

@@ -1,30 +1,54 @@
1 1
 using Gtk;
2 2
 using Notify;
3
+using GConf;
3 4
 
4 5
 class smdApplet {
5 6
 
6 7
 	Gtk.Menu menu = null;
7 8
 	Gtk.StatusIcon si = null;
9
+	Gtk.Window win = null;
10
+	GConf.Client gconf = null;
11
+
12
+	static const string key_icon = "/apps/smd-applet/icon_only_on_errors";
13
+	static const string key_newmail = "/apps/smd-applet/notify_new_mail";
8 14
 
9 15
 	smdApplet(Gtk.Builder builder) {
10
-        menu = builder.get_object ("mMain") as Menu;
11
-		si = new StatusIcon.from_stock(Gtk.STOCK_NETWORK);
16
+		gconf = GConf.Client.get_default();
12 17
 
18
+		win = builder.get_object("wPrefs") as Window;
19
+		var close = builder.get_object("bClose") as Button;
20
+		close.clicked += (b) =>  { win.hide(); };
21
+		var bicon = builder.get_object("cbIcon") as CheckButton;
22
+		bicon.set_active( gconf.get_bool(key_icon));
23
+		bicon.toggled += (b) => {
24
+			try { gconf.set_bool(key_icon,b.active); }
25
+			catch (GLib.Error e) { stderr.printf("%s\n",e.message); }
26
+		};
27
+		var bnotify = builder.get_object("cbNotify") as CheckButton;
28
+		bnotify.set_active( gconf.get_bool(key_newmail));
29
+		bnotify.toggled += (b) => {
30
+			try { gconf.set_bool(key_newmail,b.active); }
31
+			catch (GLib.Error e) { stderr.printf("%s\n",e.message); }
32
+		};
33
+
34
+        menu = builder.get_object ("mMain") as Menu;
13 35
 		var quit = builder.get_object ("miQuit") as MenuItem;
14 36
 		quit.activate += (b) => { Gtk.main_quit(); };
15 37
 		var about = builder.get_object ("miAbout") as MenuItem;
16 38
 		about.activate += (b) => { Gtk.main_quit(); };
39
+		var prefs = builder.get_object ("miPrefs") as MenuItem;
40
+		prefs.activate += (b) => {  win.show(); };
17 41
 
42
+		si = new StatusIcon.from_stock(Gtk.STOCK_NETWORK);
18 43
 		si.activate += (s) => { 
19 44
 			menu.popup(null,null,si.position_menu,0,
20 45
 				Gtk.get_current_event_time());
21 46
 		};
22
-	
23 47
 		si.set_visible(true);
24 48
 
25
-		var not = new Notify.Notification("foo","bar","gtk-about",null);
26
-		not.attach_to_status_icon(si);
27
-		not.show();
49
+		// var not = new Notify.Notification("foo","bar","gtk-about",null);
50
+		// not.attach_to_status_icon(si);
51
+		// not.show();
28 52
 	}
29 53
 
30 54
 	void run() { Gtk.main(); }

Loading…
Cancel
Save