~blackskad/gnomeradio/dev-vol-button

« back to all changes in this revision

Viewing changes to src/trayicon.c

  • Committer: mfcn
  • Date: 2008-09-13 15:05:32 UTC
  • Revision ID: svn-v3-trunk0:ba97a3d1-ec25-0410-b1c6-e06ad936ea6c:trunk:206
Tags: GNOMERADIO_1_8
        * configure.in:
        * src/Makefile.am:

        Version 1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "gui.h"
24
24
#include "trayicon.h"
25
25
 
 
26
extern GtkAdjustment *adj;
 
27
extern GtkTooltips *tooltips;
 
28
 
 
29
extern int mom_ps;
 
30
extern gnomeradio_settings settings;
 
31
 
26
32
static GtkWidget *showwindow_menuitem;
27
33
 
28
34
static void mute_menuitem_toggled_cb(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
104
110
        gtk_widget_show_all(tray_menu);
105
111
}
106
112
 
107
 
static gboolean tray_destroyed_cb(GtkWidget *widget, GdkEvent *event, gpointer data)
108
 
{
109
 
        create_tray_icon(GTK_WIDGET(data));
110
 
        return TRUE;
111
 
}
112
 
 
113
 
static gboolean tray_clicked_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
 
113
static void tray_activate_cb(GtkStatusIcon* icon, gpointer data)
114
114
{
115
115
        gboolean active;
116
 
        switch (event->button)
117
 
        {
118
 
                case 1:
119
 
                        if (event->type != GDK_BUTTON_PRESS)
120
 
                                break;
121
 
                        active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem));
122
 
                        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem), !active);
123
 
                        break;
124
 
                case 3:
125
 
                        if (event->type != GDK_BUTTON_PRESS)
126
 
                                break;
127
 
                        gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, NULL, event->button, event->time);
128
 
                        break;
129
 
        }                       
130
 
        return FALSE;
 
116
        active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem));
 
117
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(showwindow_menuitem), !active);
 
118
}
 
119
 
 
120
static void tray_popup_menu (GtkStatusIcon* icon, guint button, guint32 time, gpointer data)
 
121
{
 
122
        gtk_menu_popup(GTK_MENU(tray_menu), NULL, NULL, NULL, icon, button, time);
131
123
}       
132
124
 
133
125
void create_tray_icon(GtkWidget *app)
134
126
{
135
127
        GdkPixbuf *pixbuf;
136
 
        GtkWidget *tray_icon_image;
137
128
        GtkWidget *eventbox;
138
129
        GtkIconTheme *icontheme;
139
130
        char *text;
140
131
        
141
 
        tray_icon = GTK_WIDGET(egg_tray_icon_new (PACKAGE));
142
132
        icontheme = gtk_icon_theme_get_default();
143
133
        pixbuf = gtk_icon_theme_load_icon(icontheme, "gnomeradio", 22, 0, NULL);
144
134
        g_return_if_fail(pixbuf);
145
 
        tray_icon_image = gtk_image_new_from_pixbuf(pixbuf);
 
135
        tray_icon = G_OBJECT(gtk_status_icon_new_from_pixbuf(pixbuf));
146
136
        gdk_pixbuf_unref(pixbuf);
147
137
 
148
 
        eventbox = gtk_event_box_new();
149
 
        gtk_container_add(GTK_CONTAINER(eventbox), tray_icon_image);
150
 
        gtk_container_add (GTK_CONTAINER(tray_icon), eventbox);
151
138
 
152
 
        g_signal_connect(G_OBJECT(eventbox), "button-press-event", 
153
 
                G_CALLBACK(tray_clicked_cb), (gpointer)app);
154
 
        g_signal_connect(G_OBJECT(tray_icon), "destroy-event",
155
 
                G_CALLBACK(tray_destroyed_cb), (gpointer)app);
156
 
        gtk_widget_show_all(GTK_WIDGET(tray_icon));
 
139
        g_signal_connect(G_OBJECT(tray_icon), "activate", 
 
140
                G_CALLBACK(tray_activate_cb), (gpointer)app);
 
141
        g_signal_connect(G_OBJECT(tray_icon), "popup-menu",
 
142
                G_CALLBACK(tray_popup_menu), (gpointer)app);
157
143
        
158
144
        text = g_strdup_printf(_("Gnomeradio - %.2f MHz"), adj->value/STEPS);
159
 
        gtk_tooltips_set_tip(tooltips, tray_icon, text, NULL);
 
145
        gtk_status_icon_set_tooltip(GTK_STATUS_ICON(tray_icon), text);
160
146
        g_free(text);
161
147
}