summaryrefslogtreecommitdiff
path: root/mat-gui
diff options
context:
space:
mode:
authorjvoisin2013-06-26 21:11:21 +0200
committerjvoisin2013-06-26 21:11:21 +0200
commitb47ff0e87ea5a6739b2e95b43ec48c24e4be6110 (patch)
tree3b3c1c576a3893dbeb4ef019986584bb43a5b392 /mat-gui
parentd09b04b89f791ae1f38fc3ed44c1b1af4281bbdd (diff)
Cleanup of mat-gui
Diffstat (limited to '')
-rwxr-xr-xmat-gui41
1 files changed, 18 insertions, 23 deletions
diff --git a/mat-gui b/mat-gui
index aefe72a..bc2d1bc 100755
--- a/mat-gui
+++ b/mat-gui
@@ -102,13 +102,13 @@ class GUI(object):
102 targets.add_uri_targets(80) 102 targets.add_uri_targets(80)
103 self.treeview.drag_dest_set_target_list(targets) 103 self.treeview.drag_dest_set_target_list(targets)
104 104
105 def cb_update_supported_popup(self, w): 105 def cb_update_supported_popup(self, window):
106 ''' 106 '''
107 Fill GtkEntries of the supported_format_popups 107 Fill GtkEntries of the supported_format_popups
108 with corresponding data. 108 with corresponding data.
109 ''' 109 '''
110 i = w.get_active_iter() 110 i = window.get_active_iter()
111 index, _ = w.get_model()[i] 111 index, _ = window.get_model()[i]
112 support = self.builder.get_object('supported_support') 112 support = self.builder.get_object('supported_support')
113 support.set_text(self.supported_dict.list[index]['support']) 113 support.set_text(self.supported_dict.list[index]['support'])
114 metadata = self.builder.get_object('supported_metadata').get_buffer() 114 metadata = self.builder.get_object('supported_metadata').get_buffer()
@@ -123,7 +123,7 @@ class GUI(object):
123 Gtk.main_quit() 123 Gtk.main_quit()
124 124
125 def cb_add_files(self, button): 125 def cb_add_files(self, button):
126 ''' Add the files chosen by the filechoser ("Add" button) ''' 126 ''' Add the files chosen by the filechooser ("Add" button) '''
127 chooser = Gtk.FileChooserDialog(title=_('Choose files'), 127 chooser = Gtk.FileChooserDialog(title=_('Choose files'),
128 parent=self.window, action=Gtk.FileChooserAction.OPEN, 128 parent=self.window, action=Gtk.FileChooserAction.OPEN,
129 buttons=(Gtk.STOCK_OK, 0, Gtk.STOCK_CANCEL, 1)) 129 buttons=(Gtk.STOCK_OK, 0, Gtk.STOCK_CANCEL, 1))
@@ -141,9 +141,7 @@ class GUI(object):
141 supported_filter.set_name(_('Supported files')) 141 supported_filter.set_name(_('Supported files'))
142 chooser.add_filter(supported_filter) 142 chooser.add_filter(supported_filter)
143 143
144 response = chooser.run() 144 if not chooser.run(): # Gtk.STOCK_OK
145
146 if not response: # Gtk.STOCK_OK
147 filenames = chooser.get_filenames() 145 filenames = chooser.get_filenames()
148 GObject.idle_add(self.populate(filenames).next) # asynchrone processing 146 GObject.idle_add(self.populate(filenames).next) # asynchrone processing
149 chooser.destroy() 147 chooser.destroy()
@@ -153,21 +151,20 @@ class GUI(object):
153 Popup that display on double-clic 151 Popup that display on double-clic
154 metadata from a file 152 metadata from a file
155 ''' 153 '''
156 MetadataPopupListStore = self.builder.get_object('MetadataPopupListStore') 154 metadataPopupListStore = self.builder.get_object('MetadataPopupListStore')
157 MetadataPopupListStore.clear() 155 metadataPopupListStore.clear()
158 if self.liststore[row][0].file.is_clean(): 156 if self.liststore[row][0].file.is_clean():
159 MetadataPopupListStore.append([_('No metadata found'), '']) 157 metadataPopupListStore.append([_('No metadata found'), ''])
160 self.liststore[row][2] = _('Clean') 158 self.liststore[row][2] = _('Clean')
161 else: 159 else:
162 self.liststore[row][2] = _('Dirty') 160 self.liststore[row][2] = _('Dirty')
163 for i, j in self.liststore[row][0].file.get_meta().iteritems(): 161 for i, j in self.liststore[row][0].file.get_meta().iteritems():
164 MetadataPopupListStore.append([i, j]) 162 metadataPopupListStore.append([i, j])
165 163
166 popup_metadata = self.builder.get_object('MetadataPopup') 164 popup_metadata = self.builder.get_object('MetadataPopup')
167 popup_metadata.set_title(_("%s's metadata") % self.liststore[row][0].file.basename) 165 popup_metadata.set_title(_("%s's metadata") % self.liststore[row][0].file.basename)
168 popup_metadata.show_all() 166 popup_metadata.show_all()
169 click = popup_metadata.run() 167 if not popup_metadata.run(): # Close
170 if not click: # Close
171 popup_metadata.hide() 168 popup_metadata.hide()
172 169
173 def cb_about_popup(self, button): 170 def cb_about_popup(self, button):
@@ -176,7 +173,7 @@ class GUI(object):
176 w.set_authors(['Julien (jvoisin) Voisin', ]) 173 w.set_authors(['Julien (jvoisin) Voisin', ])
177 w.set_artists(['Marine Benoît', ]) 174 w.set_artists(['Marine Benoît', ])
178 w.set_copyright('GNU Public License v2') 175 w.set_copyright('GNU Public License v2')
179 w.set_comments(_('This software was coded during the GSoC 2011')) 176 w.set_comments(_(''))
180 w.set_logo(GdkPixbuf.Pixbuf.new_from_file_at_size(self.logo, 400, 200)) 177 w.set_logo(GdkPixbuf.Pixbuf.new_from_file_at_size(self.logo, 400, 200))
181 w.set_program_name('Metadata Anonymisation Toolkit') 178 w.set_program_name('Metadata Anonymisation Toolkit')
182 w.set_version(mat.__version__) 179 w.set_version(mat.__version__)
@@ -190,8 +187,7 @@ class GUI(object):
190 ''' Show the "supported formats" popup''' 187 ''' Show the "supported formats" popup'''
191 dialog = self.builder.get_object('SupportedWindow') 188 dialog = self.builder.get_object('SupportedWindow')
192 dialog.show_all() 189 dialog.show_all()
193 click = dialog.run() 190 if not dialog.run():
194 if not click: # Close
195 dialog.hide() 191 dialog.hide()
196 192
197 def cb_clear_list(self, _): 193 def cb_clear_list(self, _):
@@ -266,9 +262,9 @@ non-anonymised) file to output archive'))
266 elif url.startswith('file:'): # xffm 262 elif url.startswith('file:'): # xffm
267 return url[5:] # 5 is len('file:') 263 return url[5:] # 5 is len('file:')
268 264
269 urls = selection.get_uris() 265 dirties_urls = selection.get_uris()
270 urls = map(clean_path, urls) 266 cleaned_urls = map(clean_path, dirties_urls)
271 GObject.idle_add(self.populate(urls).next) # asynchrone processing 267 GObject.idle_add(self.populate(cleaned_urls).next) # asynchrone processing
272 268
273 def __add_file_to_treeview(self, filename): 269 def __add_file_to_treeview(self, filename):
274 ''' 270 '''
@@ -334,9 +330,9 @@ non-anonymised) file to output archive'))
334 for item in filelist: 330 for item in filelist:
335 mime = mimetypes.guess_type(item)[0] 331 mime = mimetypes.guess_type(item)[0]
336 if mime: 332 if mime:
337 store.append([item, mime]) 333 store.append([os.path.basename(item), mime])
338 else: 334 else:
339 store.append([item, _('unknown')]) 335 store.append([os.path.basename(item), _('Unknown mimetype')])
340 336
341 treeview = Gtk.TreeView(store) 337 treeview = Gtk.TreeView(store)
342 vbox.pack_start(treeview, True, True, 0) 338 vbox.pack_start(treeview, True, True, 0)
@@ -349,8 +345,7 @@ non-anonymised) file to output archive'))
349 treeview.append_column(column) 345 treeview.append_column(column)
350 346
351 dialog.show_all() 347 dialog.show_all()
352 click = dialog.run() 348 if not dialog.run(): # Ok button
353 if not click: # Ok button
354 dialog.destroy() 349 dialog.destroy()
355 350
356 def __mat_check(self, iterator): 351 def __mat_check(self, iterator):