Example #1
0
 def __on_play_pause_button_toggled(self, button: Gtk.ToggleButton) -> None:
     if button.get_active():
         button.set_label("⏸")
         self.play_event.set()
     else:
         button.set_label("⏵")
         self.play_event.clear()
Example #2
0
        def __init__(
            self, tool_id: Any, tool_button: Gtk.ToggleButton,
            on_click: Callable[['ToolPanelView._ToolItemManager'],
                               Any]) -> None:
            self.tool_id = tool_id
            self._tool_button = tool_button
            self._on_click = on_click

            # Prevent the tool button from being toggled by user clicks, we only want to invoke the appropriate callback
            # when this happens. The toggled-ness of the button is managed by an outside object.
            tool_button.connect('button-press-event', lambda *_: True)

            tool_button.connect('button-release-event',
                                self._hdl_tool_button_clicked)
Example #3
0
    def toggle_bookmark(self, button: Gtk.ToggleButton) -> None:
        if self.is_updating:
            return

        months = [
            "Muharram", "Safar", "Rabi Al Awwal", "Rabi Al Akhar",
            "Jumada Al Ula", "Jumada Al Akhira", "Rajab", "Sha'aban",
            "Ramadan", "Shawwal", "Dhu Al Qa'da", "Dhu Al Hijja"
        ]
        date = HijriDate.today()

        # Format bookmark data
        bookmark = f'{glob.musshaf_name};{glob.page_number};'

        # Add/remove bookmark
        if button.get_active():
            bookmark += \
                f'Bookmarked on {date.day_name_en}, {months[date.month-1]} ' \
                f'{date.day}, {date.year}'
            glob.bookmark_names.append(bookmark)
        else:
            for bookmark_name in glob.bookmark_names:
                if bookmark_name.startswith(bookmark):
                    glob.bookmark_names.remove(bookmark_name)
                    break
Example #4
0
 def on_looped(self, button: Gtk.ToggleButton) -> None:
     glob.playback_loop = button.get_active()
     if glob.playback_loop:
         self.icon_toggle_loopback.set_from_icon_name(
             'media-playlist-repeat-symbolic', Gtk.IconSize.BUTTON)
     else:
         self.icon_toggle_loopback.set_from_icon_name(
             'media-playlist-consecutive-symbolic', Gtk.IconSize.BUTTON)
Example #5
0
    def _do_button_toggled(self, btn: Gtk.ToggleButton):
        """Handler for when a button is toggled.

        Emits `nvim-switch-buffer` if the button was toggled ON, and the widget
        isn't in the middle of an update.

        Also avoids toggling off buttons, since the user can't "unswitch" to a
        buffer.

        :btn: the toggled button.

        """
        if not self.props.updating:
            if btn.get_active():
                id = self.bids[self.btns.index(btn)]
                self.emit('nvim-switch-buffer', id)
            else:
                btn.set_active(True)
Example #6
0
    def toggle_telaawa(self, button: Gtk.ToggleButton) -> None:
        if self.is_updating:
            return

        is_activated = button.get_active()
        if is_activated:
            self.icon_telaawa_playback.set_from_icon_name(
                'media-playback-pause-symbolic', Gtk.IconSize.BUTTON)
        else:
            self.icon_telaawa_playback.set_from_icon_name(
                'media-playback-start-symbolic', Gtk.IconSize.BUTTON)

        button_playback_telaawa = self.popover_telaawa.button_toggle_playback
        button_playback_telaawa.set_active(is_activated)
Example #7
0
    def on_played(self, button: Gtk.ToggleButton) -> None:
        self.ready_to_play = button.get_active()
        self.emit('telaawa-playback', self.ready_to_play)

        if self.ready_to_play:
            self.icon_toggle_playback.set_from_icon_name(
                'media-playback-pause-symbolic', Gtk.IconSize.BUTTON)
        else:
            self.icon_toggle_playback.set_from_icon_name(
                'media-playback-start-symbolic', Gtk.IconSize.BUTTON)

        if self.is_updating:
            return

        if self.ready_to_play:
            if self.playbin_state == TelaawaPlayer.STOP:
                self.playback(TelaawaPlayer.PLAY)
            else:
                self.playback(TelaawaPlayer.RESUME)
        else:
            self.playback(TelaawaPlayer.PAUSE)
Example #8
0
 def on_tool_scene_grid_toggled(self, w: Gtk.ToggleButton):
     if self.drawer:
         self.drawer.set_draw_tile_grid(w.get_active())
Example #9
0
 def toggle_tarajem(
         self,
         button: Gtk.ToggleButton) -> None:
     glob.tarajem_visibility = button.get_active()
     self.emit('tarajem-toggled')
Example #10
0
 def match_whole_word_toggled(self, toggle: Gtk.ToggleButton) -> None:
     self.match_whole_word = toggle.get_active()
     self.populate()
Example #11
0
 def match_case_toggled(self, toggle: Gtk.ToggleButton) -> None:
     self.match_case = toggle.get_active()
     self.populate()
Example #12
0
 def on_enabledbt_toggled(self, button: Gtk.ToggleButton):
     if button.get_active():
         self.helper.start()
     else:
         self.helper.stop()
 def on_code_editor_cntrls_breaks_toggled(self, btn: Gtk.ToggleButton,
                                          *args):
     self.parent.parent.global_state__breaks_disabled = btn.get_active()
Example #14
0
 def on_button_toggle(toggle, other_toggle: Gtk.ToggleButton):
     if Gtk.ToggleButton.get_active(toggle):
         other_toggle.set_sensitive(False)
     else:
         other_toggle.set_sensitive(True)
Example #15
0
 def _on_mouse_enter(self, button: Gtk.ToggleButton):
     button.grab_focus()