Skip to content

Commit 8788e55

Browse files
committed
gmoccapy: add toggle button "sort by date" TODO: add settings for sort mode
1 parent 59ff19b commit 8788e55

2 files changed

Lines changed: 44 additions & 15 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.glade

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
<signal name="value-changed" handler="on_adj_width_popup_value_changed" swapped="no"/>
152152
</object>
153153
<object class="GtkAdjustment" id="adj_x_pos">
154-
<property name="upper">1024</property>
154+
<property name="upper">2500</property>
155155
<property name="value">40</property>
156156
<property name="step-increment">1</property>
157157
<signal name="value-changed" handler="on_adj_x_pos_value_changed" swapped="no"/>
@@ -7966,6 +7966,22 @@ tool z</property>
79667966
<property name="position">5</property>
79677967
</packing>
79687968
</child>
7969+
<child>
7970+
<object class="GtkToggleButton" id="tbtn_sort">
7971+
<property name="label" translatable="yes">Sort by
7972+
date</property>
7973+
<property name="visible">True</property>
7974+
<property name="can-focus">True</property>
7975+
<property name="receives-default">True</property>
7976+
<property name="tooltip-text" translatable="yes">Sort files by date, newest first</property>
7977+
<signal name="toggled" handler="on_tbtn_sort_toggled" swapped="no"/>
7978+
</object>
7979+
<packing>
7980+
<property name="expand">True</property>
7981+
<property name="fill">True</property>
7982+
<property name="position">6</property>
7983+
</packing>
7984+
</child>
79697985
<child>
79707986
<object class="GtkLabel" id="lbl_space_11">
79717987
<property name="width-request">90</property>
@@ -7976,7 +7992,7 @@ tool z</property>
79767992
<packing>
79777993
<property name="expand">False</property>
79787994
<property name="fill">False</property>
7979-
<property name="position">6</property>
7995+
<property name="position">7</property>
79807996
</packing>
79817997
</child>
79827998
<child>
@@ -7994,19 +8010,6 @@ tool z</property>
79948010
<property name="image-position">top</property>
79958011
<signal name="clicked" handler="on_btn_select_clicked" swapped="no"/>
79968012
</object>
7997-
<packing>
7998-
<property name="expand">False</property>
7999-
<property name="fill">False</property>
8000-
<property name="position">7</property>
8001-
</packing>
8002-
</child>
8003-
<child>
8004-
<object class="GtkLabel" id="lbl_space_12">
8005-
<property name="width-request">90</property>
8006-
<property name="height-request">56</property>
8007-
<property name="visible">True</property>
8008-
<property name="can-focus">False</property>
8009-
</object>
80108013
<packing>
80118014
<property name="expand">False</property>
80128015
<property name="fill">False</property>

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,19 @@ def _init_IconFileSelection(self):
24832483
for ext in file_ext:
24842484
filetypes += ext.replace("*.", "") + ","
24852485
self.widgets.IconFileSelection1.set_property("filetypes", filetypes)
2486+
# _ASCENDING = 0
2487+
# _DESCENDING = 1
2488+
# _FOLDERFIRST = 2
2489+
# _FILEFIRST = 3
2490+
self.widgets.IconFileSelection1.set_property("sortorder", 2)
2491+
# _DATE_NONE = 0
2492+
# _DATE_ALL = 1
2493+
# _DATE_FILESONLY = 2
2494+
self.widgets.IconFileSelection1.set_property("sortbydate", 2)
2495+
2496+
self.sort_by_date_filesonly = self.prefs.getpref("sort_by_date_filesonly", True, bool)
2497+
self.sort_by_date = self.prefs.getpref("sort_by_date", False, bool)
2498+
self.widgets.tbtn_sort.set_active(self.sort_by_date)
24862499

24872500
jump_to_dir = self.prefs.getpref("jump_to_dir", os.path.expanduser("~"), str)
24882501
self.widgets.jump_to_dir_chooser.set_current_folder(jump_to_dir)
@@ -5896,6 +5909,19 @@ def on_tbtn_switch_mode_toggled(self, widget, data=None):
58965909
self.widgets.tbtn_switch_mode.set_label(_("World\nmode"))
58975910
self._set_motion_mode(1)
58985911

5912+
def on_tbtn_sort_toggled(self, widget, data=None):
5913+
if widget.get_active():
5914+
# sortbydate: 0 = _DATE_NONE, 1 = _DATE_ALL, 2 = _DATE_FILESONLY
5915+
if self.sort_by_date_filesonly:
5916+
self.widgets.IconFileSelection1.set_property("sortbydate", 2)
5917+
else:
5918+
self.widgets.IconFileSelection1.set_property("sortbydate", 1)
5919+
else:
5920+
self.widgets.IconFileSelection1.set_property("sortbydate", 0)
5921+
5922+
self.sort_by_date = widget.get_active()
5923+
self.prefs.putpref("sort_by_date", self.sort_by_date)
5924+
58995925
def on_tbtn_split_view_toggled(self, widget, data=None):
59005926
if widget.get_active():
59015927
self.widgets.ntb_preview.show()

0 commit comments

Comments
 (0)