Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar/0050-Patch-to-add-feedback-icon-to-frame.patch
blob: edc6e995d84ceea4eb87c10f24763a2c854c9f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
From 274fc4539ea8d2b2cd33ae60321fdfb629375e40 Mon Sep 17 00:00:00 2001
From: Mukesh Gupta <mukeshgupta.2006@gmail.com>
Date: Tue, 18 Jan 2011 07:54:15 +0000
Subject: [PATCH sugar 50/74] Patch to add feedback icon to frame

Signed-off-by: Mukesh Gupta <mukeshgupta.2006@gmail.com>
---
 extensions/deviceicon/Makefile.am |    4 +-
 extensions/deviceicon/feedback.py |  129 +++++++++++++++++++++++++++++++++++++
 2 files changed, 132 insertions(+), 1 deletions(-)
 create mode 100644 extensions/deviceicon/feedback.py

diff --git a/extensions/deviceicon/Makefile.am b/extensions/deviceicon/Makefile.am
index 3a74053..b38cbb3 100644
--- a/extensions/deviceicon/Makefile.am
+++ b/extensions/deviceicon/Makefile.am
@@ -8,4 +8,6 @@ sugar_PYTHON = 		\
 	speaker.py	\
 	touchpad.py	\
 	virtualkeyboard.py	\
-	volume.py
+	volume.py	\
+	feedback.py
+	
diff --git a/extensions/deviceicon/feedback.py b/extensions/deviceicon/feedback.py
new file mode 100644
index 0000000..dc40a6e
--- /dev/null
+++ b/extensions/deviceicon/feedback.py
@@ -0,0 +1,129 @@
+# Copyright (C) Mukesh Gupta <mukeshgupta.2006@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+import logging
+from gettext import gettext as _
+import gconf
+import gtk
+from sugar.graphics import style
+from sugar.graphics.tray import TrayIcon
+from sugar.graphics.palette import Palette
+from sugar.graphics.xocolor import XoColor
+from jarabe.model import feedback_collector
+from jarabe.view import launcher
+from sugar.activity import activityfactory
+from jarabe.model import bundleregistry
+from sugar.activity.activityhandle import ActivityHandle
+
+_ICON_NAME = 'feedback-icon'
+
+class DeviceView(TrayIcon):
+    FRAME_POSITION_RELATIVE = 500
+    def __init__(self):
+        client = gconf.client_get_default()
+        self._color = XoColor(client.get_string('/desktop/sugar/user/color'))
+        TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color)
+        self.create_palette()
+            
+    def create_palette(self):
+        logging.debug('palette created')
+        self.palette = BugsPalette(_('Bugs'))
+        self.palette.set_group_id('frame')
+        return self.palette
+
+
+class BugsPalette(Palette):  
+    
+    def __init__(self, primary_text):
+        Palette.__init__(self, primary_text)
+        self._level = 0        
+        self._status_label = gtk.Label()
+        self._status_label.show()
+        self.vbox = gtk.VBox()        
+        self.hbox = gtk.HBox()              
+        self.set_content(self.vbox)
+        self._bugs_count_text = gtk.Label()
+        self.vbox.pack_start(self._bugs_count_text,
+         padding = style.DEFAULT_PADDING)                      
+        self.vbox.pack_start(self.hbox, padding = style.DEFAULT_PADDING)
+        self.vbox.show()        
+        self.hbox.pack_start(self._status_label,
+         padding = style.DEFAULT_PADDING)
+        self.hbox.show()        
+        self._open_log_button = gtk.Button("Open Log")
+        self._open_log_button.connect("clicked",
+         self.__open_log_activity)
+        self.hbox.pack_start(self._open_log_button,
+         padding = style.DEFAULT_PADDING)        
+        self._send_report_button = gtk.Button("Send Report")
+        self._send_report_button.connect("clicked", self.__send_bug_report)
+        self.hbox.pack_start(self._send_report_button,
+         padding = style.DEFAULT_PADDING)       
+        self.__get_bug_count()
+        self._bugs_count_text.show()
+        self._open_log_button.show()
+        self._send_report_button.show()        
+    
+    def popup(self, immediate=False, state=None):
+        Palette.popup(self, immediate=immediate, state=state)
+        self.__update_bug_palette()
+        
+        
+    def __send_bug_report(self, button):
+        feedback_collector.submit()
+        
+    def __open_log_activity(self, path):
+        
+        registry = bundleregistry.get_registry()
+        bundle = registry.get_bundle('org.laptop.Log')
+        activity_id = activityfactory.create_activity_id()
+        client = gconf.client_get_default()
+        xo_color = XoColor(client.get_string('/desktop/sugar/user/color'))
+        launcher.add_launcher(activity_id, bundle.get_icon(), xo_color)
+        activityfactory.create(bundle, ActivityHandle(activity_id))
+            
+    def __get_bug_count(self):
+        """This method returns the total error count"""
+        bugs_count = 0
+        
+        
+        return bugs_count
+    
+    def __update_bug_palette(self):        
+        bugs_count = self.__get_bug_count()    
+        self._open_log_button.set_sensitive(False)
+        have_reports, have_errors = feedback_collector.stat()
+        #have_reports, have_errors=[True,False]
+        if have_errors:
+            self._open_log_button.set_sensitive(True)
+        else:
+            self._open_log_button.set_sensitive(False)
+        
+                
+        if have_reports:
+            self._send_report_button.set_sensitive(True)
+        else:
+            self._send_report_button.set_sensitive(False)
+                    
+        if bugs_count == 0:        
+            self._bugs_count_text.set_label('No Errors')
+        else :            
+            self._bugs_count_text.set_label(_('Total Errors: %d' %  bugs_count))
+ 
+def setup(tray):
+    client = gconf.client_get_default()
+    if client.get_bool('/desktop/sugar/feedback/enabled'):
+        tray.add_device(DeviceView())
-- 
1.7.6