Skip to content

Commit

Permalink
use plus icon to open files
Browse files Browse the repository at this point in the history
  • Loading branch information
mijorus committed Jun 2, 2023
1 parent b32c2a6 commit 58e48eb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
2 changes: 2 additions & 0 deletions data/icons/hicolor/scalable/actions/plus-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 29 additions & 4 deletions src/GearleverWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, from_file=False, **kwargs):

self.titlebar = Adw.HeaderBar()
self.view_title_widget = Adw.ViewSwitcherTitle(stack=self.app_lists_stack)
self.left_button = Gtk.Button(icon_name='go-previous', visible=False)
self.left_button = Gtk.Button(icon_name='plus-symbolic')

menu_obj = Gtk.Builder.new_from_resource('/it/mijorus/gearlever/gtk/main-menu.xml')
self.menu_button = Gtk.MenuButton(icon_name='open-menu', menu_model=menu_obj.get_object('primary_menu'))
Expand Down Expand Up @@ -132,23 +132,28 @@ def on_selected_local_file(self, file: Gio.File) -> bool:

def on_show_installed_list(self, source: Gtk.Widget=None, data=None):
self.container_stack.set_transition_type(Gtk.StackTransitionType.SLIDE_RIGHT)
self.left_button.set_visible(False)

self.installed_apps_list.refresh_list()
self.container_stack.set_visible_child(self.app_lists_stack)

def on_left_button_clicked(self, widget):
if self.app_lists_stack.get_visible_child() == self.installed_stack:
if self.container_stack.get_visible_child() == self.app_details:
container_visible = self.container_stack.get_visible_child()
print(container_visible)

if container_visible == self.app_details:
self.titlebar.set_title_widget(self.view_title_widget)
self.on_show_installed_list()

elif container_visible == self.app_lists_stack:
self.on_open_file_chooser()

def on_app_lists_stack_change(self, widget, data):
pass

def on_container_stack_change(self, widget, data):
in_app_details = self.container_stack.get_visible_child() is self.app_details
self.left_button.set_visible(in_app_details)
self.left_button.set_icon_name('go-previous' if in_app_details else 'plus-symbolic')
self.view_title_widget.set_visible(not in_app_details)

def on_drop_event(self, widget, value, x, y):
Expand Down Expand Up @@ -181,5 +186,25 @@ def on_uninstalled_app(self, widget, data):

self.on_show_installed_list(widget, data)

def on_open_file_chooser_response(self, dialog, result):
try:
selected_file = dialog.open_finish(result)
except Exception as e:
logging.error(str(e))
return

if selected_file:
self.on_selected_local_file(selected_file)

def on_open_file_chooser(self):
print('qe')
dialog = Gtk.FileDialog(title=_('Open a file'),modal=True)

dialog.open(
parent=self,
cancellable=None,
callback=self.on_open_file_chooser_response
)

def on_close_request(self, widget):
appimage_provider.extraction_folder_cleanup()
4 changes: 0 additions & 4 deletions src/gtk/main-menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open Appimage File</attribute>
<attribute name="action">app.open_file</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Open Log File</attribute>
<attribute name="action">app.open_log_file</attribute>
Expand Down
25 changes: 1 addition & 24 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(self, version):
super().__init__(application_id=APP_ID, flags=Gio.ApplicationFlags.HANDLES_OPEN)
self.create_action('about', self.on_about_action)
self.create_action('preferences', self.on_preferences_action)
self.create_action('open_file', self.on_open_file_chooser)
self.create_action('open_log_file', self.on_open_log_file)
self.win = None
self.version = version
Expand All @@ -67,7 +66,7 @@ def do_activate(self, from_file=False):
if not self.win:
self.win = GearleverWindow(application=self, from_file=from_file)

if get_gsettings().get_boolean('first-run'):
if not get_gsettings().get_boolean('first-run'):
# get_gsettings().set_boolean('first-run', False)
tutorial = WelcomeScreen()
tutorial.present()
Expand Down Expand Up @@ -111,28 +110,6 @@ def create_action(self, name, callback, shortcuts=None):
if shortcuts:
self.set_accels_for_action(f"app.{name}", shortcuts)

def on_open_file_chooser_response(self, dialog, result):
try:
selected_file = dialog.open_finish(result)
except Exception as e:
logging.error(str(e))
return

if selected_file and isinstance(self.props.active_window, GearleverWindow):
self.props.active_window.on_selected_local_file(selected_file)

def on_open_file_chooser(self, widget, event):
if not self.win:
return

dialog = Gtk.FileDialog(title='Open a file',modal=True)

dialog.open(
parent=self.win,
cancellable=None,
callback=self.on_open_file_chooser_response
)

def on_open_log_file(self, widget, event):
if not self.win:
return
Expand Down

0 comments on commit 58e48eb

Please sign in to comment.