Verified Kaydet (Commit) 78f3e7ab authored tarafından Erdem Ersoy's avatar Erdem Ersoy

Fix actions after implement sorting (1/X)

* Fix "Install" menu item function
üst 12028b56
......@@ -163,24 +163,25 @@ class InstallWindow(object):
download_size_mib_str = ""
name = installed_ref.get_appdata_name()
GLib.idle_add(self.TreeModel.set_row,
self.TreeIter, [installed_ref_real_name,
installed_ref_arch,
installed_ref_branch,
installed_ref_remote,
installed_size_mib_str,
download_size_mib_str,
name],
tree_iter = self.TreeModel.convert_iter_to_child_iter(self.TreeIter)
tree_model = self.TreeModel.get_model()
GLib.idle_add(tree_model.set_row,
tree_iter, [installed_ref_real_name,
installed_ref_arch,
installed_ref_branch,
installed_ref_remote,
installed_size_mib_str,
download_size_mib_str,
name],
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
GLib.idle_add(self.Selection.unselect_iter,
self.TreeIter,
GLib.idle_add(self.Selection.unselect_all,
data=None,
priority=GLib.PRIORITY_DEFAULT)
time.sleep(0.2)
self.SearchFilter.refilter()
def install_progress_callback(self, transaction, operation, progress):
ref_to_install = Flatpak.Ref.parse(operation.get_ref())
ref_to_install_real_name = ref_to_install.get_name()
......
......@@ -44,7 +44,7 @@ class MainWindow(object):
self.Application = application
try:
main_gui_file = "/usr/share/pardus/pardus-flatpak-gui/ui/mainwindow.glade"
main_gui_file = "ui/mainwindow.glade"
main_builder = Gtk.Builder.new_from_file(main_gui_file)
main_builder.connect_signals(self)
except GLib.GError:
......@@ -207,6 +207,15 @@ class MainWindow(object):
self.SearchFilter = main_builder.get_object("SearchFilter")
self.SearchFilter.set_visible_func(self.search_filter_function)
self.SortModel = main_builder.get_object("SortModel")
self.SortModel.set_sort_func(0, self.sorting_compare_function, (self.TreeViewColumnRealName, 0))
self.SortModel.set_sort_func(1, self.sorting_compare_function, (self.TreeViewColumnArch, 1))
self.SortModel.set_sort_func(2, self.sorting_compare_function, (self.TreeViewColumnBranch, 2))
self.SortModel.set_sort_func(3, self.sorting_compare_function, (self.TreeViewColumnRemoteName, 3))
self.SortModel.set_sort_func(4, self.sorting_float_compare_function, (self.TreeViewColumnInstalledSize, 4))
self.SortModel.set_sort_func(5, self.sorting_float_compare_function, (self.TreeViewColumnDownloadSize, 5))
self.SortModel.set_sort_func(6, self.sorting_compare_function, (self.TreeViewColumnName, 6))
self.HeaderBarShowButton = main_builder.get_object("HeaderBarShowButton")
self.HeaderBarShowButton.set_label(_("Show Installed Apps"))
......@@ -251,6 +260,47 @@ class MainWindow(object):
else:
return False
def sorting_compare_function(self, tree_model_filter, row1, row2, data):
sorting_column, id_number = data
value1 = tree_model_filter.get_value(row1, id_number)
value2 = tree_model_filter.get_value(row2, id_number)
if value1 == "" and value2 == "":
return 0
elif value1 == "" and value2 != "":
return -1
elif value1 != "" and value2 == "":
return 1
if value1 < value2:
return -1
elif value1 == value2:
return 0
else:
return 1
def sorting_float_compare_function(self, tree_model_filter, row1, row2, data):
sorting_column, id_number = data
value1 = tree_model_filter.get_value(row1, id_number)[:-4]
value2 = tree_model_filter.get_value(row2, id_number)[:-4]
if value1 == "" and value2 == "":
return 0
elif value1 == "" and value2 != "":
return -1
elif value1 != "" and value2 == "":
return 1
value1_float = float(value1)
value2_float = float(value2)
if value1_float < value2_float:
return -1
elif value1_float == value2_float:
return 0
else:
return 1
def on_delete_main_window(self, widget, event):
widget.hide_on_delete()
......@@ -292,6 +342,9 @@ class MainWindow(object):
def on_search_changed(self, search_entry):
self.SearchFilter.refilter()
def on_resorted(self, tree_sortable):
self.SearchFilter.refilter()
def on_press_show_button(self, toggle_button):
self.SearchFilter.refilter()
......
......@@ -64,6 +64,10 @@ Author: Erdem Ersoy
<object class="GtkTreeModelFilter" id="SearchFilter">
<property name="child_model">ListStoreMain</property>
</object>
<object class="GtkTreeModelSort" id="SortModel">
<property name="model">SearchFilter</property>
<signal name="sort-column-changed" handler="on_resorted" swapped="no"/>
</object>
<object class="GtkImage" id="RunImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -219,7 +223,7 @@ Author: Erdem Ersoy
<object class="GtkTreeView" id="TreeViewMain">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">SearchFilter</property>
<property name="model">SortModel</property>
<property name="search_column">0</property>
<property name="activate_on_single_click">True</property>
<signal name="columns-changed" handler="on_columns_changed" swapped="no"/>
......@@ -235,6 +239,8 @@ Author: Erdem Ersoy
<property name="fixed_width">270</property>
<property name="title" translatable="yes">Real Name</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">0</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextRealName"/>
<attributes>
......@@ -248,6 +254,8 @@ Author: Erdem Ersoy
<property name="resizable">True</property>
<property name="title" translatable="yes">Arch</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">1</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextArch"/>
<attributes>
......@@ -261,6 +269,8 @@ Author: Erdem Ersoy
<property name="resizable">True</property>
<property name="title" translatable="yes">Branch</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">2</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextBranch"/>
<attributes>
......@@ -274,6 +284,8 @@ Author: Erdem Ersoy
<property name="resizable">True</property>
<property name="title" translatable="yes">Remote Name</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">3</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextRemoteName"/>
<attributes>
......@@ -287,6 +299,8 @@ Author: Erdem Ersoy
<property name="resizable">True</property>
<property name="title" translatable="yes">Installed Size</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">4</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextInstalledSize"/>
<attributes>
......@@ -300,6 +314,8 @@ Author: Erdem Ersoy
<property name="resizable">True</property>
<property name="title" translatable="yes">Download Size</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">5</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextDownloadSize"/>
<attributes>
......@@ -315,6 +331,8 @@ Author: Erdem Ersoy
<property name="fixed_width">80</property>
<property name="title" translatable="yes">Name</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_column_id">6</property>
<child>
<object class="GtkCellRendererText" id="CellRendererTextName"/>
<attributes>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment