Skip to content

Commit f7a9349

Browse files
committed
gmoccapy: add toggle button "sort by date" TODO: add settings for sort mode
1 parent d86c9e1 commit f7a9349

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"/>
@@ -8031,6 +8031,22 @@ tool z</property>
80318031
<property name="position">5</property>
80328032
</packing>
80338033
</child>
8034+
<child>
8035+
<object class="GtkToggleButton" id="tbtn_sort">
8036+
<property name="label" translatable="yes">Sort by
8037+
date</property>
8038+
<property name="visible">True</property>
8039+
<property name="can-focus">True</property>
8040+
<property name="receives-default">True</property>
8041+
<property name="tooltip-text" translatable="yes">Sort files by date, newest first</property>
8042+
<signal name="toggled" handler="on_tbtn_sort_toggled" swapped="no"/>
8043+
</object>
8044+
<packing>
8045+
<property name="expand">True</property>
8046+
<property name="fill">True</property>
8047+
<property name="position">6</property>
8048+
</packing>
8049+
</child>
80348050
<child>
80358051
<object class="GtkLabel" id="lbl_space_11">
80368052
<property name="width-request">90</property>
@@ -8041,7 +8057,7 @@ tool z</property>
80418057
<packing>
80428058
<property name="expand">False</property>
80438059
<property name="fill">False</property>
8044-
<property name="position">6</property>
8060+
<property name="position">7</property>
80458061
</packing>
80468062
</child>
80478063
<child>
@@ -8059,19 +8075,6 @@ tool z</property>
80598075
<property name="image-position">top</property>
80608076
<signal name="clicked" handler="on_btn_select_clicked" swapped="no"/>
80618077
</object>
8062-
<packing>
8063-
<property name="expand">False</property>
8064-
<property name="fill">False</property>
8065-
<property name="position">7</property>
8066-
</packing>
8067-
</child>
8068-
<child>
8069-
<object class="GtkLabel" id="lbl_space_12">
8070-
<property name="width-request">90</property>
8071-
<property name="height-request">56</property>
8072-
<property name="visible">True</property>
8073-
<property name="can-focus">False</property>
8074-
</object>
80758078
<packing>
80768079
<property name="expand">False</property>
80778080
<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)