def click_toggle_button(widget): global store global main_view print(toggletoolbutton.get_active()) print(main_view) if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store() if toggletoolbutton.get_active(): main_view = create_icon_view() else: main_view = create_list_view()
def on_double_click_list(widget, path, column): global CURRENT_DIRECTORY model = widget.get_model() file_name = model[path][1] file_is_dir = model[path][2] if file_is_dir: if CURRENT_DIRECTORY == '/': CURRENT_DIRECTORY = CURRENT_DIRECTORY + file_name else: CURRENT_DIRECTORY = CURRENT_DIRECTORY + '/' + file_name else: if CURRENT_DIRECTORY == '/': current_file = CURRENT_DIRECTORY + file_name else: current_file = CURRENT_DIRECTORY + '/' + file_name subprocess.call(['xdg-open', current_file]) if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store() tool_button_up.set_sensitive(True) tool_button_back.set_sensitive(True) path_list.append(CURRENT_DIRECTORY) global path_index path_index += 1 print(path_list, path_index)
def click_home_button(widget): global CURRENT_DIRECTORY if CURRENT_DIRECTORY == '/home/hell_abhi': return CURRENT_DIRECTORY = os.path.realpath(os.path.expanduser('~')) if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store() tool_button_up.set_sensitive(True) tool_button_back.set_sensitive(True) path_list.append(CURRENT_DIRECTORY) global path_index path_index += 1 print(path_list, path_index)
def click_forward_button(widget): global path_index if path_index == len(path_list) - 1: widget.set_sensitive(False) return path_index += 1 print(path_list, path_index) tool_button_back.set_sensitive(True) global CURRENT_DIRECTORY CURRENT_DIRECTORY = path_list[path_index] if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store() if CURRENT_DIRECTORY == '/': tool_button_up.set_sensitive(False)
def click_up_button(widget): global CURRENT_DIRECTORY CURRENT_DIRECTORY = os.path.dirname(CURRENT_DIRECTORY) path_list.append(CURRENT_DIRECTORY) global path_index path_index += 1 print(path_list, path_index) if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store() sensitive = True if CURRENT_DIRECTORY == '/': sensitive = False widget.set_sensitive(sensitive) if sensitive: tool_button_back.set_sensitive(True)
def __init__(self): # creating window Gtk.Window.__init__(self, title="File Manager") self.set_size_request(800, 600) self.set_position(Gtk.WindowPosition.CENTER) vertical_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(vertical_box) menu_bar = create_menu_bar() vertical_box.pack_start(menu_bar, False, False, 0) tool_bar = create_tool_bar() vertical_box.pack_start(tool_bar, False, False, 0) horizontal_box = Gtk.Box() vertical_box.pack_start(horizontal_box, True, True, 0) side_bar = create_side_bar() horizontal_box.pack_start(side_bar, False, True, 0) horizontal_box.set_halign(Gtk.Align.START) global main_view if toggletoolbutton.get_active(): main_view = create_icon_view() else: main_view = create_list_view() #list_view.set_hexpand (True) #list_view.set_vexpand (True) scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(main_view) #scrolled_window.set_min_content_width(1000) scrolled_window.set_policy( hscrollbar_policy=Gtk.PolicyType.NEVER, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC ) horizontal_box.pack_start(scrolled_window, True, True, 0)
def populate_main_store(): if (toggletoolbutton.get_active()): populate_icon_store() else: populate_list_store()