diff options
| -rw-r--r-- | data/mat.ui | 4 | ||||
| -rwxr-xr-x | mat-gui | 40 |
2 files changed, 14 insertions, 30 deletions
diff --git a/data/mat.ui b/data/mat.ui index f8b2db1..001db33 100644 --- a/data/mat.ui +++ b/data/mat.ui | |||
| @@ -139,7 +139,7 @@ | |||
| 139 | <property name="can_focus">False</property> | 139 | <property name="can_focus">False</property> |
| 140 | <child> | 140 | <child> |
| 141 | <object class="GtkImageMenuItem" id="clean_menuitem"> | 141 | <object class="GtkImageMenuItem" id="clean_menuitem"> |
| 142 | <property name="label">Clean</property> | 142 | <property name="label">Scour</property> |
| 143 | <property name="visible">True</property> | 143 | <property name="visible">True</property> |
| 144 | <property name="can_focus">False</property> | 144 | <property name="can_focus">False</property> |
| 145 | <property name="image">GtkClear</property> | 145 | <property name="image">GtkClear</property> |
| @@ -224,7 +224,7 @@ | |||
| 224 | <object class="GtkToolButton" id="ToolbarClean"> | 224 | <object class="GtkToolButton" id="ToolbarClean"> |
| 225 | <property name="visible">True</property> | 225 | <property name="visible">True</property> |
| 226 | <property name="can_focus">False</property> | 226 | <property name="can_focus">False</property> |
| 227 | <property name="label" translatable="yes">Clean</property> | 227 | <property name="label" translatable="yes">Scour</property> |
| 228 | <property name="stock_id">gtk-clear</property> | 228 | <property name="stock_id">gtk-clear</property> |
| 229 | <signal name="clicked" handler="cb_mat_clean" swapped="no"/> | 229 | <signal name="clicked" handler="cb_mat_clean" swapped="no"/> |
| 230 | </object> | 230 | </object> |
| @@ -1,9 +1,7 @@ | |||
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -* | 2 | # -*- coding: utf-8 -* |
| 3 | 3 | ||
| 4 | ''' | 4 | ''' Metadata anonymisation toolkit - GUI edition ''' |
| 5 | Metadata anonymisation toolkit - GUI edition | ||
| 6 | ''' | ||
| 7 | 5 | ||
| 8 | from gi.repository import GObject, Gtk, GLib | 6 | from gi.repository import GObject, Gtk, GLib |
| 9 | from gi.repository import Gdk, GdkPixbuf | 7 | from gi.repository import Gdk, GdkPixbuf |
| @@ -24,8 +22,7 @@ logging.basicConfig(level=mat.LOGGING_LEVEL) | |||
| 24 | 22 | ||
| 25 | 23 | ||
| 26 | class CFile(GObject.Object): | 24 | class CFile(GObject.Object): |
| 27 | ''' | 25 | ''' Contain the "parser" class of the file "filename" |
| 28 | Contain the "parser" class of the file "filename" | ||
| 29 | This class exist just to be "around" my parser.Generic_parser class, | 26 | This class exist just to be "around" my parser.Generic_parser class, |
| 30 | since the Gtk.ListStore does not accept it because it does not | 27 | since the Gtk.ListStore does not accept it because it does not |
| 31 | extends Gobject.Object | 28 | extends Gobject.Object |
| @@ -35,9 +32,7 @@ class CFile(GObject.Object): | |||
| 35 | 32 | ||
| 36 | 33 | ||
| 37 | class GUI(object): | 34 | class GUI(object): |
| 38 | ''' | 35 | ''' Main GUI class ''' |
| 39 | Main GUI class | ||
| 40 | ''' | ||
| 41 | def __init__(self): | 36 | def __init__(self): |
| 42 | # Preferences | 37 | # Preferences |
| 43 | self.add2archive = True | 38 | self.add2archive = True |
| @@ -111,12 +106,11 @@ class GUI(object): | |||
| 111 | return False | 106 | return False |
| 112 | 107 | ||
| 113 | def cb_update_supported_popup(self, window): | 108 | def cb_update_supported_popup(self, window): |
| 114 | ''' | 109 | ''' Fill GtkEntries of the supported_format_popups |
| 115 | Fill GtkEntries of the supported_format_popups | ||
| 116 | with corresponding data. | 110 | with corresponding data. |
| 117 | ''' | 111 | ''' |
| 118 | i = window.get_active_iter() | 112 | i = window.get_active_iter() |
| 119 | index, _ = window.get_model()[i] | 113 | index = window.get_model()[i][0] |
| 120 | support = self.builder.get_object('supported_support') | 114 | support = self.builder.get_object('supported_support') |
| 121 | support.set_text(self.supported_dict.list[index]['support']) | 115 | support.set_text(self.supported_dict.list[index]['support']) |
| 122 | metadata = self.builder.get_object('supported_metadata').get_buffer() | 116 | metadata = self.builder.get_object('supported_metadata').get_buffer() |
| @@ -155,8 +149,7 @@ class GUI(object): | |||
| 155 | chooser.destroy() | 149 | chooser.destroy() |
| 156 | 150 | ||
| 157 | def cb_popup_metadata(self, widget, row, col): | 151 | def cb_popup_metadata(self, widget, row, col): |
| 158 | ''' | 152 | ''' Popup that display on double-clic |
| 159 | Popup that display on double-clic | ||
| 160 | metadata from a file | 153 | metadata from a file |
| 161 | ''' | 154 | ''' |
| 162 | metadataPopupListStore = self.builder.get_object('MetadataPopupListStore') | 155 | metadataPopupListStore = self.builder.get_object('MetadataPopupListStore') |
| @@ -250,15 +243,13 @@ non-anonymised) file to output archive')) | |||
| 250 | 243 | ||
| 251 | def cb_drag_data_received(self, widget, context, | 244 | def cb_drag_data_received(self, widget, context, |
| 252 | x, y, selection, target_type, timestamp): | 245 | x, y, selection, target_type, timestamp): |
| 253 | ''' | 246 | ''' This function is called when something is |
| 254 | This function is called when something is | ||
| 255 | drag'n'droped into mat. | 247 | drag'n'droped into mat. |
| 256 | It basically add files. | 248 | It basically add files. |
| 257 | ''' | 249 | ''' |
| 258 | 250 | ||
| 259 | def clean_path(url): | 251 | def clean_path(url): |
| 260 | ''' | 252 | ''' Since the dragged urls are ugly, |
| 261 | Since the dragged urls are ugly, | ||
| 262 | we need to process them | 253 | we need to process them |
| 263 | ''' | 254 | ''' |
| 264 | url = urllib2.unquote(url) # unquote url | 255 | url = urllib2.unquote(url) # unquote url |
| @@ -275,9 +266,7 @@ non-anonymised) file to output archive')) | |||
| 275 | GLib.idle_add(self.populate(cleaned_urls).next) # asynchronous processing | 266 | GLib.idle_add(self.populate(cleaned_urls).next) # asynchronous processing |
| 276 | 267 | ||
| 277 | def __add_file_to_treeview(self, filename): | 268 | def __add_file_to_treeview(self, filename): |
| 278 | ''' | 269 | ''' Add a file to the list if its format is supported ''' |
| 279 | Add a file to the list if its format is supported | ||
| 280 | ''' | ||
| 281 | cf = CFile(filename, add2archive=self.add2archive, | 270 | cf = CFile(filename, add2archive=self.add2archive, |
| 282 | low_pdf_quality=self.pdf_quality) | 271 | low_pdf_quality=self.pdf_quality) |
| 283 | # if the file is supported by the mat, | 272 | # if the file is supported by the mat, |
| @@ -288,9 +277,7 @@ non-anonymised) file to output archive')) | |||
| 288 | return True | 277 | return True |
| 289 | 278 | ||
| 290 | def __process_files(self, func): | 279 | def __process_files(self, func): |
| 291 | ''' | 280 | ''' Launch the function "func" in a asynchronous way ''' |
| 292 | Launch the function "func" in a asynchronous way | ||
| 293 | ''' | ||
| 294 | iterator = self.treeview.get_selection().get_selected_rows()[1] | 281 | iterator = self.treeview.get_selection().get_selected_rows()[1] |
| 295 | if not iterator: # if nothing is selected : select everything | 282 | if not iterator: # if nothing is selected : select everything |
| 296 | iterator = range(len(self.liststore)) | 283 | iterator = range(len(self.liststore)) |
| @@ -305,9 +292,7 @@ non-anonymised) file to output archive')) | |||
| 305 | self.add2archive = not self.add2archive | 292 | self.add2archive = not self.add2archive |
| 306 | 293 | ||
| 307 | def populate(self, filenames): | 294 | def populate(self, filenames): |
| 308 | ''' | 295 | ''' Append selected files by add_file to the self.liststore ''' |
| 309 | Append selected files by add_file to the self.liststore | ||
| 310 | ''' | ||
| 311 | not_supported = [] | 296 | not_supported = [] |
| 312 | for filename in filenames: # filenames : all selected files/folders | 297 | for filename in filenames: # filenames : all selected files/folders |
| 313 | if os.path.isdir(filename): # if "filename" is a directory | 298 | if os.path.isdir(filename): # if "filename" is a directory |
| @@ -326,8 +311,7 @@ non-anonymised) file to output archive')) | |||
| 326 | yield False | 311 | yield False |
| 327 | 312 | ||
| 328 | def __popup_non_supported(self, filelist): | 313 | def __popup_non_supported(self, filelist): |
| 329 | ''' | 314 | ''' Popup that warn the user about the unsupported files |
| 330 | Popup that warn the user about the unsupported files | ||
| 331 | that he want to process | 315 | that he want to process |
| 332 | ''' | 316 | ''' |
| 333 | dialog = Gtk.Dialog(title=_('Not-supported'), parent=self.window, | 317 | dialog = Gtk.Dialog(title=_('Not-supported'), parent=self.window, |
