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);
}
void   
awn_applet_simple_set_icon_info (AwnAppletSimple  *applet,
                                 GStrv            states,
                                 GStrv            icon_names)
{
  gchar *applet_name=NULL;
  
  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));
  g_return_if_fail (states);
  g_return_if_fail (icon_names);

  g_object_get (applet,
                "canonical-name",&applet_name,
                NULL);  
  g_return_if_fail (applet_name);
  applet->priv->last_set_icon = ICON_THEMED_MANY;
  awn_themed_icon_set_size (AWN_THEMED_ICON (applet->priv->icon),
                            awn_applet_get_size (AWN_APPLET (applet)));
  awn_themed_icon_set_info (AWN_THEMED_ICON (applet->priv->icon),
                            applet_name,
                            awn_applet_get_uid (AWN_APPLET (applet)),
                            states,
                            icon_names);
  g_free (applet_name);
}
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;
}
Exemple #4
0
AwnApplet* awn_applet_factory_initp(const gchar *name,
                                    const gchar* uid, gint panel_id)
{
    AwnApplet *applet = AWN_APPLET(awn_applet_simple_new(name, uid, panel_id));
    CpuMeter *cpumeter;

    g_object_set (applet,
                  "display-name","Awn System Monitor",
                  NULL);
    gint height = awn_applet_get_size(applet);

    gtk_widget_set_size_request(GTK_WIDGET(applet), height*1.25, -1);


    GdkPixbuf *icon;
#if 0
    icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(),
                                    "gnome-main-menu",
                                    height - 2,
                                    0, NULL);
    awn_applet_simple_set_temp_icon(AWN_APPLET_SIMPLE(applet), icon);
#endif
    /*setting to a transparent pixbuf to begin with... awn-effects (I think)
    does not seem to deal well with having the icon set overly late*/

#if 1
    icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, height, height);
    gdk_pixbuf_fill(icon, 0x00000000);
    awn_applet_simple_set_icon_pixbuf(AWN_APPLET_SIMPLE(applet), icon);
#endif
    cpumeter = cpumeter_applet_new(applet);
    cpumeter->height = height;
    /*gtk_widget_show_all(GTK_WIDGET(applet));*/
    return applet;
}
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 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);
  }
}
void
cairo_main_icon_refresh_menu (CairoMainIcon * icon)
{
  g_return_if_fail (AWN_IS_CAIRO_MAIN_ICON(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;
  }
  priv->menu = menu_build (priv->menu_instance);
}
void
awn_applet_simple_set_icon_name (AwnAppletSimple  *applet,
                                 const gchar      *icon_name)
{
  gchar *applet_name;  
  
  g_return_if_fail (AWN_IS_APPLET_SIMPLE (applet));
  g_return_if_fail (icon_name);

  g_object_get (applet,
                "canonical-name",&applet_name,
                NULL);

  g_return_if_fail (applet_name);

  applet->priv->last_set_icon = ICON_THEMED_SIMPLE;
  awn_themed_icon_set_size (AWN_THEMED_ICON (applet->priv->icon),
                            awn_applet_get_size (AWN_APPLET (applet)));  
  awn_themed_icon_set_info_simple (AWN_THEMED_ICON (applet->priv->icon),
                                   applet_name,
                                   awn_applet_get_uid (AWN_APPLET (applet)),
                                   icon_name);
  g_free (applet_name);
}
Exemple #9
0
AwnApplet *
awn_applet_factory_initp (const gchar *name, gchar* uid, gint panel_id)
{
  g_on_error_stack_trace (NULL);
  html_init ();
  WebApplet *webapplet = g_malloc (sizeof (WebApplet));
  webapplet->uid=g_strdup(uid);
  webapplet->check_home = NULL;
  webapplet->location_dialog = NULL;
  webapplet->start = NULL;
  webapplet->applet = AWN_APPLET (awn_applet_simple_new (name, uid, panel_id));
  init_config (webapplet);
  gint height = awn_applet_get_size(webapplet->applet);

  awn_applet_simple_set_icon_name(AWN_APPLET_SIMPLE(webapplet->applet),
                                  ICON_NAME);
 
  /*gtk_widget_show_all (GTK_WIDGET (webapplet->applet));*/
  awn_html_dialog_new (webapplet);
  gtk_window_set_focus_on_map (GTK_WINDOW (webapplet->mainwindow), TRUE);
  g_signal_connect_after (G_OBJECT (webapplet->applet), "realize",
                          G_CALLBACK (_bloody_thing_has_style), webapplet);
  return webapplet->applet;
}