Skip to content

Commit

Permalink
Selection optionsbar: show copy/cut/del instead of import/paste (mobile)
Browse files Browse the repository at this point in the history
the familiarity with icons makes much sense this way

+ show the "selection options" label to avoid confusion between the 2 menus (desktop)
  • Loading branch information
maoschanz committed Jan 1, 2023
1 parent f37a21f commit 3756f99
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 95 deletions.
162 changes: 75 additions & 87 deletions src/optionsbars/selection/optionsbar-selection.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,82 +6,66 @@
<property name="expand">True</property>

<child>
<object class="GtkBox" id="import_box_narrow">
<object class="GtkBox" id="import_box">
<property name="visible">True</property>
<style><class name="linked"/></style>
<child>
<object class="GtkButton">
<property name="action_name">win.import</property>
<property name="tooltip-text" translatable="yes">Import</property>
<property name="label" translatable="yes">Import</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">insert-image-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action_name">win.paste</property>
<property name="tooltip-text" translatable="yes">Paste</property>
<property name="label" translatable="yes">Paste</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-paste-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="clipboard_box">
<property name="visible">True</property>
<style><class name="linked"/></style>
<child>
<object class="GtkMenuButton" id="actions_btn_long">
<object class="GtkButton">
<property name="action_name">win.selection_delete</property>
<property name="tooltip-text" translatable="yes">Delete</property>
<property name="visible">True</property>
<style><class name="suggested-action"/></style>
<property name="menu-model">actions-menu-long</property>
<child>
<object class="GtkBox">
<object class="GtkImage">
<property name="icon-name">edit-delete-symbolic</property>
<property name="visible">True</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
<property name="icon-name">system-run-symbolic</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">pan-down-symbolic</property>
<property name="visible">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>

<child>
<object class="GtkBox" id="import_box_long">
<property name="visible">True</property>
<style><class name="linked"/></style>
<child>
<object class="GtkButton">
<property name="action_name">win.import</property>
<property name="label" translatable="yes">Import</property>
<property name="action_name">win.selection_cut</property>
<property name="tooltip-text" translatable="yes">Cut</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-cut-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action_name">win.paste</property>
<property name="label" translatable="yes">Paste</property>
<property name="action_name">win.selection_copy</property>
<property name="tooltip-text" translatable="yes">Copy</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-copy-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
Expand Down Expand Up @@ -116,45 +100,28 @@
</child>

<child>
<object class="GtkBox" id="clipboard_box">
<object class="GtkMenuButton" id="actions_btn_long">
<property name="visible">True</property>
<style><class name="linked"/></style>
<child>
<object class="GtkButton">
<property name="action_name">win.selection_delete</property>
<property name="tooltip-text" translatable="yes">Delete</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-delete-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<style><class name="suggested-action"/></style>
<property name="menu-model">actions-menu-long</property>
<child>
<object class="GtkButton">
<property name="action_name">win.selection_cut</property>
<property name="tooltip-text" translatable="yes">Cut</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-cut-symbolic</property>
<property name="icon-name">system-run-symbolic</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action_name">win.selection_copy</property>
<property name="tooltip-text" translatable="yes">Copy</property>
<property name="visible">True</property>
<child>
<object class="GtkImage">
<property name="icon-name">edit-copy-symbolic</property>
<property name="icon-name">pan-down-symbolic</property>
<property name="visible">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>
Expand All @@ -163,13 +130,41 @@

<child>
<object class="GtkMenuButton" id="options_btn">
<property name="valign">center</property>
<property name="visible">True</property>
<property name="menu-model">options-menu</property>
<property name="tooltip-text" translatable="yes">Selection options</property>
<child>
<object class="GtkImage">
<property name="icon-name">view-more-symbolic</property>
<object class="GtkBox">
<property name="visible">True</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox" id="options_long_box">
<property name="visible">True</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Selection options</property>
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">pan-down-symbolic</property>
<property name="visible">True</property>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkImage" id="options_short_box">
<property name="icon-name">view-more-symbolic</property>
<property name="tooltip-text" translatable="yes">Selection options</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
Expand Down Expand Up @@ -253,19 +248,12 @@
<section>
<attribute name="display-hint">horizontal-buttons</attribute>
<item>
<attribute name="label" translatable="yes">Delete</attribute>
<attribute name="action">win.selection_delete</attribute>
<attribute name="verb-icon">edit-delete-symbolic</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Cut</attribute>
<attribute name="action">win.selection_cut</attribute>
<attribute name="verb-icon">edit-cut-symbolic</attribute>
<attribute name="label" translatable="yes">Import</attribute>
<attribute name="action">win.import</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Copy</attribute>
<attribute name="action">win.selection_copy</attribute>
<attribute name="verb-icon">edit-copy-symbolic</attribute>
<attribute name="label" translatable="yes">Paste</attribute>
<attribute name="action">win.paste</attribute>
</item>
</section>
<section>
Expand Down
20 changes: 12 additions & 8 deletions src/optionsbars/selection/optionsbar_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ def __init__(self, window):
self.window = window
builder = self._build_ui('selection/optionsbar-selection.ui')

self.import_box_narrow = builder.get_object('import_box_narrow')
self.import_box_long = builder.get_object('import_box_long')
self.import_box = builder.get_object('import_box')
self.clipboard_box = builder.get_object('clipboard_box')

self.actions_btn = builder.get_object('actions_btn')
self.actions_btn_long = builder.get_object('actions_btn_long')
self._togglable_btn = self.actions_btn

self.options_long_box = builder.get_object('options_long_box')
self.options_short_box = builder.get_object('options_short_box')

self.minimap_btn = builder.get_object('minimap_btn')
self.minimap_label = builder.get_object('minimap_label')
self.minimap_arrow = builder.get_object('minimap_arrow')
Expand All @@ -50,24 +51,27 @@ def middle_click_action(self):

def init_adaptability(self):
super().init_adaptability()
temp_limit_size = self.import_box_long.get_preferred_width()[0] + \
temp_limit_size = self.import_box.get_preferred_width()[0] + \
self.clipboard_box.get_preferred_width()[0] + \
self.actions_btn.get_preferred_width()[0] + \
self.options_btn.get_preferred_width()[0] + \
self.options_long_box.get_preferred_width()[0] + \
self.help_btn.get_preferred_width()[0] + \
self.minimap_btn.get_preferred_width()[0]
self._set_limit_size(temp_limit_size)

def set_compact(self, state):
super().set_compact(state)
self.import_box_narrow.set_visible(state)
self.import_box_long.set_visible(not state)
self.actions_btn_long.set_visible(state)
self.import_box.set_visible(not state)
self.actions_btn.set_visible(not state)
self.clipboard_box.set_visible(not state)

self.options_long_box.set_visible(not state)
self.options_short_box.set_visible(state)
if state:
self._togglable_btn = self.actions_btn_long
else:
self._togglable_btn = self.actions_btn

self.minimap_arrow.set_visible(not state)

############################################################################
Expand Down

0 comments on commit 3756f99

Please sign in to comment.