예제 #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)
예제 #2
0
    def __init__(self, text=""):

        # Create button
        GenericButton.__init__(self, text)
        apply_styling_to_widget(self, self.button_css)
        apply_styling_to_widget(self.label, self.button_css)
        self.get_style_context().add_class('small_white_button')
예제 #3
0
    def __init__(self, text=""):

        # Create button
        GenericButton.__init__(self, text)
        apply_styling_to_widget(self, self.button_css)
        apply_styling_to_widget(self.label, self.button_css)
        self.get_style_context().add_class('small_white_button')
예제 #4
0
    def __init__(self, text=""):

        # Create button
        GenericButton.__init__(self, text)
        apply_styling_to_widget(self, self.BUTTON_CSS)
        apply_styling_to_widget(self.label, self.BUTTON_CSS)

        self.get_style_context().add_class("small_orange_button")
예제 #5
0
    def __init__(self, text=""):

        # Create button
        GenericButton.__init__(self, text)
        apply_styling_to_widget(self, self.BUTTON_CSS)
        apply_styling_to_widget(self.label, self.BUTTON_CSS)

        self.get_style_context().add_class("small_orange_button")
예제 #6
0
    def __init__(self):
        Gtk.Overlay.__init__(self)

        self._loading = False

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._spinner = Gtk.Spinner()
        self._spinner.props.active = True
        apply_styling_to_widget(self._spinner, KanoButton.SPINNER_CSS)
예제 #7
0
    def __init__(self):
        Gtk.Overlay.__init__(self)

        self._loading = False

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._spinner = Gtk.Spinner()
        self._spinner.props.active = True
        apply_styling_to_widget(self._spinner, KanoButton.SPINNER_CSS)
예제 #8
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)
예제 #9
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)
예제 #10
0
 def add_spinner(self):
     self.spinner = Gtk.Spinner()
     self.spinner.props.active = True
     self.is_spinning = False
     apply_styling_to_widget(self.spinner, self.SPINNER_CSS)
예제 #11
0
    def _initialise_window(self):
        '''
        Inititlaises the gtk window
        '''
        self.last_click = 0

        self.app_name_opened = 'feedback-widget-opened'
        self.typeahead = None
        self.help_tip_message = 'Type your feedback here!'

        self.rotating_mode = True
        self.in_submit = False

        apply_styling_to_screen(media_dir() + 'css/widget.css')

        ScrolledWindow.apply_styling_to_screen(wide=False)

        self.visible = False
        self.set_hexpand(False)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_keep_above(False)
        self.set_property('skip-taskbar-hint', True)

        self._grid = grid = Gtk.Grid(hexpand=True, vexpand=True)

        qmark = Gtk.Label('?')
        qmark.get_style_context().add_class('qmark')

        qmark_centering = Gtk.Alignment(xalign=0.5, yalign=0.5)
        qmark_centering.add(qmark)

        qmark_box = Gtk.EventBox()
        qmark_box.get_style_context().add_class('qmark_box')
        qmark_box.add(qmark_centering)
        qmark_box.set_size_request(self.HEIGHT_COMPACT, self.HEIGHT_COMPACT)

        grid.attach(qmark_box, 0, 0, 1, 1)

        self._prompt = prompt = Gtk.Label(self.wprompts.get_current_prompt(),
                                          hexpand=False)
        prompt.get_style_context().add_class('prompt')
        prompt.set_justify(Gtk.Justification.LEFT)
        prompt.set_alignment(0.1, 0.5)
        prompt.set_size_request(410, -1)
        prompt.set_line_wrap(True)

        prompt_container = Gtk.Table(1, 1, False)
        prompt_container.attach(prompt, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)

        grid.attach(prompt_container, 1, 0, 2, 1)

        self._x_button = x_button = Gtk.Button('x')
        x_button.set_size_request(20, 20)
        x_button.connect('clicked', self._shrink)
        x_button.get_style_context().add_class('x_button')
        x_button.set_margin_right(20)

        x_button_ebox = Gtk.EventBox()
        x_button_ebox.add(x_button)
        x_button_ebox.connect("realize", self._set_cursor_to_hand_cb)

        x_button_align = Gtk.Alignment(xalign=1, yalign=0.5,
                                       xscale=0, yscale=0)
        x_button_align.add(x_button_ebox)

        grid.attach(x_button_align, 3, 0, 1, 1)

        self._gray_box = gray_box = Gtk.EventBox()
        gray_box.get_style_context().add_class('gray_box')
        gray_box.set_size_request(-1,
                                  self.HEIGHT_EXPANDED - self.HEIGHT_COMPACT)

        gray_box_centering = Gtk.Alignment(xalign=0, yalign=0, xscale=1.0,
                                           yscale=1.0)
        gray_box_centering.add(gray_box)

        grid.attach(gray_box_centering, 0, 1, 1, 2)

        self._ebox = Gtk.EventBox()
        self._ebox.get_style_context().add_class('scrolled_win')
        grid.attach(self._ebox, 1, 1, 2, 1)

        self._pack_input_widget()

        self._send = send = OrangeButton('SEND')
        apply_styling_to_widget(send.label, media_dir() + 'css/widget.css')
        send.set_sensitive(False)
        send.connect('clicked', self._send_clicked)
        send.set_margin_left(10)
        send.set_margin_right(20)
        send.set_margin_top(10)
        send.set_margin_bottom(15)
        send_align = Gtk.Alignment(xalign=1, yalign=0.5, xscale=0, yscale=0)
        send_align.add(send)

        grid.attach(send_align, 3, 2, 1, 1)

        self.set_main_widget(grid)
        self.show_all()

        self._dont_shrink = False
        self._shrink()

        self.connect("focus-out-event", self._shrink)
        self.connect("button-press-event", self._toggle)
예제 #12
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)
예제 #13
0
    def _initialise_window(self):
        '''
        Inititlaises the gtk window
        '''
        self.last_click = 0

        self.app_name_opened = 'feedback-widget-opened'
        self.typeahead = None
        self.help_tip_message = _("Type your feedback here!")

        self.rotating_mode = True
        self.in_submit = False

        apply_styling_to_screen(media_dir() + 'css/widget.css')

        ScrolledWindow.apply_styling_to_screen(wide=False)

        self.visible = False
        self.set_hexpand(False)
        self.set_decorated(False)
        self.set_resizable(False)
        self.set_keep_above(False)
        self.set_property('skip-taskbar-hint', True)

        self._grid = grid = Gtk.Grid(hexpand=True, vexpand=True)

        qmark = Gtk.Label('?')
        qmark.get_style_context().add_class('qmark')

        qmark_centering = Gtk.Alignment(xalign=0.5, yalign=0.5)
        qmark_centering.add(qmark)

        qmark_box = Gtk.EventBox()
        qmark_box.get_style_context().add_class('qmark_box')
        qmark_box.add(qmark_centering)
        qmark_box.set_size_request(self.HEIGHT_COMPACT, self.HEIGHT_COMPACT)

        grid.attach(qmark_box, 0, 0, 1, 1)

        self._prompt = prompt = Gtk.Label(self.wprompts.get_current_prompt(),
                                          hexpand=False)
        prompt.get_style_context().add_class('prompt')
        prompt.set_justify(Gtk.Justification.LEFT)
        prompt.set_size_request(410, -1)
        prompt.set_line_wrap(True)

        prompt_align = Gtk.Alignment(xalign=0.5, yalign=0.5)
        prompt_align.add(prompt)

        prompt_ebox = Gtk.EventBox()
        prompt_ebox.add(prompt_align)

        grid.attach(prompt_ebox, 1, 0, 2, 1)

        self._x_button = x_button = Gtk.Button('x')
        x_button.set_size_request(20, 20)
        x_button.connect('clicked', self._shrink)
        x_button.get_style_context().add_class('x_button')
        x_button.set_margin_right(20)

        x_button_ebox = Gtk.EventBox()
        x_button_ebox.add(x_button)
        x_button_ebox.connect("realize", self._set_cursor_to_hand_cb)

        x_button_align = Gtk.Alignment(xalign=1, yalign=0.5,
                                       xscale=0, yscale=0)
        x_button_align.add(x_button_ebox)

        grid.attach(x_button_align, 3, 0, 1, 1)

        self._gray_box = gray_box = Gtk.EventBox()
        gray_box.get_style_context().add_class('gray_box')
        gray_box.set_size_request(-1,
                                  self.HEIGHT_EXPANDED - self.HEIGHT_COMPACT)

        gray_box_centering = Gtk.Alignment(xalign=0, yalign=0, xscale=1.0,
                                           yscale=1.0)
        gray_box_centering.add(gray_box)

        grid.attach(gray_box_centering, 0, 1, 1, 2)

        self._ebox = Gtk.EventBox()
        self._ebox.get_style_context().add_class('scrolled_win')
        grid.attach(self._ebox, 1, 1, 2, 1)

        self._pack_input_widget()

        self._send = send = OrangeButton('SEND')
        apply_styling_to_widget(send.label, media_dir() + 'css/widget.css')
        send.set_sensitive(False)
        send.connect('clicked', self._send_clicked)
        send.set_margin_left(10)
        send.set_margin_right(20)
        send.set_margin_top(10)
        send.set_margin_bottom(15)
        send_align = Gtk.Alignment(xalign=1, yalign=0.5, xscale=0, yscale=0)
        send_align.add(send)

        grid.attach(send_align, 3, 2, 1, 1)

        self.set_main_widget(grid)
        self.show_all()

        self._dont_shrink = False
        self._shrink()

        self.connect("focus-out-event", self._shrink)
        self.connect("button-press-event", self._toggle)
예제 #14
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()
예제 #15
0
 def add_style(self, widget, app_class):
     apply_styling_to_widget(widget, self.CSS_PATH)
     style = widget.get_style_context()
     style.add_class(app_class)
예제 #16
0
 def add_spinner(self):
     self.spinner = Gtk.Spinner()
     self.spinner.props.active = True
     self.is_spinning = False
     apply_styling_to_widget(self.spinner, self.SPINNER_CSS)
예제 #17
0
 def add_style(self, widget, app_class):
     apply_styling_to_widget(widget, self.CSS_PATH)
     style = widget.get_style_context()
     style.add_class(app_class)