Esempio n. 1
0
 def apply_styling_to_widget(self, wide=False):
     for bar in [self.get_vscrollbar(), self.get_hscrollbar()]:
         apply_colours_to_widget(bar)
         if wide:
             apply_styling_to_widget(bar, self.WIDE_CSS_PATH)
         else:
             apply_styling_to_widget(bar, self.NORMAL_CSS_PATH)
Esempio n. 2
0
    def __init__(self, text="", icon_filename=""):

        Gtk.Button.__init__(self)

        apply_colours_to_widget(self)

        self.internal_box = Gtk.Box(spacing=10)
        self.internal_box.props.halign = Gtk.Align.CENTER
        self.add(self.internal_box)

        if icon_filename:
            self.icon = Gtk.Image.new_from_file(icon_filename)
            self.internal_box.pack_start(self.icon, False, False, 0)
            self.label = Gtk.Label(text)
            self.internal_box.pack_start(self.label, False, False, 0)
        else:
            self.label = Gtk.Label(text)
            self.internal_box.add(self.label)

        cursor.attach_cursor_events(self)
Esempio n. 3
0
    def __init__(self, text="", icon_filename=""):

        Gtk.Button.__init__(self)

        apply_colours_to_widget(self)

        self.internal_box = Gtk.Box(spacing=10)
        self.internal_box.props.halign = Gtk.Align.CENTER
        self.add(self.internal_box)

        if icon_filename:
            self.icon = Gtk.Image.new_from_file(icon_filename)
            self.internal_box.pack_start(self.icon, False, False, 0)
            self.label = Gtk.Label(text)
            self.internal_box.pack_start(self.label, False, False, 0)
        else:
            self.label = Gtk.Label(text)
            self.internal_box.add(self.label)

        cursor.attach_cursor_events(self)
Esempio n. 4
0
    def __init__(self, text="", color="green", icon_filename=""):

        # Keep this updated - useful for set_color function
        self.available_colors = ["orange", "green", "red", "grey", "blue"]

        # Create button
        GenericButton.__init__(self, text, icon_filename)

        style_context = self.get_style_context()
        style_context.add_class("kano_button")
        style_context.add_class("kano_button_padding")
        style_context.add_class(color + "_background")

        self.align = None
        cursor.attach_cursor_events(self)

        self.add_spinner()

        widgets = [self, self.label]
        for w in widgets:
            apply_colours_to_widget(w)
            apply_styling_to_widget(w, self.BUTTON_CSS)
Esempio n. 5
0
    def __init__(self, text="", color="green", icon_filename=""):

        # Keep this updated - useful for set_color function
        self.available_colors = ["orange", "green", "red", "grey", "blue"]

        # Create button
        GenericButton.__init__(self, text, icon_filename)

        style_context = self.get_style_context()
        style_context.add_class("kano_button")
        style_context.add_class("kano_button_padding")
        style_context.add_class(color + "_background")

        self.align = None
        cursor.attach_cursor_events(self)

        self.add_spinner()

        widgets = [self, self.label]
        for w in widgets:
            apply_colours_to_widget(w)
            apply_styling_to_widget(w, self.BUTTON_CSS)
Esempio n. 6
0
    def __init__(
        self,
        title_text="",
        description_text="",
        button_dict=None,
        widget=None,
        has_entry=False,
        has_list=False,
        scrolled_text="",
        global_style="",
        parent_window=None,
        orange_info=None,
        hide_from_taskbar=False,
    ):

        self.title_text = title_text
        self.description_text = description_text
        self.widget = widget
        self.button_info = button_dict
        self.returnvalue = 0
        self.has_entry = has_entry
        self.has_list = has_list
        self.scrolled_text = scrolled_text
        self.global_style = global_style
        self.parent_window = parent_window
        self.orange_info = orange_info

        self.dialog = Gtk.Dialog()
        self.dialog.set_decorated(False)
        self.dialog.set_resizable(False)

        # TODO: review this - should this always be set?
        # self.dialog.set_keep_above(True)
        self.dialog.set_skip_taskbar_hint(hide_from_taskbar)
        self.dialog.set_border_width(5)

        apply_styling_to_widget(self.dialog, self.CSS_PATH)
        apply_colours_to_widget(self.dialog)

        # if widget or an orange button is added, to get styling correct
        # the global_styling property should be on.
        # TODO: is this needed any more?
        if global_style or (widget is not None or orange_info is not None):
            apply_common_to_screen()

        content_area, action_area = self.__colour_dialog_background()

        self.title = Heading(self.title_text, self.description_text)
        content_area.pack_start(self.title.container, False, False, 0)

        # If button_info is None, or an empty dictionary or list, default to an OK button
        if not self.button_info:
            button_defaults["label"] = _("OK")
            self.button_info = [button_defaults]

        # convert button dictionary to list
        if isinstance(self.button_info, dict):
            self.__convert_dict_to_list()

        kano_button_box = self.__generate_buttons()

        if orange_info is not None:
            button_container = self.__add_orange_button(orange_info, kano_button_box)
        else:
            button_container = Gtk.Alignment()
            button_container.add(kano_button_box)
            # annoying uneven alignment - cannot seem to centre y position
            button_container.set_padding(6, 3, 0, 0)

        action_area.pack_start(button_container, False, False, 0)

        # Add scrolled window
        if self.scrolled_text:
            scrolledwindow = self.__add_scrolled_window()
            content_area.pack_start(scrolledwindow, False, False, 0)

        # or add widget
        elif self.widget is not None:
            content_area.pack_start(self.widget, False, False, 0)

        # Set keyboard focus on first button if no entry
        if not has_entry:
            self.buttons[0].grab_focus()
Esempio n. 7
0
    def __init__(self,
                 title_text="",
                 description_text="",
                 button_dict=None,
                 widget=None,
                 has_entry=False,
                 has_list=False,
                 scrolled_text="",
                 global_style="",
                 parent_window=None,
                 orange_info=None,
                 hide_from_taskbar=False):

        self.title_text = title_text
        self.description_text = description_text
        self.widget = widget
        self.button_info = button_dict
        self.returnvalue = 0
        self.has_entry = has_entry
        self.has_list = has_list
        self.scrolled_text = scrolled_text
        self.global_style = global_style
        self.parent_window = parent_window
        self.orange_info = orange_info

        self.dialog = Gtk.Dialog()
        self.dialog.set_decorated(False)
        self.dialog.set_resizable(False)

        # TODO: review this - should this always be set?
        # self.dialog.set_keep_above(True)
        self.dialog.set_skip_taskbar_hint(hide_from_taskbar)
        self.dialog.set_border_width(5)

        apply_styling_to_widget(self.dialog, self.CSS_PATH)
        apply_colours_to_widget(self.dialog)

        # if widget or an orange button is added, to get styling correct
        # the global_styling property should be on.
        # TODO: is this needed any more?
        if global_style or (widget is not None or orange_info is not None):
            apply_common_to_screen()

        content_area, action_area = self.__colour_dialog_background()

        self.title = Heading(self.title_text, self.description_text)
        content_area.pack_start(self.title.container, False, False, 0)

        # If button_info is None, or an empty dictionary or list, default to an OK button
        if not self.button_info:
            button_defaults['label'] = _("OK")
            self.button_info = [button_defaults]

        # convert button dictionary to list
        if isinstance(self.button_info, dict):
            self.__convert_dict_to_list()

        kano_button_box = self.__generate_buttons()

        if orange_info is not None:
            button_container = self.__add_orange_button(
                orange_info, kano_button_box)
        else:
            button_container = Gtk.Alignment()
            button_container.add(kano_button_box)
            # annoying uneven alignment - cannot seem to centre y position
            button_container.set_padding(6, 3, 0, 0)

        action_area.pack_start(button_container, False, False, 0)

        # Add scrolled window
        if self.scrolled_text:
            scrolledwindow = self.__add_scrolled_window()
            content_area.pack_start(scrolledwindow, False, False, 0)

        # or add widget
        elif self.widget is not None:
            content_area.pack_start(self.widget, False, False, 0)

        # Set keyboard focus on first button if no entry
        if not has_entry:
            self.buttons[0].grab_focus()

        # Brings the focus back to the default button (OK) "hacky"
        if isinstance(self.widget, Gtk.Entry):

            def entry_activated(w):
                self.returnvalue = self.widget.get_text()
                self.dialog.response(Gtk.ResponseType.OK)

            self.widget.connect('activate', entry_activated)