Exemple #1
0
 def setup(self):
     """
         Setup container
     """
     self.__widget = Handy.Leaflet()
     self.__widget.show()
     self.__sub_widget = Handy.Leaflet()
     self.__sub_widget.show()
     self.__focused_view = None
     self._stack = StackContainer()
     self._stack.show()
     ListsContainer.__init__(self)
     self.__progress = ProgressBar()
     self.__progress.get_style_context().add_class("progress-bottom")
     self.__progress.set_property("valign", Gtk.Align.END)
     self.add_overlay(self.__progress)
     search_action = App().lookup_action("search")
     search_action.connect("activate", self.__on_search_activate)
     self.__widget.add(self.sidebar)
     self.__grid_view = Grid()
     self.__grid_view.set_orientation(Gtk.Orientation.VERTICAL)
     self.__grid_view.show()
     self.__sub_widget.add(self.left_list)
     self.__sub_widget.add(self.__grid_view)
     self.__grid_view.attach(self._stack, 0, 0, 1, 1)
     self.__widget.add(self.__sub_widget)
     self.__widget.set_visible_child(self.__sub_widget)
     self.__sub_widget.set_visible_child(self.__grid_view)
     self.add(self.__widget)
     FilterContainer.__init__(self)
    def __init__(self, app, model):
        Gtk.ApplicationWindow.__init__(self,
                                       application=app,
                                       show_menubar=False)
        self.set_size_request(-1, 700)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_icon_name("org.gnome.tweaks")

        self.hsize_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)

        self.main_box = Handy.Leaflet()
        self.main_box.set_mode_transition_type(
            Handy.LeafletModeTransitionType.SLIDE)
        self.main_box.set_child_transition_type(
            Handy.LeafletChildTransitionType.SLIDE)

        left_box = self.sidebar()
        right_box = self.main_content()
        right_box.props.hexpand = True
        separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)

        self.menu_btn = Gtk.MenuButton()
        titlebar = self.titlebar()
        self.set_titlebar(titlebar)
        self._update_decorations()

        self.main_box.add(left_box)
        self.main_box.child_set(left_box, name="sidebar")
        self.main_box.add(separator)
        self.main_box.add(right_box)
        self.main_box.child_set(right_box, name="content")

        self.main_box.set_visible_child_name("sidebar")
        self.main_box.bind_property("visible-child-name", titlebar,
                                    "visible-child-name",
                                    GObject.BindingFlags.SYNC_CREATE)

        start_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        start_pane_size_group.add_widget(left_box)
        start_pane_size_group.add_widget(self._left_header)

        end_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        end_pane_size_group.add_widget(right_box)
        end_pane_size_group.add_widget(self._right_header)

        self.load_css()
        self._model = model
        self._model.load_tweaks(self)
        self.load_model_data()

        Gtk.Settings.get_default().connect("notify::gtk-decoration-layout",
                                           self._update_decorations)

        self.connect("key-press-event", self._on_key_press)
        self.connect_after("key-press-event", self._after_key_press)
        self.add(self.main_box)
Exemple #3
0
    def __init__(self, app):
        Gtk.ApplicationWindow.__init__(self,
                                       application=app,
                                       show_menubar=False)
        self.set_size_request(-1, 700)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_icon_name("com.magnifier.tweaks")

        self.hsize_group = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL)

        self.main_box = Handy.Leaflet()
        self.main_box.set_mode_transition_type(
            Handy.LeafletModeTransitionType.SLIDE)
        self.main_box.set_child_transition_type(
            Handy.LeafletChildTransitionType.SLIDE)

        titlebar = self.create_titlebar()

        self.set_titlebar(titlebar)
        self._update_decorations()

        sidebar = self.create_sidebar()
        content = self.create_content()
        content.props.hexpand = True

        self.main_box.add(sidebar)
        self.main_box.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL))
        self.main_box.add(content)
        self.main_box.child_set(sidebar, name="sidebar")
        self.main_box.child_set(content, name="content")
        self.main_box.set_visible_child_name("sidebar")
        self.main_box.bind_property("visible-child-name", titlebar,
                                    "visible-child-name",
                                    GObject.BindingFlags.SYNC_CREATE)

        start_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        start_pane_size_group.add_widget(sidebar)
        start_pane_size_group.add_widget(self._left_header)

        end_pane_size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
        end_pane_size_group.add_widget(content)
        end_pane_size_group.add_widget(self._right_header)

        widget = self.listbox.get_row_at_index(0)
        self.listbox.select_row(widget)

        Gtk.Settings.get_default().connect("notify::gtk-decoration-layout",
                                           self._update_decorations)
        self.connect("key-press-event", self._on_key_press)

        self.add(self.main_box)
Exemple #4
0
  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    self.set_icon_from_file("images/taskwarrior.png")
    self.set_wmclass("HandyTask", "HandyTask")

    # This will be in the windows group and have the "win" prefix
    # max_action = Gio.SimpleAction.new_stateful("maximize", None,
    #                                    GLib.Variant.new_boolean(False))
    # max_action.connect("change-state", self.on_maximize_toggle)
    # self.add_action(max_action)

    self.header = Handy.HeaderBar()
    self.header.set_title("HandyTask")
    self.back_button = Gtk.Button.new_from_icon_name("go-previous", Gtk.IconSize.BUTTON)
    # self.back_button.set_label("<")
    # self.back_button.set_image(
    #   Gtk.Image.new_from_icon_name("go-previous", Gtk.IconSize.BUTTON)
    # )
    self.back_button.connect("clicked", self.on_detail_cancel_clicked)
    self.header.pack_start(self.back_button)
    # self.back_button.show()

    # self.refresh_button = Gtk.ToolButton()
    # self.refresh_button.set_icon_name("view-refresh")
    self.refresh_button = Gtk.Button.new_from_icon_name("view-refresh", Gtk.IconSize.BUTTON)
    self.refresh_button.show()
    self.refresh_button.connect("clicked", self.on_refresh_clicked)
    self.header.pack_end(self.refresh_button)

    self.new_button = Gtk.Button.new_from_icon_name("appointment-new", Gtk.IconSize.BUTTON)
    self.new_button.connect("clicked", self.on_new_clicked)
    self.new_button.show()
    self.header.pack_end(self.new_button)

    self.set_titlebar(self.header)
    self.header.show()
    self.set_show_menubar(False)


    # Keep it in sync with the actual state
    # self.connect("notify::is-maximized",
    #                     lambda obj, pspec: max_action.set_state(
    #                                        GLib.Variant.new_boolean(obj.props.is_maximized)))

    # Allocate a universal taskwarrior instance
    self.tasks = TaskList(taskwarrior = TaskWarrior())

    # Responsive Box -> Stack transition
    # If there's enough width, we show the sidebar as a box (adjacent fields)
    # If not (see set_size_request in each of the children), Handy.Leaflet
    #   instead displays as a stack (one view at a time)
    self.multi_view = Handy.Leaflet(orientation = Gtk.Orientation.HORIZONTAL)
    self.add(self.multi_view)
    self.multi_view.show()

    # Allocate the task list view itself
    self.initial_selection = True
    self.task_view = TaskListView(
      tasks = self.tasks, 
      toggle = self.on_done_toggled,
      on_select = self.on_select_task
    )
    self.multi_view.add(self.task_view)
    self.task_view.show()

    self.multi_view.bind_property(
      "folded", 
      self.back_button, "visible",
      GObject.BindingFlags.SYNC_CREATE
    )

    self.multi_view.bind_property(
      "folded", 
      self.new_button, "visible",
      GObject.BindingFlags.SYNC_CREATE
    )

    # Allocate the task detail sidebar
    self.detail_view = TaskDetailView(
      on_save = self.on_detail_save_clicked,
      on_cancel = self.on_detail_cancel_clicked,
      on_update_date = self.on_update_date
    )
    self.multi_view.add(self.detail_view)
    # self.detail_view.hide()
    self.detail_view.show()

    self.task_view.unselect()
    def titlebar(self):

        header = Handy.Leaflet()
        header.set_mode_transition_type(Handy.LeafletModeTransitionType.SLIDE)
        header.set_child_transition_type(
            Handy.LeafletChildTransitionType.SLIDE)
        header.connect("notify::visible-child", self._update_decorations)
        header.connect("notify::fold", self._update_decorations)

        left_header = Gtk.HeaderBar()
        left_header.props.show_close_button = True
        right_header = Gtk.HeaderBar()
        right_header.props.show_close_button = True
        right_header.props.hexpand = True

        self._left_header = left_header
        self._right_header = right_header

        left_header.get_style_context().add_class("titlebar")
        left_header.get_style_context().add_class("tweak-titlebar-left")
        right_header.get_style_context().add_class("titlebar")
        right_header.get_style_context().add_class("tweak-titlebar-right")

        self._group_titlebar_widget = None

        self.title = Gtk.Label(label="")
        self.title.get_style_context().add_class("title")
        right_header.set_custom_title(self.title)

        self.back_button = Gtk.Button.new_from_icon_name(
            "go-previous-symbolic", 1)
        self.back_button.connect("clicked", self._on_back_clicked)
        header.bind_property("folded", self.back_button, "visible")
        right_header.pack_start(self.back_button)

        icon = Gtk.Image()
        icon.set_from_icon_name("edit-find-symbolic", Gtk.IconSize.MENU)
        self.button = Gtk.ToggleButton()
        self.button.add(icon)
        self.button.connect("toggled", self._on_find_toggled)
        self.button.props.valign = Gtk.Align.CENTER
        self.button.get_style_context().add_class("image-button")
        left_header.pack_start(self.button)

        lbl = Gtk.Label(label=_("Tweaks"))
        lbl.get_style_context().add_class("title")
        left_header.set_custom_title(lbl)

        self.builder = Gtk.Builder()
        assert (os.path.exists(gtweak.PKG_DATA_DIR))
        filename = os.path.join(gtweak.PKG_DATA_DIR, 'shell.ui')
        self.builder.add_from_file(filename)

        appmenu = self.builder.get_object('appmenu')
        icon = Gtk.Image.new_from_gicon(
            Gio.ThemedIcon(name="open-menu-symbolic"), Gtk.IconSize.BUTTON)
        self.menu_btn.set_image(icon)
        self.menu_btn.set_menu_model(appmenu)
        left_header.pack_end(self.menu_btn)

        header.add(left_header)
        header.child_set(left_header, name="sidebar")
        header.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL))
        header.add(right_header)
        header.child_set(right_header, name="content")

        self.header_group = Handy.HeaderGroup()
        self.header_group.add_header_bar(left_header)
        self.header_group.add_header_bar(right_header)

        self.hsize_group.add_widget(left_header)

        return header
Exemple #6
0
    def create_titlebar(self):
        self._group_titlebar_widget = None

        header = Handy.Leaflet()
        header.set_mode_transition_type(Handy.LeafletModeTransitionType.SLIDE)
        header.set_child_transition_type(
            Handy.LeafletChildTransitionType.SLIDE)
        header.connect("notify::visible-child", self._update_decorations)
        header.connect("notify::fold", self._update_decorations)

        lbl = Gtk.Label(label="Options")
        lbl.get_style_context().add_class("title")
        icon1 = Gtk.Image()
        icon1.set_from_icon_name("edit-find-symbolic", Gtk.IconSize.MENU)
        icon2 = Gtk.Image.new_from_gicon(
            Gio.ThemedIcon(name="open-menu-symbolic"), Gtk.IconSize.BUTTON)

        self.button = Gtk.ToggleButton()
        self.button.add(icon1)
        self.button.connect("toggled", self._on_find_toggled)
        self.button.props.valign = Gtk.Align.CENTER

        appmenu = Gio.Menu()
        appmenu.append("About Magnifier Tweaks", "win.about")

        self.menu_btn = Gtk.MenuButton()
        self.menu_btn.set_image(icon2)
        self.menu_btn.set_menu_model(appmenu)

        left_header = Gtk.HeaderBar()
        left_header.props.show_close_button = True
        left_header.set_custom_title(lbl)
        left_header.pack_start(self.button)
        left_header.pack_end(self.menu_btn)
        self._left_header = left_header

        self.title = Gtk.Label(label="")

        self.back_button = Gtk.Button.new_from_icon_name(
            "go-previous-symbolic", 1)
        self.back_button.connect("clicked", self._on_back_clicked)

        right_header = Gtk.HeaderBar()
        right_header.props.show_close_button = True
        right_header.props.hexpand = True
        right_header.set_custom_title(self.title)
        right_header.pack_start(self.back_button)
        self._right_header = right_header

        header.add(left_header)
        header.add(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL))
        header.add(right_header)
        header.child_set(left_header, name="sidebar")
        header.child_set(right_header, name="content")

        header.bind_property("folded", self.back_button, "visible")

        self.header_group = Handy.HeaderGroup()
        self.header_group.add_header_bar(left_header)
        self.header_group.add_header_bar(right_header)

        self.hsize_group.add_widget(left_header)

        action_about = Gio.SimpleAction.new("about", None)
        action_about.connect("activate", self._on_activate_about)
        self.add_action(action_about)

        return header