Esempio n. 1
0
    def on_button_press(self, w, e):
        
        if is_middle_click(e):
            self.add_to_tab(True)
            return

        if is_left_click(e):
            # on left click expand selected folders
            return
        
        if is_double_left_click(e):
            # on middle click play selected beans 
            self.add_to_tab()
            return
        
        if is_rigth_click(e):
            # on right click, show pop-up menu
            menu = Popup()
            menu.add_item(_("Add to current tab"), gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
            menu.add_item(_("Add to new tab"), gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
            menu.add_separator()
            menu.add_item(_("Add folder"), gtk.STOCK_OPEN, self.add_folder, None)
            menu.add_separator()

            if FC().tabs_mode == "Multi":
                menu.add_item(_("Add folder in new tab"), gtk.STOCK_OPEN, lambda : self.add_folder(True), None)
                menu.add_item(_("Clear Music Tree"), gtk.STOCK_CLEAR, lambda : self.controls.tabhelper.clear_tree(self.scroll), None)
            menu.add_item(_("Update Music Tree"), gtk.STOCK_REFRESH, lambda: self.controls.tabhelper.on_update_music_tree(self.scroll), None)
                
            menu.show(e)
Esempio n. 2
0
    def on_button_press(self, w, e):
        if is_middle_click(e):
            """to avoid unselect all selected items"""
            self.stop_emission('button-press-event')
        if is_left_click(e):
            # on left click expand selected folders
            return

        if is_double_left_click(e):
            # on middle click play selected beans
            self.add_to_tab()
            return

        if is_rigth_click(e):
            # on right click, show pop-up menu
            menu = Popup()
            menu.add_item(_("Append to playlist"), gtk.STOCK_ADD,
                          lambda: self.add_to_tab(True), None)
            menu.add_item(_("Open in new playlist"), gtk.STOCK_MEDIA_PLAY,
                          self.add_to_tab, None)
            menu.add_separator()
            menu.add_item(_("Add folder here"), gtk.STOCK_OPEN,
                          self.add_folder, None)
            menu.add_separator()

            if FC().tabs_mode == "Multi":
                menu.add_item(_("Add folder in new tab"), gtk.STOCK_OPEN,
                              lambda: self.add_folder(True), None)
                menu.add_item(
                    _("Clear"), gtk.STOCK_CLEAR,
                    lambda: self.controls.tabhelper.clear_tree(self.scroll),
                    None)
            menu.add_item(
                _("Update"), gtk.STOCK_REFRESH, lambda: self.controls.tabhelper
                .on_update_music_tree(self.scroll), None)

            f_model, f_t_paths = self.get_selection().get_selected_rows()
            if f_t_paths:
                model = f_model.get_model()
                t_paths = [
                    f_model.convert_child_path_to_path(f_t_path)
                    for f_t_path in f_t_paths
                ]
                row = model[t_paths[0]]
                paths = [model[t_path][self.path[0]] for t_path in t_paths]
                row_refs = [
                    gtk.TreeRowReference(model, t_path) for t_path in t_paths
                ]
                menu.add_separator()
                menu.add_item(_("Open in file manager"), None,
                              open_in_filemanager,
                              self.get_selected_bean().path)
                menu.add_item(_("Rename file (folder)"), None,
                              self.rename_files,
                              (row, self.path[0], self.text[0]))
                menu.add_item(
                    _("Delete file(s) / folder(s)"), None, self.delete_files,
                    (row_refs, paths, self.get_iter_from_row_reference))

            menu.show(e)
Esempio n. 3
0
    def on_button_press(self, w, e, tab_content=None):
        """there were two problems in the handler:
        1. when you click on eventbox, appears extra the signal from the notebook
        2. when double-clicking, the first click is handled"""

        if type(w) == Gtk.EventBox:
            self.stop_handling = True

            #add delay in the background

            def start_handling():
                self.stop_handling = False

            threading.Timer(0.3, start_handling).start()

        #Get rid of the parasitic signal
        if self.stop_handling and type(w) != Gtk.EventBox:
            return

        #handling of double middle click
        if is_double_middle_click(e) and type(w) == Gtk.EventBox:
            #this variable helps to ignore first click, when double-clicking
            self.val = False
            self.on_rename_tab(tab_content)

        #handling of middle click
        elif is_middle_click(e):
            self.val = True

            def midclick():
                if self.val:
                    if type(w) == Gtk.EventBox:
                        n = self.page_num(tab_content)
                        self.remove_page(n)
                    else:
                        self.empty_tab()

            #add delay in the background
            #for check (is second click or not)
            threading.Timer(0.5, midclick).start()

        #to show context menu
        elif is_rigth_click(e):
            if type(w) == Gtk.EventBox:
                w.menu.show_all()
                w.menu.popup(None, None, None, None, e.button, e.time)
Esempio n. 4
0
    def on_button_press(self, w, e):
        if is_empty_click(w, e):
            w.get_selection().unselect_all()
        if is_middle_click(e):
            """to avoid unselect all selected items"""
            self.stop_emission('button-press-event')
        if is_left_click(e):
            # on left click expand selected folders
            return

        if is_double_left_click(e):
            # on middle click play selected beans
            self.add_to_tab()
            return

        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)
            tabhelper = self.controls.perspectives.get_perspective('fs').get_tabhelper()
            # on right click, show pop-up menu
            self.tree_menu.clear()
            self.tree_menu.add_item(_("Append to playlist"), Gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
            self.tree_menu.add_item(_("Open in new playlist"), Gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
            self.tree_menu.add_separator()
            self.tree_menu.add_item(_("Add folder here"), Gtk.STOCK_OPEN, self.add_folder, None)
            self.tree_menu.add_separator()

            if FC().tabs_mode == "Multi":
                self.tree_menu.add_item(_("Add folder in new tab"), Gtk.STOCK_OPEN, lambda: self.add_folder(True), None)
                self.tree_menu.add_item(_("Clear"), Gtk.STOCK_CLEAR, lambda: tabhelper.clear_tree(self.scroll), None)
            self.tree_menu.add_item(_("Update"), Gtk.STOCK_REFRESH, lambda: tabhelper.on_update_music_tree(self.scroll), None)

            f_model, f_t_paths = self.get_selection().get_selected_rows()
            if f_t_paths:
                model = f_model.get_model()
                t_paths = [f_model.convert_child_path_to_path(f_t_path) for f_t_path in f_t_paths]
                row = model[t_paths[0]]
                paths = [model[t_path][self.path[0]] for t_path in t_paths]
                row_refs = [Gtk.TreeRowReference.new(model, t_path) for t_path in t_paths]
                self.tree_menu.add_separator()
                self.tree_menu.add_item(_("Open in file manager"), None, open_in_filemanager, self.get_selected_bean().path)
                self.tree_menu.add_item(_("Create folder"), None, self.create_folder, (model, f_t_paths[0], row))
                self.tree_menu.add_item(_("Rename file (folder)"), None, self.rename_files, (row, self.path[0], self.text[0]))
                self.tree_menu.add_item(_("Delete file(s) / folder(s)"), None, self.delete_files, (row_refs, paths, self.get_iter_from_row_reference))

            self.tree_menu.show(e)
Esempio n. 5
0
    def on_button_press(self, w, e):
        if is_empty_click(w, e):
            w.get_selection().unselect_all()
        if is_middle_click(e):
            """to avoid unselect all selected items"""
            self.stop_emission('button-press-event')
        if is_left_click(e):
            # on left click expand selected folders
            return

        if is_double_left_click(e):
            # on middle click play selected beans
            self.add_to_tab()
            return

        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)
            tabhelper = self.controls.perspectives.get_perspective('fs').get_tabhelper()
            # on right click, show pop-up menu
            self.tree_menu.clear()
            self.tree_menu.add_item(_("Append to playlist"), "list-add", lambda: self.add_to_tab(True), None)
            self.tree_menu.add_item(_("Open in new playlist"), "list-add", self.add_to_tab, None)
            self.tree_menu.add_separator()
            self.tree_menu.add_item(_("Add folder here"), "folder-open", self.add_folder, None)
            self.tree_menu.add_separator()

            if FC().tabs_mode == "Multi":
                self.tree_menu.add_item(_("Add folder in new tab"), "folder-open", lambda: self.add_folder(True), None)
                self.tree_menu.add_item(_("Clear"), "edit-clear", lambda: tabhelper.clear_tree(self.scroll), None)
            self.tree_menu.add_item(_("Update"), "view-refresh", lambda: tabhelper.on_update_music_tree(self.scroll), None)

            f_model, f_t_paths = self.get_selection().get_selected_rows()
            if f_t_paths:
                model = f_model.get_model()
                t_paths = [f_model.convert_child_path_to_path(f_t_path) for f_t_path in f_t_paths]
                row = model[t_paths[0]]
                paths = [model[t_path][self.path[0]] for t_path in t_paths]
                row_refs = [Gtk.TreeRowReference.new(model, t_path) for t_path in t_paths]
                self.tree_menu.add_separator()
                self.tree_menu.add_item(_("Open in file manager"), "system-file-manager", open_in_filemanager, self.get_selected_bean().path)
                self.tree_menu.add_item(_("Create folder"), "folder-new", self.create_folder, (model, f_t_paths[0], row))
                self.tree_menu.add_item(_("Rename file (folder)"), "edit-find-replace", self.rename_files, (row, self.path[0], self.text[0]))
                self.tree_menu.add_item(_("Delete file(s) / folder(s)"), "edit-delete", self.delete_files, (row_refs, paths, self.get_iter_from_row_reference))

            self.tree_menu.show(e)
Esempio n. 6
0
    def on_button_press(self, w, e, tab_content=None):
        """there were two problems in the handler:
        1. when you click on eventbox, appears extra the signal from the notebook
        2. when double-clicking, the first click is handled"""

        if type(w) == Gtk.EventBox:
            self.stop_handling = True
            #add delay in the background

            def start_handling():
                self.stop_handling = False
            threading.Timer(0.3, start_handling).start()

        #Get rid of the parasitic signal
        if self.stop_handling and type(w) != Gtk.EventBox:
            return

        #handling of double middle click
        if is_double_middle_click(e) and type(w) == Gtk.EventBox:
            #this variable helps to ignore first click, when double-clicking
            self.val = False
            self.on_rename_tab(tab_content)

        #handling of middle click
        elif is_middle_click(e):
            self.val = True

            def midclick():
                if self.val:
                    if type(w) == Gtk.EventBox:
                        n = self.page_num(tab_content)
                        self.remove_page(n)
                    else:
                        self.empty_tab()
            #add delay in the background
            #for check (is second click or not)
            threading.Timer(0.5, midclick).start()

        #to show context menu
        elif is_rigth_click(e):
            if type(w) == Gtk.EventBox:
                w.menu.show_all()
                w.menu.popup(None, None, None, None, e.button, e.time)
Esempio n. 7
0
 def on_button_press(self, w, e):
     if is_middle_click(e):
         self.controls.play_pause()
Esempio n. 8
0
 def on_button_press(self, w, e):
     if is_middle_click(e):
         self.controls.play_pause()