Exemplo n.º 1
0
 def update_playback_button(self, playing):
     """ Update Play/Stop button """
     text, icon = get_playback_label(not playing)
     self._playback.set_icon_name(icon)
     self._playback.set_tooltip_text(text)
     self._playback.disconnect(self._playback_handler)
     if not playing:
         self._playback_handler = self._playback.connect("clicked", self._on_play)
     else:
         self._playback_handler = self._playback.connect("clicked", self._on_stop)
Exemplo n.º 2
0
 def __init__(self, app):
     Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
     self._app = app
     self.set_spacing(6)
     self.set_border_width(6)
     # Playback Button
     text, icon = get_playback_label()
     self._playback = create_toolbutton(text, icon)
     self._playback_handler = self._playback.connect("clicked", self._on_play)
     # Send message Button
     send_msg = create_toolbutton(_("Send message"), "gtk-edit")
     send_msg.connect("clicked", self._on_im)
     # Separator
     sep = Gtk.SeparatorToolItem()
     # Refresh schedule Button
     self._refresh = create_toolbutton(_("Update schedule"), "gtk-refresh")
     self._refresh.connect("clicked", self._on_refresh)
     # Spinner
     self._spinner = Gtk.Spinner()
     # Status
     self._status = Gtk.Label()
     self._status.set_selectable(True)
     self._status.set_alignment(-1, 0.45)
     self._status.set_use_markup(True)
     # Mute Button
     text, icon = get_volume_label()
     self._mute = create_toolbutton(text, icon)
     self._mute_handler = self._mute.connect("clicked", self._on_mute)
     # Volume scale
     ad = Gtk.Adjustment(value=100, lower=0, upper=100, step_increment=5, page_increment=10, page_size=0)
     self._volume = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=ad)
     self._volume.set_property("draw-value", False)
     self._volume_handler_id = self._volume.connect("value-changed", self._on_volume_changed)
     self._volume.set_size_request(80, 0)
     # Pack toolbar
     toolbar = Gtk.Toolbar()
     toolbar.set_orientation(Gtk.Orientation.HORIZONTAL)
     toolbar.set_style(Gtk.ToolbarStyle.ICONS)
     for x, el in enumerate([self._playback, send_msg, sep, self._refresh]):
         toolbar.insert(el, x)
     # Pack panel
     self.pack_start(toolbar, False, False, 0)
     self.pack_start(self._spinner, False, False, 0)
     self.pack_start(self._status, True, False, 0)
     self.pack_end(self._volume, False, False, 0)
     self.pack_end(self._mute, False, False, 0)
     self.show_all()
     self._spinner.hide()
Exemplo n.º 3
0
 def _popup_menu_create(self):
     """ Show menu on right click """
     popup_menu = Gtk.Menu()
     if APP_INDICATOR:
         # Since appindicator doesn't support left click event
         activate = Gtk.MenuItem(_("Activate"))
         activate.connect("activate", self._on_activate)
         popup_menu.append(activate)
         separator = Gtk.SeparatorMenuItem()
         popup_menu.append(separator)
     # Playback
     text, icon = get_playback_label(not self._playing)
     play = create_menuitem(text, icon)
     play.connect("activate", self._on_playback)
     play.set_size_request(100, -1)
     # Record
     text, icon = get_record_label(not self._recording)
     record = create_menuitem(text, icon)
     record.connect("activate", self._on_recorder)
     # Mute
     mute = Gtk.CheckMenuItem(_("Mute"))
     mute.set_active(self._muted)
     mute.connect("toggled", self._on_mute)
     # IM
     im = create_menuitem(_("Send message"), "gtk-edit")
     im.connect("activate", self._on_im)
     # Preferences
     preferences = create_menuitem(_("Preferences"), "gtk-preferences")
     preferences.connect("activate", self._on_prefs)
     # Quit
     quit = create_menuitem(_("Quit"), "gtk-quit")
     quit.connect("activate", self._on_quit)
     # Separator
     sep = []
     for i in range(4):
         sep.append(Gtk.SeparatorMenuItem())
     # Pack
     for item in [play, record, sep[0], mute, sep[1],
                  im, sep[2], preferences, sep[3], quit]:
         popup_menu.append(item)
     popup_menu.show_all()
     return popup_menu