/*
 * GtkSocket callbacks
 */
static gboolean
on_plug_removed (AwnAppletProxy *proxy, gpointer user_data)
{
  AwnAppletProxyPrivate *priv;

  g_return_val_if_fail (AWN_IS_APPLET_PROXY (proxy), FALSE);
  priv = proxy->priv;

  /* reset our old position */
  priv->old_x = 0;
  priv->old_y = 0;
  priv->old_w = 0;
  priv->old_h = 0;

  /* indicate that the applet crashed and allow restart */
  priv->running = FALSE;
  priv->crashed = TRUE;
  awn_icon_set_tooltip_text (AWN_ICON (priv->throbber),
    _("Whoops! The applet crashed. Click to restart it."));
  awn_throbber_set_type (AWN_THROBBER (priv->throbber),
                         AWN_THROBBER_TYPE_SAD_FACE);
  awn_icon_set_hover_effects (AWN_ICON (priv->throbber), TRUE);

  g_signal_emit (proxy, _proxy_signals[APPLET_CRASHED], 0);

  return TRUE;
}
static void
awn_applet_proxy_set_property (GObject      *object,
                               guint         prop_id,
                               const GValue *value,
                               GParamSpec   *pspec)
{
  AwnAppletProxyPrivate *priv;

  g_return_if_fail (AWN_IS_APPLET_PROXY (object));
  priv = AWN_APPLET_PROXY (object)->priv;

  switch (prop_id)
  {
    case PROP_PATH:
      priv->path = g_value_dup_string (value);
      break;
    case PROP_UID:
      priv->uid = g_value_dup_string (value);
      break;
    case PROP_POSITION:
      priv->position = g_value_get_int (value);
      awn_icon_set_pos_type (AWN_ICON (priv->throbber), priv->position);
      break;
    case PROP_OFFSET:
      priv->offset = g_value_get_int (value);
      awn_icon_set_offset (AWN_ICON (priv->throbber), priv->offset);
      break;
    case PROP_SIZE:
      priv->size = g_value_get_int (value);
      awn_throbber_set_size (AWN_THROBBER (priv->throbber), priv->size);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  }
}
static void
awn_applet_simple_constructed (GObject *object)
{
  G_OBJECT_CLASS (awn_applet_simple_parent_class)->constructed (object);

  AwnAppletSimple        *applet = AWN_APPLET_SIMPLE (object);
  AwnAppletSimplePrivate *priv = applet->priv;
  gchar                  *applet_name;
  
  g_object_get (object,
                "canonical-name",&applet_name,
                NULL);

  priv->icon = awn_themed_icon_new ();
  
  g_object_set (priv->icon,
                "applet-name",applet_name,
                NULL);
  awn_icon_set_pos_type (AWN_ICON (priv->icon), 
                         awn_applet_get_pos_type (AWN_APPLET (object)));
  awn_icon_set_offset (AWN_ICON (priv->icon),
                       awn_applet_get_offset (AWN_APPLET (object)));
  g_signal_connect_swapped (priv->icon, "clicked", 
                            G_CALLBACK (on_icon_clicked), object);
  g_signal_connect_swapped (priv->icon, "middle-clicked", 
                            G_CALLBACK (on_icon_middle_clicked), object);
  g_signal_connect_swapped (priv->icon, "context-menu-popup", 
                            G_CALLBACK (on_icon_menu_popup), object);
  gtk_container_add (GTK_CONTAINER (applet), priv->icon);
  gtk_widget_show (priv->icon);
  g_free (applet_name);
}
static GtkWidget *
pixbuf_icon (GtkWidget *parent)
{
  GdkPixbuf *pixbuf;
  GtkWidget *icon;

  pixbuf = gdk_pixbuf_new_from_file_at_size (PICTURE_FILE, 50, 50, NULL);

  icon = awn_icon_new ();
  awn_icon_set_from_pixbuf (AWN_ICON (icon), pixbuf);
  awn_icon_set_tooltip_text (AWN_ICON (icon), "Pixbuf Icon");

  /* test the signals */
  AwnEffects *fx = awn_overlayable_get_effects (AWN_OVERLAYABLE (icon));
  g_signal_connect(fx, "animation-start", (GCallback)anim_started, NULL);
  g_signal_connect(fx, "animation-end", (GCallback)anim_ended, NULL);

  gtk_container_add (GTK_CONTAINER (parent), icon);
  gtk_widget_show (icon);

  g_signal_connect (icon, "button-release-event", 
                    G_CALLBACK (on_click), parent); 
  g_object_unref (pixbuf);
  return icon;
}
Exemplo n.º 5
0
static gboolean
_button_clicked_event (CairoMainIcon *icon, GdkEventButton *event, gpointer null)
{
  g_return_val_if_fail (AWN_IS_CAIRO_MAIN_ICON(icon), FALSE);
  CairoMainIconPrivate * priv = GET_PRIVATE (icon);

  if (event->button == 1)
  {
    awn_icon_popup_gtk_menu (AWN_ICON (icon), priv->menu, event->button, event->time);

    if (!priv->autohide_cookie)
    {
      priv->autohide_cookie = awn_applet_inhibit_autohide (AWN_APPLET(priv->applet),"CairoMenu" );
    }
    g_object_set(awn_overlayable_get_effects (AWN_OVERLAYABLE(icon)), "depressed", FALSE,NULL);
  }
  else if (event->button == 3)
  {
    GtkWidget * item;

    if (!priv->context_menu)
    {
      priv->context_menu = awn_applet_create_default_menu (AWN_APPLET(priv->applet));
      gtk_menu_set_screen(GTK_MENU(priv->context_menu), NULL);
      item = awn_themed_icon_create_remove_custom_icon_item (AWN_THEMED_ICON(icon),NULL);
      gtk_menu_shell_append (GTK_MENU_SHELL(priv->context_menu), item);
/*      item = gtk_image_menu_item_new_with_label("Applet Preferences");
      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item),
                                     gtk_image_new_from_stock (GTK_STOCK_PREFERENCES,GTK_ICON_SIZE_MENU));
      gtk_widget_show(item);
      gtk_menu_shell_append(GTK_MENU_SHELL(priv->context_menu), item);
       */
//      g_signal_connect(G_OBJECT(item), "button-press-event", G_CALLBACK(_show_prefs), NULL);
      item=awn_applet_create_about_item_simple(AWN_APPLET(priv->applet),
                                               "Copyright 2007,2008, 2009 Rodney Cryderman <*****@*****.**>",
                                               AWN_APPLET_LICENSE_GPLV2,
                                               VERSION);
      gtk_menu_shell_append(GTK_MENU_SHELL(priv->context_menu), item);
      g_signal_connect(G_OBJECT(priv->context_menu), "deactivate", G_CALLBACK(_deactivate_event), icon);
    }
    if (!priv->autohide_cookie)
    {
      priv->autohide_cookie = awn_applet_inhibit_autohide (AWN_APPLET(priv->applet),"CairoMenu" );
    }
    awn_icon_popup_gtk_menu (AWN_ICON (icon), priv->context_menu, event->button, event->time);
    g_object_set(awn_overlayable_get_effects (AWN_OVERLAYABLE(icon)), "depressed", FALSE,NULL);
    awn_utils_show_menu_images (GTK_MENU (priv->context_menu));
  }
  else
  {
    return TRUE;
  }

  awn_icon_set_is_active (AWN_ICON(icon), TRUE);
  return TRUE;
}
gint
main (gint argc, gchar **argv)
{
  GtkWidget   *window, *icon_box, *vbox;
  GdkScreen   *screen;
  GdkColormap *map;
  
  gtk_init (&argc, &argv);

  screen = gdk_screen_get_default ();
  map = gdk_screen_get_rgba_colormap (screen);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  if (map)
    gtk_widget_set_colormap (window, map);

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add( GTK_CONTAINER(window), vbox);

  icon_box = awn_icon_box_new ();
  gtk_container_add (GTK_CONTAINER (vbox), icon_box);

  icons[0] = AWN_ICON(pixbuf_icon (icon_box));
  icons[1] = AWN_ICON(cairo_icon (icon_box));
  icons[2] = AWN_ICON(surface_icon (icon_box));
  icons[3] = AWN_ICON(thin_surface_icon (icon_box));

  GtkWidget *button = gtk_button_new_with_label("Active");
  g_signal_connect(G_OBJECT(button), "clicked", 
                   G_CALLBACK(on_active_click), NULL);
  gtk_container_add (GTK_CONTAINER(vbox), button);

  GtkWidget *button2 = gtk_button_new_with_label("Running");
  g_signal_connect(G_OBJECT(button2), "clicked", 
                   G_CALLBACK(on_running_click), NULL);
  gtk_container_add (GTK_CONTAINER(vbox), button2);

  GtkWidget *button3 = gtk_button_new_with_label("Signal");
  g_signal_connect(G_OBJECT(button3), "clicked", 
                   G_CALLBACK(on_signal_click), NULL);
  gtk_container_add (GTK_CONTAINER(vbox), button3);

  gtk_widget_show_all (window);

  gtk_main ();
  return 0;
}
gchar *
awn_applet_simple_get_tooltip_text (AwnAppletSimple  *applet)
{
  g_return_val_if_fail (AWN_IS_APPLET_SIMPLE (applet), NULL);

  return awn_icon_get_tooltip_text (AWN_ICON (applet->priv->icon));
}
Exemplo n.º 8
0
static void
cairo_main_icon_constructed (GObject *object)
{
  CairoMainIconPrivate * priv = GET_PRIVATE (object);
  GdkPixbuf * pbuf;
  gint size = awn_applet_get_size (priv->applet);
  G_OBJECT_CLASS (cairo_main_icon_parent_class)->constructed (object);

  awn_themed_icon_set_info_simple (AWN_THEMED_ICON(object),"cairo-menu",awn_applet_get_uid (priv->applet),"gnome-main-menu");
  awn_themed_icon_set_size (AWN_THEMED_ICON (object),size);

  gtk_drag_dest_set (GTK_WIDGET (object),
                       GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
                       drop_types, n_drop_types,
                       GDK_ACTION_COPY | GDK_ACTION_ASK);
  /* call our function in the module */

  priv->menu_instance = get_menu_instance (priv->applet,
                                          (GetRunCmdFunc)cairo_menu_applet_get_run_cmd,
                                          (GetSearchCmdFunc)cairo_menu_applet_get_search_cmd,
                                          (AddIconFunc) cairo_menu_applet_add_icon,
                                          (CheckMenuHiddenFunc) cairo_menu_applet_check_hidden_menu,
                                          NULL,
                                          0);

  g_idle_add ( (GSourceFunc)queue_menu_build, object);
  awn_icon_set_tooltip_text (AWN_ICON (object), _("Main Menu"));
}
AwnIcon *  
awn_applet_simple_get_icon (AwnAppletSimple  *applet)
{
  g_return_val_if_fail (AWN_IS_APPLET_SIMPLE (applet), NULL);

  return AWN_ICON (applet->priv->icon);
}
void  
awn_applet_simple_set_effect (AwnAppletSimple  *applet,
                              AwnEffect         effect)
{
  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));

  awn_icon_set_effect (AWN_ICON (applet->priv->icon), effect);
}
void 
awn_applet_simple_set_tooltip_text (AwnAppletSimple  *applet,
                                    const gchar      *title)
{
  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));
  
  awn_icon_set_tooltip_text (AWN_ICON (applet->priv->icon), title);
}
static gboolean
throbber_click (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
  AwnAppletProxyPrivate *priv = AWN_APPLET_PROXY_GET_PRIVATE(user_data);

  if (!priv->running)
  {
    priv->crashed = FALSE;
    awn_icon_set_tooltip_text (AWN_ICON (priv->throbber),
                               _("Loading applet..."));
    awn_throbber_set_type (AWN_THROBBER (priv->throbber),
                           AWN_THROBBER_TYPE_NORMAL);
    awn_icon_set_hover_effects (AWN_ICON (priv->throbber), FALSE);

    awn_applet_proxy_execute (AWN_APPLET_PROXY (user_data));
  }
  return FALSE;
}
/*
 * When the position changes, we need to update the size of the applet
 */
static void
awn_applet_simple_position_changed (AwnApplet *applet, GtkPositionType position)
{
  AwnAppletSimplePrivate *priv = AWN_APPLET_SIMPLE (applet)->priv;

  if (AWN_IS_ICON (priv->icon))
  {
    awn_icon_set_pos_type (AWN_ICON (priv->icon), position);
  }
}
static GtkWidget *
pixbuf_icon (GtkWidget *parent)
{
    GdkPixbuf *pixbuf;
    GtkWidget *icon;

    pixbuf = gdk_pixbuf_new_from_file_at_size (PICTURE_FILE, 50, 50, NULL);

    icon = awn_icon_new ();
    awn_icon_set_from_pixbuf (AWN_ICON (icon), pixbuf);
    awn_icon_set_pos_type (AWN_ICON (icon), GTK_POS_BOTTOM);
    awn_icon_set_tooltip_text (AWN_ICON (icon), "Pixbuf Icon");
    gtk_container_add (GTK_CONTAINER (parent), icon);
    gtk_widget_show (icon);

    g_signal_connect (icon, "button-release-event",
                      G_CALLBACK (on_click), parent);
    g_object_unref (pixbuf);
    return icon;
}
Exemplo n.º 15
0
static gboolean
_deactivate_event (GtkMenuShell *menushell,CairoMainIcon * icon)
{
  CairoMainIconPrivate * priv = GET_PRIVATE (icon);

  if (priv->autohide_cookie)
  {
    awn_applet_uninhibit_autohide (AWN_APPLET(priv->applet),priv->autohide_cookie);
    priv->autohide_cookie = 0;
  }
  awn_icon_set_is_active (AWN_ICON(icon), FALSE);
}
static gboolean
on_signal_click(GtkWidget *widget, gpointer user_data)
{
  AwnIcon *icon = AWN_ICON(icons[0]);

  AwnEffects *fx = awn_overlayable_get_effects (AWN_OVERLAYABLE (icon));
  awn_effects_start_ex(fx, AWN_EFFECT_OPENING, 1, TRUE, TRUE);

  g_object_set(fx, "arrow-png", "/usr/share/gimp/2.0/themes/Default/images/preferences/folders-gradients-22.png", NULL);

  return FALSE;
}
static void
awn_applet_simple_size_allocate (GtkWidget *widget, GtkAllocation *alloc)
{
  AwnAppletSimplePrivate *priv = AWN_APPLET_SIMPLE_GET_PRIVATE (widget);

  if (AWN_IS_ICON (priv->icon))
  {
    gint x = alloc->x + alloc->width / 2;
    gint y = alloc->y + alloc->height / 2;
    gint offset = awn_applet_get_offset_at (AWN_APPLET (widget), x, y);
    awn_icon_set_offset (AWN_ICON (priv->icon), offset);
  }
}
static GtkWidget *
thin_surface_icon (GtkWidget *parent)
{
  GtkWidget *icon;
  cairo_surface_t *surface;
  cairo_t *cr;

  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 25, 75);

  cr = cairo_create (surface);
  
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint (cr);

  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);

  cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.8);
  cairo_rectangle (cr, 0, 0, 25, 75);
  cairo_fill_preserve (cr);
  cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
  cairo_stroke (cr);

  cairo_destroy (cr);

  icon = awn_icon_new ();
  awn_icon_set_from_surface (AWN_ICON (icon), surface);
  awn_icon_set_tooltip_text (AWN_ICON (icon), "Thin Surface Icon");
  
  gtk_container_add (GTK_CONTAINER (parent), icon);
  gtk_widget_show (icon);

  g_signal_connect (icon, "button-release-event", 
                    G_CALLBACK (on_click), parent);

  cairo_surface_destroy (surface);

  return icon;
}
void
awn_throbber_set_size (AwnThrobber *throbber, gint size)
{
    gboolean is_horizontal;
    GtkPositionType pos_type;
    g_return_if_fail (AWN_IS_THROBBER (throbber));

    AwnThrobberPrivate *priv = throbber->priv;

    switch (priv->type)
    {
    case AWN_THROBBER_TYPE_ARROW_1:
    case AWN_THROBBER_TYPE_ARROW_2:
        pos_type = awn_icon_get_pos_type (AWN_ICON (throbber));
        is_horizontal = pos_type == GTK_POS_TOP || pos_type == GTK_POS_BOTTOM;
        if (is_horizontal)
        {
            awn_icon_set_custom_paint (AWN_ICON (throbber), size / 4, size);
        }
        else
        {
            awn_icon_set_custom_paint (AWN_ICON (throbber), size, size / 4);
        }
        priv->size = size;
        break;
    case AWN_THROBBER_TYPE_CLOSE_BUTTON:
        awn_icon_set_custom_paint (AWN_ICON (throbber), size / 2, size / 2);
        priv->size = size / 2;
        break;
    default:
        awn_icon_set_custom_paint (AWN_ICON (throbber), size, size);
        priv->size = size;
        break;
    }

    gtk_widget_queue_resize (GTK_WIDGET (throbber));
}
static void
on_child_exit (GPid pid, gint status, gpointer user_data)
{
  if (AWN_IS_APPLET_PROXY (user_data))
  {
    AwnAppletProxyPrivate *priv = AWN_APPLET_PROXY_GET_PRIVATE (user_data);

    /* FIXME: we could do something with the status var... nice error messages?! */
    /*
    switch (status)
    {
      case ???:
        awn_throbber_set_text (AWN_THROBBER (priv->throbber), _("..."));
        break;
      default:
        awn_throbber_set_text (AWN_THROBBER (priv->throbber), _("..."));
        break;
    }
    */

    priv->running = FALSE;
    priv->crashed = TRUE;

    awn_throbber_set_type (AWN_THROBBER (priv->throbber),
                           AWN_THROBBER_TYPE_SAD_FACE);
    awn_icon_set_tooltip_text (AWN_ICON (priv->throbber),
      _("Whoops! The applet crashed. Click to restart it."));
    awn_icon_set_hover_effects (AWN_ICON (priv->throbber), TRUE);

    g_signal_emit (user_data, _proxy_signals[APPLET_CRASHED], 0);
    /* we won't call gtk_widget_show - on_plug_removed does that
     * and if the plug wasn't even added, the throbber widget is still visible
     */
  }

  g_spawn_close_pid(pid); /* doesn't do anything on UNIX, but let's have it */
}
static void
awn_applet_simple_offset_changed (AwnApplet *applet, gint offset)
{
  AwnAppletSimplePrivate *priv = AWN_APPLET_SIMPLE (applet)->priv;

  if (AWN_IS_ICON (priv->icon))
  {
    GtkAllocation alloc;
    gtk_widget_get_allocation (GTK_WIDGET (priv->icon), &alloc);
    gint x = alloc.x + alloc.width / 2;
    gint y = alloc.y + alloc.height / 2;
    offset = awn_applet_get_offset_at (applet, x, y);
    awn_icon_set_offset (AWN_ICON (priv->icon), offset);
  }
}
/*
 * PUBLIC FUNCTIONS
 */
void    
awn_applet_simple_set_icon_pixbuf (AwnAppletSimple  *applet,
                                   GdkPixbuf        *pixbuf)
{
  AwnAppletSimplePrivate *priv;

  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));
  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
  priv = applet->priv;

  /* Make sure AwnThemedIcon doesn't update the icon of it's own accord */
  if (priv->last_set_icon == ICON_THEMED_SIMPLE 
      || priv->last_set_icon == ICON_THEMED_MANY)
    awn_themed_icon_clear_info (AWN_THEMED_ICON (priv->icon));

  priv->last_set_icon = ICON_PIXBUF;
  awn_icon_set_from_pixbuf (AWN_ICON (priv->icon), pixbuf);
}
void 
awn_applet_simple_set_icon_surface (AwnAppletSimple  *applet,
                                    cairo_surface_t  *surface)
{
  AwnAppletSimplePrivate *priv;

  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));
  g_return_if_fail (surface);
  priv = applet->priv;

  /* Make sure AwnThemedIcon doesn't update the icon of it's own accord */
  if (priv->last_set_icon == ICON_THEMED_SIMPLE
      || priv->last_set_icon == ICON_THEMED_MANY)
    awn_themed_icon_clear_info (AWN_THEMED_ICON (priv->icon));

  priv->last_set_icon = ICON_CAIRO;
  awn_icon_set_from_surface (AWN_ICON (priv->icon), surface);
}
static void
awn_applet_proxy_init (AwnAppletProxy *proxy)
{
  AwnAppletProxyPrivate *priv;

  priv = proxy->priv = AWN_APPLET_PROXY_GET_PRIVATE (proxy);

  /* Connect to the socket signals */
  g_signal_connect (proxy, "plug-removed", G_CALLBACK (on_plug_removed), NULL);
  g_signal_connect (proxy, "size-allocate", G_CALLBACK (on_size_alloc), NULL);
  awn_utils_ensure_transparent_bg (GTK_WIDGET (proxy));
  /* Rest is for the crash notification window */
  priv->running = TRUE;
  priv->crashed = FALSE;

  priv->throbber = awn_throbber_new_with_config (
      awn_config_get_default (0, NULL));

  awn_icon_set_tooltip_text (AWN_ICON (priv->throbber),
                             _("Loading applet..."));

  g_signal_connect (priv->throbber, "button-release-event",
                    G_CALLBACK (throbber_click), proxy);
}
Exemplo n.º 25
0
static gboolean 
_awn_CPUicon_update_icon(gpointer object)
{  

  AwnCPUiconPrivate * priv;  
  AwnSysmoniconPrivate * sysmonicon_priv=NULL;  
  AwnCPUicon * icon = object;
  AwnGraphSinglePoint *point;
  GList * list = NULL;
  gchar *text;
  priv = AWN_CPUICON_GET_PRIVATE (object);
  sysmonicon_priv = AWN_SYSMONICON_GET_PRIVATE (object);

  g_object_set (object,
                "invalidate",TRUE,
                NULL);
  
  /*FIXME change this to some type of graph_type thing */
  if ( (AWN_IS_AREAGRAPH(sysmonicon_priv->graph)) ||
        (AWN_IS_CIRCLEGRAPH(sysmonicon_priv->graph) ))
  {   
    point = g_new0 (AwnGraphSinglePoint,1);    
    *point = awn_CPUicon_get_load (object);
    /* Translators: %2.0lf is a number, %% is a percent sign, do not change them */
    text = g_strdup_printf (_("CPU: %2.0lf%%"),point->value);
//    awn_tooltip_set_text (AWN_TOOLTIP(sysmonicon_priv->tooltip),text);
    awn_icon_set_tooltip_text (AWN_ICON(object),text);    
    g_free (text);
    text = g_strdup_printf("%.0lf%%",point->value);  
    g_object_set (priv->text_overlay,
                  "text", text,
                 NULL);  
    g_free (text);
    
    list = g_list_prepend (list,point);
   
    awn_graph_add_data (sysmonicon_priv->graph,list);
    awn_sysmonicon_update_icon (AWN_SYSMONICON (icon));
    g_free (point);
    g_list_free (list);
  }
  else if ( AWN_IS_BARGRAPH(sysmonicon_priv->graph))
  {
    
#undef NOW
#undef LAST
#define LAST (priv->times[priv->now])
#define NOW (priv->times[priv->now ^ 1])
    
    AwnGraphSinglePoint avg_point = awn_CPUicon_get_load (object);      
    gint i;
    GList * iter;    
    glibtop_cpu cpu;
    glibtop_get_cpu(&cpu);
    
    for (i = 0; i < priv->num_cpus; i++)
    {
      gint64 total;
      gint64 total_used;
      gdouble percent_used;
      total = NOW[i][CPU_TOTAL] - LAST[i][CPU_TOTAL];
      total_used = NOW[i][CPU_USED] - LAST[i][CPU_USED];
      percent_used = total_used / (gdouble) total * 100.0;
      point = g_new0 (AwnGraphSinglePoint,1);      
      point->value = percent_used;
      list = g_list_prepend (list,point); 
    }
    text = g_strdup_printf (_("CPU: %2.0lf%%"),
                            avg_point.value
                            );
//    awn_tooltip_set_text (AWN_TOOLTIP(sysmonicon_priv->tooltip),text);
    awn_icon_set_tooltip_text (AWN_ICON(object),text);
    g_free (text);
    text = g_strdup_printf("%.0lf%%",avg_point.value);
    g_object_set (priv->text_overlay,
                  "text", text,
                 NULL);  
    g_free (text);
    
    awn_graph_add_data (sysmonicon_priv->graph,list);
    awn_sysmonicon_update_icon (AWN_SYSMONICON (icon));
    for (iter = list; iter; iter=g_list_next(iter))
    {
      g_free(iter->data);
    }
    g_list_free (list);    
#undef NOW
#undef LAST
      
  }
  return TRUE;
}
static gboolean
awn_throbber_expose_event (GtkWidget *widget, GdkEventExpose *event)
{
    AwnThrobberPrivate *priv = AWN_THROBBER (widget)->priv;
    cairo_t *cr;
    gint w, h;
    GtkPositionType pos_type;

    /* clip the drawing region, nvidia likes it */
    AwnEffects *fx = awn_overlayable_get_effects (AWN_OVERLAYABLE (widget));
    cr = awn_effects_cairo_create_clipped (fx, event);

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);

    // we'll paint to [0,0] - [1,1], so scale's needed
    g_object_get (G_OBJECT (widget), "icon-width", &w, "icon-height", &h, NULL);
    cairo_scale (cr, w, h);

    switch (priv->type)
    {
    case AWN_THROBBER_TYPE_NORMAL:
    {
        const gdouble RADIUS = 0.0625;
        const gdouble DIST = 0.3;
        const gdouble OTHER = DIST * 0.707106781; /* sqrt(2)/2 */
        const gint COUNT = 8;
        const gint counter = priv->counter;

        cairo_set_line_width (cr, 1. / priv->size);
        cairo_translate (cr, 0.5, 0.5);
        cairo_scale (cr, 1, -1);

#define PAINT_CIRCLE(cr, x, y, cnt) \
    awn_cairo_set_source_color_with_alpha_multiplier (cr, \
        priv->fill_color, ((counter+cnt) % COUNT) / (float)COUNT); \
    cairo_arc (cr, x, y, RADIUS, 0, 2*M_PI); \
    cairo_fill_preserve (cr); \
    awn_cairo_set_source_color_with_alpha_multiplier (cr, \
        priv->outline_color, ((counter+cnt) % COUNT) / (float)COUNT); \
    cairo_stroke (cr);

        PAINT_CIRCLE (cr, 0, DIST, 0);
        PAINT_CIRCLE (cr, OTHER, OTHER, 1);
        PAINT_CIRCLE (cr, DIST, 0, 2);
        PAINT_CIRCLE (cr, OTHER, -OTHER, 3);
        PAINT_CIRCLE (cr, 0, -DIST, 4);
        PAINT_CIRCLE (cr, -OTHER, -OTHER, 5);
        PAINT_CIRCLE (cr, -DIST, 0, 6);
        PAINT_CIRCLE (cr, -OTHER, OTHER, 7);

#undef PAINT_CIRCLE

        break;
    }
    case AWN_THROBBER_TYPE_SAD_FACE:
    {
        cairo_set_line_width (cr, 0.03);

        if (priv->fill_color == NULL)
        {
            GdkColor c;
            double r, g, b;

            c = gtk_widget_get_style (widget)->fg[GTK_STATE_NORMAL];
            r = c.red / 65535.0;
            g = c.green / 65535.0;
            b = c.blue / 65535.0;

            cairo_set_source_rgb (cr, r, g, b);
        }
        else
        {
            awn_cairo_set_source_color_with_alpha_multiplier (cr,
                    priv->fill_color,
                    0.75);
        }

        paint_sad_face (cr);

        break;
    }
    case AWN_THROBBER_TYPE_ARROW_1:
        cairo_rotate (cr, M_PI);
        cairo_translate (cr, -1.0, -1.0);
    // no break
    case AWN_THROBBER_TYPE_ARROW_2:
    {
        pos_type = awn_icon_get_pos_type (AWN_ICON (widget));

        if (pos_type == GTK_POS_LEFT || pos_type == GTK_POS_RIGHT)
        {
            cairo_rotate (cr, 0.5 * M_PI);
            cairo_translate (cr, 0.0, -1.0);
        }

        if (priv->outline_color)
        {
            cairo_set_line_width (cr, 3.5 / priv->size);
            awn_cairo_set_source_color (cr, priv->outline_color);

            cairo_move_to (cr, 0.125, 0.375);
            cairo_line_to (cr, 0.875, 0.5);
            cairo_line_to (cr, 0.125, 0.625);
            cairo_stroke (cr);
        }

        cairo_set_line_width (cr, 1.75 / priv->size);

        if (priv->fill_color == NULL)
        {
            GdkColor c = gtk_widget_get_style (widget)->fg[GTK_STATE_NORMAL];
            double r = c.red / 65535.0;
            double g = c.green / 65535.0;
            double b = c.blue / 65535.0;

            cairo_set_source_rgb (cr, r, g, b);
        }
        else
        {
            awn_cairo_set_source_color (cr, priv->fill_color);
        }

        cairo_move_to (cr, 0.125, 0.375);
        cairo_line_to (cr, 0.875, 0.5);
        cairo_line_to (cr, 0.125, 0.625);
        cairo_stroke (cr);

        break;
    }
    case AWN_THROBBER_TYPE_CLOSE_BUTTON:
    {
        cairo_set_line_width (cr, 1. / priv->size);

        cairo_pattern_t *pat = cairo_pattern_create_linear (0.0, 0.0, 0.5, 1.0);
        cairo_pattern_add_color_stop_rgb (pat, 0.0, 0.97254, 0.643137, 0.403921);
        //cairo_pattern_add_color_stop_rgb (pat, 0.0, 0.0, 0.0, 0.0); // test
        cairo_pattern_add_color_stop_rgb (pat, 0.7, 0.98823, 0.4, 0.0);
        cairo_pattern_add_color_stop_rgb (pat, 1.0, 0.98823, 0.4, 0.0);

        cairo_set_source (cr, pat);
        //cairo_arc (cr, 0.5, 0.5, 0.4, 0.0, 2 * M_PI);
        awn_cairo_rounded_rect (cr, 0.1, 0.1, 0.8, 0.8, 0.15, ROUND_ALL);
        cairo_fill_preserve (cr);

        cairo_pattern_destroy (pat);

        cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
        cairo_stroke (cr);

        cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
        cairo_set_line_width (cr, 2./priv->size);

        /*  \  starting with the upper point  */
        cairo_move_to (cr, 0.3, 0.25);
        cairo_line_to (cr, 0.7, 0.75);
        cairo_stroke (cr);
        /*  /  starting with the upper point  */
        cairo_move_to (cr, 0.7, 0.25);
        cairo_line_to (cr, 0.3, 0.75);
        cairo_stroke (cr);
        break;
    }
    default:
        break;
    }

    /* let effects know we're finished */
    awn_effects_cairo_destroy (fx);

    return TRUE;
}