Ticket #84: padevchooser-gtk-status-icon.patch

File padevchooser-gtk-status-icon.patch, 3.4 kB (added by lool, 2 years ago)

Adds support for GtkStatusIcon?

  • configure.ac

    old new  
    4343AC_SUBST(GUILIBS_CFLAGS) 
    4444AC_SUBST(GUILIBS_LIBS) 
    4545 
     46padc_save_cflags="$CFLAGS" 
     47CFLAGS="$GUILIBS_CFLAGS" 
     48AC_CHECK_HEADER([gtk/gtkstatusicon.h], [AC_DEFINE(HAVE_GTKSTATUSICON_H, 1, [Define to 1 if you have the <gtk/gtkstatusicon.h> header file.])]) 
     49CFLAGS="$padc_save_cflags" 
     50 
    4651if test -d ../pulseaudio ; then 
    4752   PULSE_CFLAGS='-I$(top_srcdir)/../pulseaudio/src' 
    4853   PULSE_LIBS='-L$(top_srcdir)/../pulseaudio/src/.libs -lpulse -lpulse-mainloop-glib -lpulse-browse' 
  • src/padevchooser.c

    old new  
    3838#include <pulse/browser.h> 
    3939#include <pulse/glib-mainloop.h> 
    4040 
     41#ifdef HAVE_GTKSTATUSICON_H 
     42#include <gtk/gtkstatusicon.h> 
     43#else 
    4144#include "eggtrayicon.h" 
     45#endif 
     46 
     47#include <gdk/gdkx.h> 
     48 
    4249#include "x11prop.h" 
    4350 
    4451#define GCONF_PREFIX "/apps/padevchooser" 
     
    5360static NotifyNotification *notification = NULL; 
    5461static gchar *last_events = NULL; 
    5562 
     63#ifdef HAVE_GTKSTATUSICON_H 
     64static GtkStatusIcon *tray_icon = NULL; 
     65#else 
    5666static EggTrayIcon *tray_icon = NULL; 
     67#endif 
    5768static gchar *current_server = NULL, *current_sink = NULL, *current_source = NULL; 
    5869static struct menu_item_info *current_source_menu_item_info = NULL, *current_sink_menu_item_info = NULL, *current_server_menu_item_info = NULL; 
    5970static GtkMenu *menu = NULL, *sink_submenu = NULL, *source_submenu = NULL, *server_submenu = NULL; 
     
    346357    look_for_current_menu_items(); 
    347358} 
    348359 
     360#ifdef HAVE_GTKSTATUSICON_H 
     361static 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 
    349365static void tray_icon_on_click(GtkWidget *widget, GdkEventButton* event) { 
    350366    if (event->type == GDK_BUTTON_PRESS) 
    351367        gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time); 
    352368} 
     369#endif 
    353370 
    354371static void start_manager_cb(void) { 
    355372    g_spawn_command_line_async("paman", NULL); 
     
    520537    set_server(input_dialog("Other Server", "Please enter server name:", current_server)); 
    521538} 
    522539 
     540#ifdef HAVE_GTKSTATUSICON_H 
     541static 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 
    523555static EggTrayIcon *create_tray_icon(void) { 
    524556    GtkTooltips *tips; 
    525557    EggTrayIcon *tray_icon; 
     
    541573 
    542574    return tray_icon; 
    543575} 
     576#endif 
    544577 
    545578static GtkWidget *append_menuitem(GtkMenu *m, const char *text, const char *icon_name) { 
    546579    GtkWidget *item;