static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

#if GTK_CHECK_VERSION(2,1,0)
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);
#else
      gdkwin = gdk_window_lookup (icon->manager_window);
#endif

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

#if GTK_CHECK_VERSION(2,1,0)
  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
#else
  root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
#endif

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
Exemple #2
0
static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
#ifdef GDK_WINDOWING_X11
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
#endif
}
static void
egg_tray_icon_realize (GtkWidget *widget)
{
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  gint screen;
  Display *xdisplay;
  char buffer[256];
  GdkWindow *root_window;

  if (GTK_WIDGET_CLASS (parent_class)->realize)
    GTK_WIDGET_CLASS (parent_class)->realize (widget);

  make_transparent (widget, NULL);

  xdisplay = egg_tray_icon_get_x_display(icon);

  if (xdisplay == NULL)
    return;

#if GTK_CHECK_VERSION(2,1,0)
  screen = gdk_screen_get_number (gtk_widget_get_screen (widget));
#else
  screen = XScreenNumberOfScreen (DefaultScreenOfDisplay (gdk_display));
#endif

  /* Now see if there's a manager window around */
  g_snprintf (buffer, sizeof (buffer),
	      "_NET_SYSTEM_TRAY_S%d",
	      screen);

  icon->selection_atom = XInternAtom (xdisplay, buffer, False);

  icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);

  icon->system_tray_opcode_atom = XInternAtom (xdisplay,
						   "_NET_SYSTEM_TRAY_OPCODE",
						   False);

  icon->orientation_atom = XInternAtom (xdisplay,
					"_NET_SYSTEM_TRAY_ORIENTATION",
					False);

  egg_tray_icon_update_manager_window (icon, FALSE);
  egg_tray_icon_send_dock_request (icon);

#if GTK_CHECK_VERSION(2,1,0)
  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
#else
  root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
#endif

  /* Add a root window filter so that we get changes on MANAGER */
  gdk_window_add_filter (root_window,
			 egg_tray_icon_manager_filter, icon);
}
Exemple #4
0
static void egg_tray_icon_unrealize (GtkWidget *widget) {
	EggTrayIcon *icon = EGG_TRAY_ICON (widget);
	GdkWindow *root_window=NULL;

	if (icon->manager_window != None) {
		gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

		if (GTK_WIDGET_CLASS (parent_class)->unrealize)
			(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
	}
}
Exemple #5
0
static void
egg_tray_icon_realize (GtkWidget *widget)
{
#ifdef GDK_WINDOWING_X11
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkScreen *screen;
  GdkDisplay *display;
  Display *xdisplay;
  char buffer[256];
  GdkWindow *root_window;

  if (GTK_WIDGET_CLASS (parent_class)->realize)
    GTK_WIDGET_CLASS (parent_class)->realize (widget);

  make_transparent (widget, NULL);

  screen = gtk_widget_get_screen (widget);
  display = gdk_screen_get_display (screen);
  xdisplay = gdk_x11_display_get_xdisplay (display);

  /* Now see if there's a manager window around */
  g_snprintf (buffer, sizeof (buffer),
	      "_NET_SYSTEM_TRAY_S%d",
	      gdk_screen_get_number (screen));

  icon->selection_atom = XInternAtom (xdisplay, buffer, False);
  
  icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
  
  icon->system_tray_opcode_atom = XInternAtom (xdisplay,
						   "_NET_SYSTEM_TRAY_OPCODE",
						   False);

  icon->orientation_atom = XInternAtom (xdisplay,
					"_NET_SYSTEM_TRAY_ORIENTATION",
					False);

  egg_tray_icon_update_manager_window (icon, FALSE);
  egg_tray_icon_send_dock_request (icon);

  root_window = gdk_screen_get_root_window (screen);
  
  /* Add a root window filter so that we get changes on MANAGER */
  gdk_window_add_filter (root_window,
			 egg_tray_icon_manager_filter, icon);
#endif
}
static void egg_tray_icon_get_property (GObject    *object,
                            guint       prop_id,
                            GValue     *value,
                            GParamSpec *pspec)
{
  EggTrayIcon *icon = EGG_TRAY_ICON (object);

  switch (prop_id)
    {
    case PROP_ORIENTATION:
      g_value_set_enum (value, icon->orientation);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Exemple #7
0
void wxTaskBarIcon::Private::size_allocate(int width, int height)
{
    int size = height;
    EggTrayIcon* icon = EGG_TRAY_ICON(m_eggTrayIcon);
    if (egg_tray_icon_get_orientation(icon) == GTK_ORIENTATION_VERTICAL)
        size = width;
    if (m_size == size)
        return;
    m_size = size;
    int w = m_bitmap.GetWidth();
    int h = m_bitmap.GetHeight();
    if (w > size || h > size)
    {
        if (w > size) w = size;
        if (h > size) h = size;
        GdkPixbuf* pixbuf =
            gdk_pixbuf_scale_simple(m_bitmap.GetPixbuf(), w, h, GDK_INTERP_BILINEAR);
        GtkImage* image = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(m_eggTrayIcon)));
        gtk_image_set_from_pixbuf(image, pixbuf);
        g_object_unref(pixbuf);
    }
}
Exemple #8
0
static void
egg_status_icon_size_allocate (EggStatusIcon *status_icon,
			       GtkAllocation *allocation)
{
  GtkOrientation orientation;
  gint size;
  gboolean alloc_changed = FALSE;

  orientation = egg_tray_icon_get_orientation (EGG_TRAY_ICON (status_icon->priv->tray_icon));

  if (orientation == GTK_ORIENTATION_HORIZONTAL)
    size = allocation->height;
  else
    size = allocation->width;
  
  if ((status_icon->priv->alloc_height != allocation->height) ||
       (status_icon->priv->alloc_width != allocation->width))
  {
    status_icon->priv->alloc_height = allocation->height;
    status_icon->priv->alloc_width = allocation->width;
    alloc_changed = TRUE;
  }
  
  if (status_icon->priv->size != size)
    {
      status_icon->priv->size = size;
      g_object_notify (G_OBJECT (status_icon), "size");
      emit_size_changed_signal (status_icon, size);
      alloc_changed = TRUE;
    }
    
    if (alloc_changed)
    {
      egg_status_icon_update_image (status_icon);
    }
}
Exemple #9
0
static void
egg_status_icon_update_image (EggStatusIcon *status_icon)
{
  if (status_icon->priv->blink_off)
    {
      gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image),
				 egg_status_icon_blank_icon (status_icon));
      return;
    }

  switch (status_icon->priv->image_type)
    {
    case GTK_IMAGE_PIXBUF:
      {
	GdkPixbuf *pixbuf;

	pixbuf = status_icon->priv->image_data.pixbuf;

	if (pixbuf)
	  {
	    GdkPixbuf *scaled;
	    gint size;
	    gint width;
	    gint height;

	    size = status_icon->priv->size;

	    width  = gdk_pixbuf_get_width  (pixbuf);
	    height = gdk_pixbuf_get_height (pixbuf);

	    if (width > size || height > size)
	      {
                scaled = gdk_pixbuf_scale_simple (pixbuf,
                                                        MIN (size, width),
                                                        MIN (size, height),
                                                        GDK_INTERP_BILINEAR);
	      }
	    else
              {
                scaled = g_object_ref (pixbuf);
              }

	    gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), scaled);

            /* Sets the icon's transparency mask as the window's shape mask.
               Note: This doesn't handle translucency (partial transparency). */
            gint image_offset_x, image_offset_y;
            /* No way to know the image's real offset but by calculating ourselves. */
            {
              GtkOrientation orientation;
              gfloat xalign, yalign;
              gint xpad, ypad;
              GtkWidget* image = status_icon->priv->image;
              gtk_misc_get_padding(GTK_MISC(image), &xpad, &ypad);
              gtk_misc_get_alignment(GTK_MISC(image), &xalign, &yalign);
              /* We're aligning either horizontally or vertically, depending
                 on the orientation. According to this, we'll assume either
                 width or height to be preallocated up to the panel's size. */
              orientation = egg_tray_icon_get_orientation (EGG_TRAY_ICON (status_icon->priv->tray_icon));
              /* We base on the code found in gtk_image_expose */
              image_offset_x = floor(image->allocation.x + xpad + ((status_icon->priv->alloc_width - image->requisition.width) * xalign) + 0.5);
              image_offset_y = floor(image->allocation.y + ypad + ((status_icon->priv->alloc_height - image->requisition.height) * yalign) + 0.5);
            }
            GdkBitmap* scaled_mask = NULL;
            gdk_pixbuf_render_pixmap_and_mask(scaled, NULL, &scaled_mask, 0);
            if (scaled_mask)
            {
               /* It's only possible to set shape masks on real windows, so we have to set an offseted shape mask. */
               gtk_widget_shape_combine_mask(GTK_WIDGET(status_icon->priv->tray_icon), scaled_mask, image_offset_x, image_offset_y);
               g_object_unref(scaled_mask);
            }
	    
	    g_object_unref (scaled);
	  }
	else
	  {
	    gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), NULL);
	  }
      }
      break;
    case GTK_IMAGE_STOCK:
    case GTK_IMAGE_ANIMATION:
    case GTK_IMAGE_EMPTY:
      gtk_image_set_from_pixbuf (GTK_IMAGE (status_icon->priv->image), NULL);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
    
}