Ticket #84: padevchooser-gtk-status-icon.patch
| File padevchooser-gtk-status-icon.patch, 3.4 kB (added by lool, 2 years ago) |
|---|
-
configure.ac
old new 43 43 AC_SUBST(GUILIBS_CFLAGS) 44 44 AC_SUBST(GUILIBS_LIBS) 45 45 46 padc_save_cflags="$CFLAGS" 47 CFLAGS="$GUILIBS_CFLAGS" 48 AC_CHECK_HEADER([gtk/gtkstatusicon.h], [AC_DEFINE(HAVE_GTKSTATUSICON_H, 1, [Define to 1 if you have the <gtk/gtkstatusicon.h> header file.])]) 49 CFLAGS="$padc_save_cflags" 50 46 51 if test -d ../pulseaudio ; then 47 52 PULSE_CFLAGS='-I$(top_srcdir)/../pulseaudio/src' 48 53 PULSE_LIBS='-L$(top_srcdir)/../pulseaudio/src/.libs -lpulse -lpulse-mainloop-glib -lpulse-browse' -
src/padevchooser.c
old new 38 38 #include <pulse/browser.h> 39 39 #include <pulse/glib-mainloop.h> 40 40 41 #ifdef HAVE_GTKSTATUSICON_H 42 #include <gtk/gtkstatusicon.h> 43 #else 41 44 #include "eggtrayicon.h" 45 #endif 46 47 #include <gdk/gdkx.h> 48 42 49 #include "x11prop.h" 43 50 44 51 #define GCONF_PREFIX "/apps/padevchooser" … … 53 60 static NotifyNotification *notification = NULL; 54 61 static gchar *last_events = NULL; 55 62 63 #ifdef HAVE_GTKSTATUSICON_H 64 static GtkStatusIcon *tray_icon = NULL; 65 #else 56 66 static EggTrayIcon *tray_icon = NULL; 67 #endif 57 68 static gchar *current_server = NULL, *current_sink = NULL, *current_source = NULL; 58 69 static struct menu_item_info *current_source_menu_item_info = NULL, *current_sink_menu_item_info = NULL, *current_server_menu_item_info = NULL; 59 70 static GtkMenu *menu = NULL, *sink_submenu = NULL, *source_submenu = NULL, *server_submenu = NULL; … … 346 357 look_for_current_menu_items(); 347 358 } 348 359 360 #ifdef HAVE_GTKSTATUSICON_H 361 static void tray_icon_on_click(GtkStatusIcon *status_icon, void * user_data) { 362 gtk_menu_popup(menu, NULL, NULL, gtk_status_icon_position_menu, status_icon, 1, gtk_get_current_event_time()); 363 } 364 #else 349 365 static void tray_icon_on_click(GtkWidget *widget, GdkEventButton* event) { 350 366 if (event->type == GDK_BUTTON_PRESS) 351 367 gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time); 352 368 } 369 #endif 353 370 354 371 static void start_manager_cb(void) { 355 372 g_spawn_command_line_async("paman", NULL); … … 520 537 set_server(input_dialog("Other Server", "Please enter server name:", current_server)); 521 538 } 522 539 540 #ifdef HAVE_GTKSTATUSICON_H 541 static GtkStatusIcon *create_tray_icon(void) { 542 GtkStatusIcon *tray_icon; 543 544 tray_icon = gtk_status_icon_new(); 545 /* handle left click on status icon; you may connect to the popup_menu 546 * signal for right-click, but it passes different args to the callback */ 547 g_signal_connect_object(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), tray_icon, 0); 548 gtk_status_icon_set_from_icon_name(tray_icon, "audio-card"); 549 gtk_status_icon_set_tooltip(tray_icon, "PulseAudio Applet"); 550 gtk_status_icon_set_visible(tray_icon, TRUE); 551 552 return tray_icon; 553 } 554 #else 523 555 static EggTrayIcon *create_tray_icon(void) { 524 556 GtkTooltips *tips; 525 557 EggTrayIcon *tray_icon; … … 541 573 542 574 return tray_icon; 543 575 } 576 #endif 544 577 545 578 static GtkWidget *append_menuitem(GtkMenu *m, const char *text, const char *icon_name) { 546 579 GtkWidget *item;
