Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 3478b351a5
Fetching contributors…

Cannot retrieve contributors at this time

file 116 lines (88 sloc) 2.658 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <X11/Xmu/WinUtil.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#include "panel.h"
#include "misc.h"

#include "eggtraymanager.h"
#include "fixedtip.h"
#include "main.h"

//#define DEBUG
#include "dbg.h"


typedef struct {
    GtkWidget *mainw;
    panel *panel;
    GtkWidget *box;
    /////
    EggTrayManager *tray_manager;
    
} tray;

static void
tray_added (EggTrayManager *manager, GtkWidget *icon, void *data)
{
    GtkWidget *box = (GtkWidget *)data;

    gtk_box_pack_end (GTK_BOX (box), icon, FALSE, FALSE, 0);
    gtk_widget_show (icon);
}

static void
tray_removed (EggTrayManager *manager, GtkWidget *icon, void *data)
{

}

static void
message_sent (EggTrayManager *manager, GtkWidget *icon, const char *text, glong id, glong timeout,
              void *data)
{
    /* FIXME multihead */
    int x, y;
    
    gdk_window_get_origin (icon->window, &x, &y);
  
    fixed_tip_show (0, x, y, FALSE, gdk_screen_height () - 50, text);
}

static void
message_cancelled (EggTrayManager *manager, GtkWidget *icon, glong id,
                   void *data)
{
  
}

void
tray_destructor(panel *p)
{
    tray *tr = (tray *)p->priv;

    ENTER;
    /* Make sure we drop the manager selection */
    g_object_unref (G_OBJECT (tr->tray_manager));
    fixed_tip_hide ();
    gtk_widget_destroy(tr->mainw);
    g_free(tr);
    RET();
}

int
tray_constructor(panel *p)
{
    tray *tr;
    GdkScreen *screen;
    
    ENTER;
    
    tr = g_new0(tray, 1);
    g_return_val_if_fail(tr != NULL, 0);
    p->priv = tr;
    tr->panel = p;
    tr->mainw = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
    tr->box = p->my_box_new(FALSE, 1);
    gtk_container_add (GTK_CONTAINER (tr->mainw), tr->box);
    gtk_container_add(GTK_CONTAINER(p->box), tr->mainw);
    
    screen = gtk_widget_get_screen (GTK_WIDGET (p->topgwin));
    
    if (egg_tray_manager_check_running(screen)) {
        ERR("another systray already running\n");
        RET(1);
    }
    tr->tray_manager = egg_tray_manager_new ();

    if (!egg_tray_manager_manage_screen (tr->tray_manager, screen))
        g_printerr ("System tray didn't get the system tray manager selection\n");
    
    g_signal_connect (tr->tray_manager, "tray_icon_added",
          G_CALLBACK (tray_added), tr->box);
    g_signal_connect (tr->tray_manager, "tray_icon_removed",
          G_CALLBACK (tray_removed), tr->box);
    g_signal_connect (tr->tray_manager, "message_sent",
          G_CALLBACK (message_sent), tr->box);
    g_signal_connect (tr->tray_manager, "message_cancelled",
          G_CALLBACK (message_cancelled), tr->box);
    
    
    RET(1);

}
Something went wrong with that request. Please try again.