diff options
-rw-r--r-- | src/cat_mode/mime_editor_cat_mode.py | 3 | ||||
-rw-r--r-- | src/cat_mode/mime_view_cat_mode.py | 17 | ||||
-rw-r--r-- | src/common/gtk_common.py | 2 | ||||
-rw-r--r-- | src/common/mime_view.py | 15 |
4 files changed, 19 insertions, 18 deletions
diff --git a/src/cat_mode/mime_editor_cat_mode.py b/src/cat_mode/mime_editor_cat_mode.py index 37ab448..fcd1ed8 100644 --- a/src/cat_mode/mime_editor_cat_mode.py +++ b/src/cat_mode/mime_editor_cat_mode.py @@ -244,7 +244,7 @@ class MimeSetDialog: for path in pathlist : tree_iter = model.get_iter(path) value = model.get_value(tree_iter, self.APP_OBJ) - self.selection = value + selection = value self.hide() self.on_dialog_ok(selection, self.mtypes) @@ -306,6 +306,7 @@ class MainWidget: self.mime_view.filter_category(category_id[0]) def on_mtypes_edit_ok(self, app, mtypes): + #print(app) if app is not None: mime_operations.set_app_default(app, mtypes) self.mime_view.update_data(mtypes) diff --git a/src/cat_mode/mime_view_cat_mode.py b/src/cat_mode/mime_view_cat_mode.py index c189b66..7b6edd1 100644 --- a/src/cat_mode/mime_view_cat_mode.py +++ b/src/cat_mode/mime_view_cat_mode.py @@ -101,19 +101,14 @@ class MimeViewCategories(mime_view.MimeView): def update_data(self, mtypes_to_change): - tree_iter = self.list_store.get_iter_first() + for model, tree_iter in self.iterate_by_values(self.MIME_TYPE, mtypes_to_change): + row_mtype = self.list_store.get_value(tree_iter, self.MIME_TYPE) - while tree_iter: - row_mtype = self.list_store.get_value(tree_iter, self.MTYPE) + app = mime_operations.get_default_app(row_mtype) + name, icon, *extra = mime_operations.get_app_bio(app, ICON_SIZE) - if row_mtype in mtypes_to_change: - app = mime_operations.get_default_app(row_mtype) - name, icon, *extra = mime_operations.get_app_bio(app, ICON_SIZE) - - self.list_store.set_value(tree_iter, self.APP, name) - self.list_store.set_value(tree_iter, self.APP_IMG, icon) - - tree_iter = self.list_store.iter_next(tree_iter) + self.list_store.set_value(tree_iter, self.MIME_APP, name) + self.list_store.set_value(tree_iter, self.MIME_APP_IMG, icon) def filter_associated(self, show_all = True): self.set_filter_params("associated_filter", diff --git a/src/common/gtk_common.py b/src/common/gtk_common.py index 87fe1bc..5703cc6 100644 --- a/src/common/gtk_common.py +++ b/src/common/gtk_common.py @@ -60,8 +60,6 @@ class TextColumn(Gtk.TreeViewColumn): self.set_resizable(True) - - def set_attribute(self, name, model_column): for renderer in self.cell_renderers: self.add_attribute(renderer, name, model_column) diff --git a/src/common/mime_view.py b/src/common/mime_view.py index 79902c2..85d5880 100644 --- a/src/common/mime_view.py +++ b/src/common/mime_view.py @@ -194,6 +194,13 @@ class MimeView: tree_iter = self.list_store.get_iter(self.get_store_path(path)) yield self.list_store, tree_iter + def iterate_by_values(self, column, values): + tree_iter = self.list_store.get_iter_first() + while tree_iter: + val = self.list_store.get_value(tree_iter, column) + if val in values: + yield self.list_store, tree_iter + tree_iter = self.list_store.iter_next(tree_iter) def set_value_if_cond(self, model, tree_iter, column, get_value_func = None, value = None, @@ -214,7 +221,7 @@ class MimeView: def set_value_to_all(self, column, get_value_func = None, value = None, conditions_func = None, **kwargs): - + for (model, iter_) in self.iterate_all(): self.set_value_if_cond(model, iter_, column, get_value_func, value, @@ -224,17 +231,17 @@ class MimeView: def set_value_to_selected(self, column, get_value_func = None, value = None, conditions_func = None, **kwargs): - + for (model, iter_) in self.iterate_selected(): self.set_value_if_cond(model, iter_, column, get_value_func, value, conditions_func, **kwargs) - + def set_value_to_visible(self, column, get_value_func = None, value = None, conditions_func = None, **kwargs): - + for (model, iter_) in self.iterate_visible(): self.set_value_if_cond(model, iter_, column, get_value_func, value, |