Example #1
1
int
main (int argc, char **argv)
{
  GtkStatusIcon *icon;

  gtk_init (&argc, &argv);

  icon = gtk_status_icon_new ();

  g_signal_connect (icon, "size-changed", G_CALLBACK (size_changed_cb), NULL);
  g_signal_connect (icon, "notify::embedded", G_CALLBACK (embedded_changed_cb), NULL);
  g_signal_connect (icon, "notify::orientation", G_CALLBACK (orientation_changed_cb), NULL);
  g_signal_connect (icon, "notify::screen", G_CALLBACK (screen_changed_cb), NULL);
  g_print ("icon size %d\n", gtk_status_icon_get_size (icon));

  g_signal_connect (icon, "activate",
                    G_CALLBACK (icon_activated), NULL);

  g_signal_connect (icon, "popup-menu",
                    G_CALLBACK (popup_menu), NULL);

  icons = g_slist_append (icons, icon);

  update_icon ();

  timeout = gdk_threads_add_timeout (2000, timeout_handler, icon);

  gtk_main ();

  return 0;
}
Example #2
0
void Icon::update_all()
{
    Fl_Config &iconConfig = *cfg;
    iconConfig.read_file(false);
    iconConfig.set_section("Desktop Entry");

    // Icon Label:
    icon_name = get_localized_name(iconConfig);
    tooltip(icon_name);
    label(icon_name);

    label_color(label_foreground);
    label_size(label_fontsize);

    lwidth = label_maxwidth; // This is a bit strange, but otherwise we get mysterious crashes...
    lheight= 0;
    fl_font(label_font(), label_size());
    fl_measure(icon_name, lwidth, lheight, FL_ALIGN_WRAP);
    lwidth += 4; //  height+= 4;

    // Icon file:
    iconConfig.read("Icon", icon_file, "folder.png");

    update_icon();

    redraw();
    //desktop->redraw();
}
Example #3
0
static gint
sexy_icon_entry_button_press(GtkWidget *widget, GdkEventButton *event)
{
	SexyIconEntry *entry = SEXY_ICON_ENTRY(widget);
	int i;

	for (i = 0; i < MAX_ICONS; i++)
	{
		if (event->window == entry->priv->icons[i].window)
		{
			if (event->button == 1 &&
				sexy_icon_entry_get_icon_highlight(entry, i))
			{
				entry->priv->icons[i].hovered = FALSE;

				update_icon(NULL, NULL, entry);
			}

			g_signal_emit(entry, signals[ICON_PRESSED], 0, i, event->button);

			return TRUE;
		}
	}

	if (GTK_WIDGET_CLASS(parent_class)->button_press_event)
		return GTK_WIDGET_CLASS(parent_class)->button_press_event(widget,
																  event);

	return FALSE;
}
Example #4
0
Gobby::TabLabel::TabLabel(Folder& folder, SessionView& view,
                          const Glib::ustring& active_icon_name):
	m_folder(folder), m_view(view),
	m_title(view.get_title()), m_changed(false),
	m_active_icon_name(active_icon_name)
{
	set_column_spacing(6);
	m_title.set_halign(Gtk::ALIGN_START);

	update_icon();
	update_color();

	m_icon.show();
	m_title.show();
	m_button.set_halign(Gtk::ALIGN_END);
	m_button.show();

	view.signal_active_user_changed().connect(
		sigc::mem_fun(*this, &TabLabel::on_active_user_changed));

	m_notify_status_handle = g_signal_connect(
		G_OBJECT(view.get_session()), "notify::status",
		G_CALLBACK(on_notify_status_static), this);
	m_notify_subscription_group_handle = g_signal_connect(
		G_OBJECT(view.get_session()),
		"notify::subscription-group",
		G_CALLBACK(on_notify_subscription_group_static), this);

	m_folder.signal_document_changed().connect(
		sigc::mem_fun(*this, &TabLabel::on_folder_document_changed));

	attach(m_icon, 0, 0, 1, 1);
	attach(m_title, 1, 0, 1, 1);
	attach(m_button, 2, 0, 1, 1);
}
Example #5
0
static void show_desktop_applet_realized(MatePanelApplet* applet, gpointer data)
{
	ShowDesktopData* sdd;
	GdkScreen* screen;

	sdd = (ShowDesktopData*) data;

	if (sdd->matewnck_screen != NULL)
		g_signal_handlers_disconnect_by_func(sdd->matewnck_screen, show_desktop_changed_callback, sdd);

	if (sdd->icon_theme != NULL)
		g_signal_handlers_disconnect_by_func(sdd->icon_theme, theme_changed_callback, sdd);

	screen = gtk_widget_get_screen(sdd->applet);
	sdd->matewnck_screen = matewnck_screen_get(gdk_screen_get_number (screen));

	if (sdd->matewnck_screen != NULL)
		wncklet_connect_while_alive(sdd->matewnck_screen, "showing_desktop_changed", G_CALLBACK(show_desktop_changed_callback), sdd, sdd->applet);
	else
		g_warning("Could not get MatewnckScreen!");

	show_desktop_changed_callback(sdd->matewnck_screen, sdd);

	sdd->icon_theme = gtk_icon_theme_get_for_screen (screen);
	wncklet_connect_while_alive(sdd->icon_theme, "changed", G_CALLBACK(theme_changed_callback), sdd, sdd->applet);

	update_icon (sdd);
}
Example #6
0
/* this is when the panel size changes */
static void button_size_allocated(GtkWidget* button, GtkAllocation* allocation, ShowDesktopData* sdd)
{
	/*
	if ((sdd->orient == GTK_ORIENTATION_HORIZONTAL) && (sdd->size == allocation->height))
	{
		return;
	}
	else if ((sdd->orient == GTK_ORIENTATION_VERTICAL) && (sdd->size == allocation->width))
	{
		return;
	}
	*/

	if (((sdd->orient == GTK_ORIENTATION_HORIZONTAL) && (sdd->size == allocation->height)) || ((sdd->orient == GTK_ORIENTATION_VERTICAL) && (sdd->size == allocation->width)))
		return;

	switch (sdd->orient)
	{
		case GTK_ORIENTATION_HORIZONTAL:
			sdd->size = allocation->height;
			break;
		case GTK_ORIENTATION_VERTICAL:
			sdd->size = allocation->width;
			break;
	}

	update_icon(sdd);
}
static void
applet_change_orient (PanelApplet       *applet,
                      PanelAppletOrient  orient,
                      ShowDesktopData   *sdd)
{
        GtkOrientation new_orient;

        switch (orient)
        {
        case PANEL_APPLET_ORIENT_LEFT:
        case PANEL_APPLET_ORIENT_RIGHT:
                new_orient = GTK_ORIENTATION_VERTICAL;
                break;
        case PANEL_APPLET_ORIENT_UP:
        case PANEL_APPLET_ORIENT_DOWN:
        default:
                new_orient = GTK_ORIENTATION_HORIZONTAL;
                break;
        }

        if (new_orient == sdd->orient)
                return;

        sdd->orient = new_orient;

        update_icon (sdd);
}
Example #8
0
static void on_mouse_scroll (GtkWidget* widget, GdkEventScroll* evt, volume_t *vol)
{
	if ( ! vol->dlg ) {

		vol->dlg = create_volume_window();
		g_signal_connect( vol->dlg, "delete-event",
				G_CALLBACK(on_volume_focus), widget );

	}
	else {
		if (! vol_spin) return;
		GtkAdjustment *vol_adjustment =
			gtk_spin_button_get_adjustment (vol_spin);
		if (! vol_adjustment) return;

		curr_volume = gtk_adjustment_get_value (vol_adjustment);

		if (evt->direction == GDK_SCROLL_UP) {
			curr_volume += 2;
		}
		else /*if (evt->direction == GDK_SCROLL_DOWN)*/ {
			curr_volume -= 2;
		}
		update_icon(widget, vol);
		gtk_adjustment_set_value (vol_adjustment, curr_volume);
		gtk_spin_button_set_adjustment(vol_spin, vol_adjustment);
		skip_botton1_event = TRUE;
	}
}
static void
break_window_postpone_cb (GtkWidget *window,
                          DrWright  *dr)
{
    gint elapsed_time;

    gtk_widget_destroy (dr->break_window);

    dr->state = STATE_RUNNING;
    dr->break_window = NULL;

    elapsed_time = drw_timer_elapsed (dr->timer);

    if (elapsed_time + dr->save_last_time >= dr->type_time) {
        /* Typing time has expired, but break was postponed.
         * We'll warn again in (elapsed * sqrt (typing_time))^2 */
        gfloat postpone_time = (((float) elapsed_time) / dr->break_time)
                               * sqrt (dr->type_time);
        postpone_time *= postpone_time;
        dr->save_last_time = dr->type_time - MAX (dr->warn_time, (gint) postpone_time);
    }

    drw_timer_start (dr->timer);
    maybe_change_state (dr);
    update_status (dr);
#ifdef HAVE_APP_INDICATOR
    update_app_indicator (dr);
#else
    update_icon (dr);
#endif /* HAVE_APP_INDICATOR */
}
Example #10
0
Gobby::TabLabel::TabLabel(Folder& folder, SessionView& view,
                          const Glib::ustring& active_icon_name):
	Gtk::HBox(false, 6), m_folder(folder), m_view(view),
	m_title(view.get_title()), m_changed(false),
	m_active_icon_name(active_icon_name)
{
	m_title.set_alignment(Gtk::ALIGN_START);

	update_icon();
	update_color();

	m_icon.show();
	m_title.show();
	m_extra.show();
	m_button.show();

	view.signal_active_user_changed().connect(
		sigc::mem_fun(*this, &TabLabel::on_active_user_changed));

	m_notify_status_handle = g_signal_connect(
		G_OBJECT(view.get_session()), "notify::status",
		G_CALLBACK(on_notify_status_static), this);
	m_notify_subscription_group_handle = g_signal_connect(
		G_OBJECT(view.get_session()),
		"notify::subscription-group",
		G_CALLBACK(on_notify_subscription_group_static), this);

	m_folder.signal_document_changed().connect(
		sigc::mem_fun(*this, &TabLabel::on_folder_document_changed));

	pack_start(m_icon, Gtk::PACK_SHRINK);
	pack_start(m_title, Gtk::PACK_SHRINK);
	pack_start(m_extra, Gtk::PACK_EXPAND_WIDGET);
	pack_end(m_button, Gtk::PACK_SHRINK);
}
Example #11
0
static void
polari_room_set_channel (PolariRoom *room,
                         TpChannel  *channel)
{
  PolariRoomPrivate *priv;

  g_return_if_fail (POLARI_IS_ROOM (room));
  g_return_if_fail (channel == NULL || TP_IS_TEXT_CHANNEL (channel));

  priv = room->priv;

  if (priv->channel == channel)
    return;

  if (priv->channel)
    {
      g_signal_handler_disconnect (priv->channel, priv->identifier_notify_id);
      g_signal_handler_disconnect (priv->channel, priv->group_contacts_changed_id);

      tp_proxy_signal_connection_disconnect (priv->properties_changed_id);

      g_clear_object (&priv->channel);
    }

  if (channel)
    {
      priv->channel = g_object_ref (channel);

      if (priv->id == NULL)
        priv->id = g_strdup (tp_proxy_get_object_path (TP_PROXY (channel)));

      tp_cli_dbus_properties_call_get_all (channel, -1,
                                     TP_IFACE_CHANNEL_INTERFACE_SUBJECT,
                                     (tp_properties_get_all_cb)subject_get_all,
                                     room, NULL, NULL);


      priv->identifier_notify_id =
        g_signal_connect (channel, "notify::identifier",
                          G_CALLBACK (on_identifier_notify), room);
      priv->group_contacts_changed_id =
        g_signal_connect (channel, "group-contacts-changed",
                          G_CALLBACK (on_group_contacts_changed), room);
      priv->properties_changed_id =
        tp_cli_dbus_properties_connect_to_properties_changed (
                                 channel,
                                 (tp_properties_changed_cb) properties_changed,
                                 room, NULL, NULL, NULL);
    }

    g_object_freeze_notify (G_OBJECT (room));

    update_identifier (room);
    update_icon (room);

    g_object_notify_by_pspec (G_OBJECT (room), props[PROP_CHANNEL]);

    g_object_thaw_notify (G_OBJECT (room));
}
Example #12
0
static void on_click_toggle(GtkCheckMenuItem *item, gpointer user_data){
	E_RETURN is_wall_active = torwall_client_status();
	if (is_wall_active == STATUS_RUNNING) {
        torwall_client_off();
    } else {
        torwall_client_on();
    }
	update_icon();
}
Example #13
0
static void on_click(GtkStatusIcon *status_icon, gpointer user_data){
    printf("ONCLICK\n");
	E_RETURN is_wall_active = torwall_client_status();
	if (is_wall_active == STATUS_RUNNING) {
        torwall_client_off();
    } else {
        torwall_client_on();
    }
	update_icon();
}
Example #14
0
static void style_changed_cb(GtkWidget *widget, gpointer user_data)
{
    IndicatorFitbit *self = INDICATOR_FITBIT(user_data);

    g_return_if_fail(GTK_IS_IMAGE(widget));
    g_return_if_fail(IS_INDICATOR_FITBIT(user_data));

    load_all_pixbufs(self);
    update_icon(self);
}
Example #15
0
File: mixer.c Project: pzanoni/tray
static void mute(GtkWidget *widget, struct channel *c)
{
	int val, i;

	val = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
	for (i = 0; i <= SND_MIXER_SCHN_LAST; i++)
		_set_switch(c->elem, c->playback, i, !val);

	mixer_getmute(c);
	update_icon(c);
}
Example #16
0
static void
detect_received(GtkClipboard *board, const gchar *text, SeahorseApplet *sapplet)
{
    SeahorseAppletPrivate *priv = SEAHORSE_APPLET_GET_PRIVATE (sapplet);
    
    if (!text || !*text)
        priv->clipboard_contents = SEAHORSE_TEXT_TYPE_NONE;
    else
        priv->clipboard_contents = detect_text_type (text, -1, NULL, NULL);
    
    update_icon (sapplet);
}
Example #17
0
static gboolean
timeout_handler (gpointer data)
{
  if (status == TEST_STATUS_INFO)
    status = TEST_STATUS_QUESTION;
  else
    status = TEST_STATUS_INFO;

  update_icon ();

  return TRUE;
}
Example #18
0
/**
 * sexy_icon_entry_set_icon
 * @entry: A #SexyIconEntry.
 * @position: Icon position.
 * @icon: A #GtkImage to set as the icon.
 *
 * Sets the icon shown in the entry
 */
void
sexy_icon_entry_set_icon(SexyIconEntry *entry, SexyIconEntryPosition icon_pos,
						 GtkImage *icon)
{
	SexyIconInfo *icon_info;

	g_return_if_fail(entry != NULL);
	g_return_if_fail(SEXY_IS_ICON_ENTRY(entry));
	g_return_if_fail(IS_VALID_ICON_ENTRY_POSITION(icon_pos));
	g_return_if_fail(icon == NULL || GTK_IS_IMAGE(icon));

	icon_info = &entry->priv->icons[icon_pos];

	if (icon == icon_info->icon)
		return;

	if (icon_pos == SEXY_ICON_ENTRY_SECONDARY &&
		entry->priv->icon_released_id != 0)
	{
		g_signal_handler_disconnect(entry, entry->priv->icon_released_id);
		entry->priv->icon_released_id = 0;
	}

	if (icon == NULL)
	{
		if (icon_info->icon != NULL)
		{
			gtk_widget_destroy(GTK_WIDGET(icon_info->icon));
			icon_info->icon = NULL;

			/*
			 * Explicitly check, as the pointer may become invalidated
			 * during destruction.
			 */
			if (icon_info->window != NULL && GDK_IS_WINDOW(icon_info->window))
				gdk_window_hide(icon_info->window);
		}
	}
	else
	{
		if (icon_info->window != NULL && icon_info->icon == NULL)
			gdk_window_show(icon_info->window);

		g_signal_connect(G_OBJECT(icon), "notify",
						 G_CALLBACK(update_icon), entry);

		icon_info->icon = icon;
		g_object_ref(icon);
	}

	update_icon(NULL, NULL, entry);
}
static void
init_tray_icon (DrWright *dr)
{
    dr->icon = gtk_status_icon_new_from_pixbuf (dr->neutral_bar);

    update_status (dr);
    update_icon (dr);

    g_signal_connect (dr->icon,
                      "popup_menu",
                      G_CALLBACK (popup_menu_cb),
                      dr);
}
Example #20
0
static void 
handle_clipboard_owner_change(GtkClipboard *clipboard, GdkEvent *event, 
                              SeahorseApplet *sapplet)
{
    SeahorseAppletPrivate *priv = SEAHORSE_APPLET_GET_PRIVATE (sapplet);
    priv->board = clipboard; 
    
    if (seahorse_gconf_get_boolean (SHOW_CLIPBOARD_STATE_KEY)) 
        gtk_clipboard_request_text (clipboard,
             (GtkClipboardTextReceivedFunc)detect_received, sapplet);
    else
        update_icon (sapplet);
}
Example #21
0
static void
settings_changed_cb (GSettings          *settings,
                     const gchar        *key,
                     GpMenuButtonApplet *menu_button)
{
  GpMenuButtonAppletPrivate *priv;

  priv = gp_menu_button_applet_get_instance_private (menu_button);

  if (g_strcmp0 (key, "custom-icon") == 0)
    {
      update_icon (menu_button);
    }
  else if (g_strcmp0 (key, "menu-path") == 0)
    {
      update_menu (menu_button);
      update_icon (menu_button);
    }
  else if (g_strcmp0 (key, "show-arrow") == 0)
    {
      gboolean show_arrow;

      show_arrow = g_settings_get_boolean (priv->settings, "show-arrow");
      gtk_widget_set_visible (priv->image, show_arrow);
    }
  else if (g_strcmp0 (key, "tooltip") == 0)
    {
      gchar *tooltip;
      gboolean enable_tooltips;

      tooltip = g_settings_get_string (priv->settings, "tooltip");
      gtk_widget_set_tooltip_text (priv->button, *tooltip != '\0' ? tooltip : NULL);
      g_free (tooltip);

      g_object_get (menu_button, "enable-tooltips", &enable_tooltips, NULL);
      gtk_widget_set_has_tooltip (priv->button, enable_tooltips);
    }
}
Example #22
0
static GtkWidget *volume_constructor(LXPanel *panel, config_setting_t *settings)
{
    volume_t *vol;
    GtkWidget *p;
    GtkAdjustment *vol_adjustment;

    vol_before_mute = 1;
    curr_volume = 0;
    curr_image = NULL;
    skip_botton1_event = FALSE;

    ENTER;
    /* check if OSS mixer device could be open */
    mixer_fd = open ("/dev/mixer", O_RDWR, 0);
    if (mixer_fd < 0) {
        RET(NULL);
    }
    /* try to obtain current volume */
    p = create_volume_window(); /* use pointer */
    if (! vol_spin)
        goto _error;
    vol_adjustment = gtk_spin_button_get_adjustment (vol_spin);
    if (! vol_adjustment)
    {
_error:
        gtk_widget_destroy(p);
        RET(NULL);
    }
    curr_volume = gtk_adjustment_get_value (vol_adjustment);

    vol = g_new0(volume_t, 1);
    vol->dlg = p; /* it was reused */

    p = gtk_event_box_new();
    lxpanel_plugin_set_data(p, vol, volume_destructor);
    vol->panel = panel;

    gtk_widget_add_events(p, GDK_BUTTON_PRESS_MASK);
    g_signal_connect(p, "scroll-event", G_CALLBACK(on_mouse_scroll), vol);
    gtk_widget_set_size_request(p, panel_get_icon_size(panel), panel_get_icon_size(panel));

    update_icon(p, vol);
    gtk_widget_destroy( vol->dlg );
    vol->dlg = NULL;

    /* FIXME: display current level in tooltip. ex: "Volume Control: 80%"  */
    gtk_widget_set_tooltip_text(p, _("Volume control"));

    RET(p);
}
static void
break_window_postpone_cb (GtkWidget *window,
			  DrWright  *dr)
{
	gtk_widget_destroy (dr->break_window);

	dr->state = STATE_WARN_TYPE;
	dr->break_window = NULL;

	g_timer_start (dr->timer);
	start_blinking (dr);
	update_icon (dr);
	update_tooltip (dr);
}
Example #24
0
File: mixer.c Project: pzanoni/tray
static void update_gui(struct channel *c)
{
	mixer_getmute(c);
	update_icon(c);

	if (c->mute) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c->mute),
							!c->muteval);
	} else {
		c->muteval = 1;
	}

	gtk_range_set_value(GTK_RANGE(c->vscale), mixer_get(c));
}
static void
notify (GObject *object,
        GParamSpec *pspec)
{
    if (!pspec || !pspec->name)
        return;

    if (!strcmp (pspec->name, NM_LIST_ITEM_STATUS))
        update_icon (NM_ETHERNET_ITEM (object));
    else if (!strcmp (pspec->name, NM_CONNECTION_ITEM_CONNECTION) && 
             !nm_connection_item_get_connection (NM_CONNECTION_ITEM (object)))
        /* If the connection is removed from the item, request deletion */
        nm_list_item_request_remove (NM_LIST_ITEM (object));
}
Example #26
0
static void on_volume_focus (GtkWidget* dlg, GdkEventFocus *event, GtkWidget *p)
{
	volume_t *vol = lxpanel_plugin_get_data(p);

	if (! vol_spin) return;
	GtkAdjustment *vol_adjustment = gtk_spin_button_get_adjustment (vol_spin);
	if (! vol_adjustment) return;
	curr_volume = gtk_adjustment_get_value (vol_adjustment);

	update_icon(p, vol);

	/* FIXME: use smarter method */
	gtk_widget_destroy( dlg );
	vol->dlg = NULL;
}
Example #27
0
static GtkImage *get_image(IndicatorObject *io)
{
    IndicatorFitbit *self = INDICATOR_FITBIT(io);

    if (!self->priv->image) {
        self->priv->image = GTK_IMAGE(gtk_image_new());

        load_all_pixbufs(self);
        update_icon(self);

        g_signal_connect(G_OBJECT(self->priv->image), "style-updated", G_CALLBACK(style_changed_cb), self);
        gtk_widget_show(GTK_WIDGET(self->priv->image));
    }

    return self->priv->image;
}
static void
update_current_ap (NMWifiItem *self)
{
    NMWifiItemPrivate *priv = GET_PRIVATE (self);
    GSList *iter;

    /* FIXME: If device is activated, use activation AP only */

    for (iter = priv->ap_list; iter; iter = iter->next) {
        NMAccessPoint *ap = (NMAccessPoint *) iter->data;

        if (!priv->current_ap || nm_access_point_get_strength (priv->current_ap) < nm_access_point_get_strength (ap))
            priv->current_ap = ap;
    }

    update_icon (self);
}
Example #29
0
static void tracker_cb(fitbitd_tracker_t *tracker, void *user)
{
    IndicatorFitbit *self = user;
    GtkWidget *item = tracker->user;

    if (!item) {
        item = tracker_menuitem_new();
        tracker->user = item;
        gtk_widget_show(item);
        gtk_menu_shell_prepend(GTK_MENU_SHELL(self->priv->menu), item);
    }

    self->priv->syncing |= tracker->sync_active;
    update_icon(self);

    tracker_menuitem_set_from_tracker(TRACKER_MENUITEM(item), tracker);
}
Example #30
0
/*
 * Initialise an icon structure
 * PARAMETERS:
 *	s			: Label structure to initialise
 *	on_img		: Path to the on_image picture
 *	off_img		: Path to the off_image picture
 *	status		: 0 for off_image, 1 for on_image
 *	x			: x coordinate of the top left corner of the label
 *	y			: y coordinate of the top left corner of the label
 *
 * RETURNS:
 *	0			: Success
 *	1			: Failure
 */
int init_icon(icon_t *s, char *on_img, char *off_img, int status, int x, int y)
{
	//Load icon image on and image off
	s->surface_on = IMG_Load(on_img);
	s->surface_off = IMG_Load(off_img);

	// Return 1 if unable to load one of the image
	if (!(s->surface_on) || !(s->surface_off))
		return 1;

	// Populate other variables from param
	s->status = status;
	s->x = x;
	s->y = y;

	update_icon(s, 1, 0);

	return 0;
}