Exemplo n.º 1
0
 def on_treeview_folders_cursor_changed(self, widget):
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         # Check if the folder still exists
         # (model erased while the cursor moves through the Gtk.TreeView)
         if folder_name in self.folders:
             folder_info = self.folders[folder_name]
             # Clear any previous application icon
             self.model_applications.clear()
             # Add new application icons
             applications = folder_info.get_applications()
             for application in applications:
                 desktop_file = applications[application]
                 if desktop_file or preferences.get(
                         preferences.PREFERENCES_SHOW_MISSING):
                     application_file = applications[application]
                     application_info = ApplicationInfo(
                         application,
                         application_file.getName()
                         if desktop_file else 'Missing desktop file',
                         application_file.getComment()
                         if desktop_file else application,
                         application_file.getIcon()
                         if desktop_file else None,
                         # Always show any application, also if hidden
                         True)
                     self.model_applications.add_data(application_info)
         # Disable folder content saving
         self.ui.action_files_save.set_sensitive(False)
Exemplo n.º 2
0
 def on_action_folders_remove_activate(self, action):
     """Remove the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         if show_message_dialog(class_=UIMessageDialogNoYes,
                                parent=self.ui.win_main,
                                message_type=Gtk.MessageType.QUESTION,
                                title=None,
                                msg1=_('Remove the selected folder?'),
                                msg2=_('Are you sure you want to remove '
                                       'the folder %s?') % folder_name,
                                is_response_id=Gtk.ResponseType.YES):
             # Remove the AppFolder from settings
             folder_info = self.folders[folder_name]
             folder_info.remove()
             self.folders.pop(folder_name)
             # Remove the folder name from the folders list
             settings_folders = Gio.Settings.new(SCHEMA_FOLDERS)
             list_folders = settings_folders.get_strv('folder-children')
             list_folders.remove(folder_name)
             settings_folders.set_strv('folder-children', list_folders)
             # Clear the applications model
             self.model_applications.clear()
             # Remove the folder from the folders model
             self.model_folders.remove(selected_row)
Exemplo n.º 3
0
 def on_action_files_remove_activate(self, action):
     """Remove the selected application from the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_applications)
     if selected_row:
         self.model_applications.remove(selected_row)
         # Enable folder content saving
         self.ui.action_files_save.set_sensitive(True)
Exemplo n.º 4
0
 def on_action_folders_remove_activate(self, action):
     """Remove the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         if show_message_dialog(class_=UIMessageDialogNoYes,
                                parent=self.ui.win_main,
                                message_type=Gtk.MessageType.QUESTION,
                                title=None,
                                msg1=_('Remove the selected folder?'),
                                msg2=_('Are you sure you want to remove '
                                       'the folder %s?') % folder_name,
                                is_response_id=Gtk.ResponseType.YES):
             # Remove the AppFolder from settings
             folder_info = self.folders[folder_name]
             folder_info.remove()
             self.folders.pop(folder_name)
             # Remove the folder name from the folders list
             settings_folders = Gio.Settings.new(SCHEMA_FOLDERS)
             list_folders = settings_folders.get_strv('folder-children')
             list_folders.remove(folder_name)
             settings_folders.set_strv('folder-children', list_folders)
             # Clear the applications model
             self.model_applications.clear()
             # Remove the folder from the folders model
             self.model_folders.remove(selected_row)
Exemplo n.º 5
0
 def on_action_files_remove_activate(self, action):
     """Remove the selected application from the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_applications)
     if selected_row:
         self.model_applications.remove(selected_row)
         # Enable folder content saving
         self.ui.action_files_save.set_sensitive(True)
Exemplo n.º 6
0
 def on_treeview_folders_cursor_changed(self, widget):
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         # Check if the folder still exists
         # (model erased while the cursor moves through the Gtk.TreeView)
         if folder_name in self.folders:
             folder_info = self.folders[folder_name]
             # Clear any previous application icon
             self.model_applications.clear()
             # Add new application icons
             applications = folder_info.get_applications()
             for application in applications:
                 desktop_file = applications[application]
                 if desktop_file or preferences.get(
                         preferences.PREFERENCES_SHOW_MISSING):
                     application_file = applications[application]
                     application_info = ApplicationInfo(
                         application,
                         application_file.getName()
                         if desktop_file else 'Missing desktop file',
                         application_file.getComment()
                         if desktop_file else application,
                         application_file.getIcon()
                         if desktop_file else None,
                         # Always show any application, also if hidden
                         True)
                     self.model_applications.add_data(application_info)
         # Disable folder content saving
         self.ui.action_files_save.set_sensitive(False)
Exemplo n.º 7
0
 def on_action_files_save_activate(self, action):
     """Save the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         folder_info = self.folders[folder_name]
         folder_info.set_applications(self.model_applications.rows.keys())
     # Disable folder content saving
     self.ui.action_files_save.set_sensitive(False)
Exemplo n.º 8
0
 def on_action_files_save_activate(self, action):
     """Save the current AppFolder"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         folder_name = self.model_folders.get_key(selected_row)
         folder_info = self.folders[folder_name]
         folder_info.set_applications(self.model_applications.rows.keys())
     # Disable folder content saving
     self.ui.action_files_save.set_sensitive(False)
Exemplo n.º 9
0
 def on_treeview_selection_folders_changed(self, widget):
     """Set action sensitiveness on selection change"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     for widget in (self.ui.action_folders_remove,
                    self.ui.action_folders_properties,
                    self.ui.action_files_new):
         widget.set_sensitive(bool(selected_row))
     if not selected_row:
         self.ui.action_files_new.set_sensitive(False)
         self.ui.action_files_remove.set_sensitive(False)
         self.ui.action_files_save.set_sensitive(False)
         self.model_applications.clear()
Exemplo n.º 10
0
 def on_treeview_selection_folders_changed(self, widget):
     """Set action sensitiveness on selection change"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     for widget in (self.ui.action_folders_remove,
                    self.ui.action_folders_properties,
                    self.ui.action_files_new):
         widget.set_sensitive(bool(selected_row))
     if not selected_row:
         self.ui.action_files_new.set_sensitive(False)
         self.ui.action_files_remove.set_sensitive(False)
         self.ui.action_files_save.set_sensitive(False)
         self.model_applications.clear()
Exemplo n.º 11
0
 def on_action_folders_properties_activate(self, action):
     """Set the AppFolder properties"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         name = self.model_folders.get_key(selected_row)
         title = self.model_folders.get_title(selected_row)
         dialog = UICreateAppFolder(self.ui.win_main,
                                    self.model_folders.rows.keys())
         if dialog.show(name=name, title=title) == Gtk.ResponseType.OK:
             folder_name = dialog.folder_name
             folder_title = dialog.folder_title
             # Update the folder title
             folder_info = self.folders[folder_name]
             folder_info.name = folder_title
             folder_info.set_title(folder_title)
             # Reload the folders list and select the folder again
             self.reload_folders()
             self.ui.treeview_folders.set_cursor(
                 self.model_folders.get_path_by_name(folder_name))
         dialog.destroy()
Exemplo n.º 12
0
 def on_action_folders_properties_activate(self, action):
     """Set the AppFolder properties"""
     selected_row = get_treeview_selected_row(self.ui.treeview_folders)
     if selected_row:
         name = self.model_folders.get_key(selected_row)
         title = self.model_folders.get_title(selected_row)
         dialog = UICreateAppFolder(self.ui.win_main,
                                    self.model_folders.rows.keys())
         if dialog.show(name=name, title=title) == Gtk.ResponseType.OK:
             folder_name = dialog.folder_name
             folder_title = dialog.folder_title
             # Update the folder title
             folder_info = self.folders[folder_name]
             folder_info.name = folder_title
             folder_info.set_title(folder_title)
             # Reload the folders list and select the folder again
             self.reload_folders()
             self.ui.treeview_folders.set_cursor(
                 self.model_folders.get_path_by_name(folder_name))
         dialog.destroy()
Exemplo n.º 13
0
 def on_treeview_selection_applications_changed(self, widget):
     """Set action sensitiveness on selection change"""
     selected_row = get_treeview_selected_row(self.ui.treeview_applications)
     self.ui.action_files_remove.set_sensitive(bool(selected_row))
Exemplo n.º 14
0
 def on_treeview_selection_applications_changed(self, widget):
     """Set action sensitiveness on selection change"""
     selected_row = get_treeview_selected_row(self.ui.treeview_applications)
     self.ui.action_files_remove.set_sensitive(bool(selected_row))