Example #1
0
  def notify(title, text, icon = None, timeout = None, iconsize = 48):
    if icon is None:
      icon = resources.get_ui_asset("icons/hicolor/scalable/apps/gwibber.svg")

    if icon is None:
      return
    
    caps = Notify.get_server_caps()
    
    notification = Notify.Notification.new(title, text, "gwibber")

    pixbuf = None
    try:
      pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon, iconsize, iconsize)
    except GLib.Error as e:
      logger.error("Avatar failure - %s - %s", icon, e.message)
      resources.del_avatar(icon)

    if pixbuf:
      try:
        notification.set_icon_from_pixbuf(pixbuf)
      except GLib.Error as e:
        logger.error("Notification failure - %s", e.message)

    if timeout:
      notification.set_timeout(timeout)

    if "x-canonical-append" in caps:
      notification.set_hint_string('x-canonical-append', 'allowed')

    try:
      notification.show ()
    except:
      logger.error("Notification failed")
    return
Example #2
0
  def set_stream(self, stream):
    self.selected_stream = stream
    self.nav_label.set_text(stream["name"])

    is_search = stream["stream"] == "search" and not stream["transient"]
    self.search_box.set_visible(not is_search)

    if stream["account"]:
      fname = resources.get_ui_asset("icons/breakdance/16x16/%s.png" % stream["service"])
      self.icon_protocol.set_from_file(fname)
    else: self.icon_protocol.clear()

    if stream["stream"]:
      fname = resources.get_ui_asset("icons/streams/16x16/%s.png" % stream["stream"])
      self.icon_stream.set_from_file(fname)
    else: self.icon_stream.clear()
Example #3
0
 def on_about(self, *args):
   self.ui.add_from_file (resources.get_ui_asset("gwibber-about-dialog.ui"))
   about_dialog = self.ui.get_object("about_dialog")
   about_dialog.set_version(str(VERSION_NUMBER))
   about_dialog.set_transient_for(self)
   about_dialog.connect("response", lambda *a: about_dialog.hide())
   about_dialog.show_all()
Example #4
0
 def on_about(self, *args):
     self.ui.add_from_file(
         resources.get_ui_asset("gwibber-about-dialog.ui"))
     about_dialog = self.ui.get_object("about_dialog")
     about_dialog.set_version(str(VERSION_NUMBER))
     about_dialog.set_transient_for(self)
     about_dialog.connect("response", lambda *a: about_dialog.hide())
     about_dialog.show_all()
Example #5
0
    def action(self, w, client, msg):
        client.service.PerformOp(
            json.dumps({"account": msg["account"], "operation": "delete", "args": {"message": msg}, "transient": False})
        )

        image = resources.get_ui_asset("gwibber.svg")
        expire_timeout = 5000
        n = gwibber.microblog.util.notify(_("Deleted"), _("The message has been deleted."), image, expire_timeout)
Example #6
0
    def action(self, w, client, msg):
        client.service.PerformOp(
            json.dumps({
                "account": msg["account"],
                "operation": "delete",
                "args": {
                    "message": msg
                },
                "transient": False,
            }))

        image = resources.get_ui_asset("gwibber.svg")
        expire_timeout = 5000
        n = gwibber.microblog.util.notify(_("Deleted"),
                                          _("The message has been deleted."),
                                          image, expire_timeout)
Example #7
0
  def notify(title, text, icon = None, timeout = None, iconsize = 48):
    if icon is None:
      icon = resources.get_ui_asset("gwibber.svg")
    
    caps = pynotify.get_server_caps()
    
    notification = pynotify.Notification(title, text)

    try:
      pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon, iconsize, iconsize)
      notification.set_icon_from_pixbuf(pixbuf)
    except glib.GError as e:
      log.logger.error("Avatar failure - %s - %s", icon, e.message)
      resources.del_avatar(icon)

    if timeout:
      notification.set_timeout(timeout)

    if "x-canonical-append" in caps:
      notification.set_hint('x-canonical-append', 'allowed')

    return notification.show()
Example #8
0
def pixbuf(path):
    return gtk.gdk.pixbuf_new_from_file(resources.get_ui_asset(path))
Example #9
0
 def on_loading_started(self, *args):
     self.loading_spinner.set_from_animation(
         gtk.gdk.PixbufAnimation(resources.get_ui_asset("progress.gif")))
Example #10
0
    def setup_ui(self):
        self.set_title(_("Social broadcast messages"))
        self.set_icon_from_file(resources.get_ui_asset("gwibber.svg"))
        self.connect("delete-event", self.on_window_close)

        # Load the application menu
        menu_ui = self.setup_menu()
        self.add_accel_group(menu_ui.get_accel_group())

        def on_tray_menu_popup(i, b, a):
            menu_ui.get_widget("/menu_tray").popup(
                None, None, gtk.status_icon_position_menu, b, a,
                self.tray_icon)

        self.tray_icon = gtk.status_icon_new_from_file(
            resources.get_ui_asset("gwibber.svg"))
        self.tray_icon.connect("activate", self.on_toggle_window_visibility)
        self.tray_icon.connect("popup-menu", on_tray_menu_popup)

        # Create animated loading spinner
        self.loading_spinner = gtk.Image()
        menu_spin = gtk.ImageMenuItem("")
        menu_spin.set_right_justified(True)
        menu_spin.set_sensitive(False)
        menu_spin.set_image(self.loading_spinner)

        # Force the spinner to show in newer versions of Gtk
        if hasattr(menu_spin, "set_always_show_image"):
            menu_spin.set_always_show_image(True)

        menubar = menu_ui.get_widget("/menubar_main")
        menubar.append(menu_spin)

        # Load the user's saved streams
        streams = json.loads(self.model.settings["streams"])
        streams = [dict((str(k), v) for k, v in s.items()) for s in streams]

        # Use the multicolumn mode if there are multiple saved streams
        view_class = getattr(
            gwui, "MultiStreamUi" if len(streams) > 1 else "SingleStreamUi")

        self.stream_view = view_class(self.model)
        self.stream_view.connect("action", self.on_action)
        self.stream_view.connect("search", self.on_perform_search)
        self.stream_view.connect("stream-changed", self.on_stream_changed)
        self.stream_view.connect("stream-closed", self.on_stream_closed)
        if isinstance(self.stream_view, gwui.MultiStreamUi):
            self.stream_view.connect("pane-closed", self.on_pane_closed)

        self.input = gwui.Input()
        self.input.connect("submit", self.on_input_activate)
        self.input.connect("changed", self.on_input_changed)

        self.input_splitter = gtk.VPaned()
        self.input_splitter.pack1(self.stream_view, resize=True)
        self.input_splitter.pack2(self.input, resize=False)

        self.input_splitter.set_focus_child(self.input)

        self.button_send = gtk.Button(_("Send"))
        self.button_send.connect("clicked", self.on_button_send_clicked)

        self.message_target = gwui.AccountTargetBar(self.model)
        self.message_target.pack_end(self.button_send, False)
        self.message_target.connect("canceled", self.on_reply_cancel)

        content = gtk.VBox(spacing=5)
        content.pack_start(self.input_splitter, True)
        content.pack_start(self.message_target, False)
        content.set_border_width(5)

        layout = gtk.VBox()
        layout.pack_start(menubar, False)
        layout.pack_start(content, True)

        self.add(layout)

        # Apply the user's settings
        self.resize(*self.model.settings["window_size"])
        self.move(*self.model.settings["window_position"])
        self.input_splitter.set_position(
            self.model.settings["window_splitter"])

        if hasattr(self.stream_view, "splitter"):
            self.stream_view.splitter.set_position(
                self.model.settings["sidebar_splitter"])

        self.show_all()

        self.stream_view.set_state(streams)
        self.update_menu_availability()
Example #11
0
def pixbuf(path):
  return gtk.gdk.pixbuf_new_from_file(resources.get_ui_asset(path))
Example #12
0
 def set_icon(self, name):
     self.tray.set_from_file(resources.get_ui_asset(name))
     self.Icon_name = name
Example #13
0
 def on_loading_started(self, *args):
   self.loading_spinner.set_from_animation(
     gtk.gdk.PixbufAnimation(resources.get_ui_asset("progress.gif")))
Example #14
0
  def setup_ui(self):
    self.set_title(_("Social broadcast messages"))
    self.set_icon_from_file(resources.get_ui_asset("gwibber.svg"))
    self.connect("delete-event", self.on_window_close)

    # Load the application menu
    menu_ui = self.setup_menu()
    self.add_accel_group(menu_ui.get_accel_group())

    def on_tray_menu_popup(i, b, a):
      menu_ui.get_widget("/menu_tray").popup(None, None,
          gtk.status_icon_position_menu, b, a, self.tray_icon)

    self.tray_icon = gtk.status_icon_new_from_file(resources.get_ui_asset("gwibber.svg"))
    self.tray_icon.connect("activate", self.on_toggle_window_visibility)
    self.tray_icon.connect("popup-menu", on_tray_menu_popup)

    # Create animated loading spinner
    self.loading_spinner = gtk.Image()
    menu_spin = gtk.ImageMenuItem("")
    menu_spin.set_right_justified(True)
    menu_spin.set_sensitive(False)
    menu_spin.set_image(self.loading_spinner)

    # Force the spinner to show in newer versions of Gtk
    if hasattr(menu_spin, "set_always_show_image"):
      menu_spin.set_always_show_image(True)

    menubar = menu_ui.get_widget("/menubar_main")
    menubar.append(menu_spin)

    # Load the user's saved streams
    streams = json.loads(self.model.settings["streams"])
    streams = [dict((str(k), v) for k, v in s.items()) for s in streams]
    
    # Use the multicolumn mode if there are multiple saved streams
    view_class = getattr(gwui, "MultiStreamUi" if len(streams) > 1 else "SingleStreamUi")

    self.stream_view = view_class(self.model)
    self.stream_view.connect("action", self.on_action)
    self.stream_view.connect("search", self.on_perform_search)
    self.stream_view.connect("stream-changed", self.on_stream_changed)
    self.stream_view.connect("stream-closed", self.on_stream_closed)
    if isinstance(self.stream_view, gwui.MultiStreamUi):
      self.stream_view.connect("pane-closed", self.on_pane_closed)

    self.input = gwui.Input()
    self.input.connect("submit", self.on_input_activate)
    self.input.connect("changed", self.on_input_changed)

    self.input_splitter = gtk.VPaned()
    self.input_splitter.pack1(self.stream_view, resize=True)
    self.input_splitter.pack2(self.input, resize=False)

    self.input_splitter.set_focus_child(self.input)

    self.button_send = gtk.Button(_("Send"))
    self.button_send.connect("clicked", self.on_button_send_clicked)

    self.message_target = gwui.AccountTargetBar(self.model)
    self.message_target.pack_end(self.button_send, False)
    self.message_target.connect("canceled", self.on_reply_cancel)

    content = gtk.VBox(spacing=5)
    content.pack_start(self.input_splitter, True)
    content.pack_start(self.message_target, False)
    content.set_border_width(5)

    layout = gtk.VBox()
    layout.pack_start(menubar, False)
    layout.pack_start(content, True)

    self.add(layout)

    # Apply the user's settings 
    self.resize(*self.model.settings["window_size"])
    self.move(*self.model.settings["window_position"])
    self.input_splitter.set_position(self.model.settings["window_splitter"])
    
    if hasattr(self.stream_view, "splitter"):
      self.stream_view.splitter.set_position(
          self.model.settings["sidebar_splitter"])
    
    self.show_all()

    self.stream_view.set_state(streams)
    self.update_menu_availability()