/[sido]/callbacks.c
ViewVC logotype

Diff of /callbacks.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 17 by ben, Fri Oct 16 20:27:45 2009 UTC revision 19 by ben, Sat Oct 17 00:31:21 2009 UTC
# Line 43  gboolean tooltip_display (gpointer app_d Line 43  gboolean tooltip_display (gpointer app_d
43  }  }
44    
45  /* handler for the volume button drag */  /* handler for the volume button drag */
46  void volume_on_event (GtkWidget* instance, gpointer app_data) {  void volume_on_change (GtkWidget* instance, gpointer app_data) {
47          gchar* cmd = NULL;          gchar* cmd = NULL;
48          gdouble value = 0;          gdouble value = 0;
49          AppData* d = (AppData*) app_data;          AppData* d = (AppData*) app_data;
# Line 55  void volume_on_event (GtkWidget* instanc Line 55  void volume_on_event (GtkWidget* instanc
55          instance = NULL;          instance = NULL;
56  }  }
57    
58    /* handler for volume slider leaving  (close) */
59    gboolean volume_on_leave (GtkWidget* instance, GdkEventCrossing* event, gpointer app_data)
60    {
61            AppData* d = (AppData*) app_data;
62    
63            gtk_widget_hide (d->vol_window);
64            gtk_widget_destroy (d->vol_window);
65            d->vol_window = NULL;
66            instance = NULL;
67            event = NULL;
68            return FALSE;
69    }
70    
71  /* handler for left-button click */  /* handler for left-button click */
72  void status_icon_on_left_click(GtkStatusIcon* instance, gpointer app_data) {  void status_icon_on_left_click(GtkStatusIcon* instance, gpointer app_data) {
73          AppData* d = (AppData*) app_data;          AppData* d = (AppData*) app_data;
         GtkWidget* window;  
74          gdouble curvol;          gdouble curvol;
75    
76          window = gtk_window_new(GTK_WINDOW_TOPLEVEL);          if (NULL != d->vol_window) /* already set up */
77          gtk_window_set_decorated (GTK_WINDOW(window), FALSE);                  return;
78          gtk_window_set_default_size(GTK_WINDOW(window), 24, 128);          d->vol_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
79          gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);          gtk_window_set_decorated (GTK_WINDOW(d->vol_window), FALSE);
80            gtk_window_set_default_size(GTK_WINDOW(d->vol_window), 25, 128);
81            gtk_window_set_position(GTK_WINDOW(d->vol_window), GTK_WIN_POS_MOUSE);
82          d->volume = gtk_vscale_new_with_range (0, 100, 1);          d->volume = gtk_vscale_new_with_range (0, 100, 1);
83          gtk_range_set_inverted(GTK_RANGE(d->volume), TRUE);          gtk_range_set_inverted(GTK_RANGE(d->volume), TRUE);
84          curvol = mpd_get_vol(d->sock);          curvol = mpd_get_vol(d->sock);
85          gtk_range_set_value(GTK_RANGE(d->volume), curvol);          gtk_range_set_value(GTK_RANGE(d->volume), curvol);
86          gtk_container_add (GTK_CONTAINER(window), d->volume);          gtk_container_add (GTK_CONTAINER(d->vol_window), d->volume);
87          g_signal_connect(G_OBJECT(d->volume), "value-changed", G_CALLBACK(volume_on_event), app_data);          g_signal_connect(G_OBJECT(d->volume), "value-changed", G_CALLBACK(volume_on_change), app_data);
88          g_signal_connect_swapped(G_OBJECT(d->volume), "leave-notify-event", G_CALLBACK(gtk_widget_destroy), window);          g_signal_connect(G_OBJECT(d->volume), "leave-notify-event", G_CALLBACK(volume_on_leave), app_data);
89          gtk_widget_show_all(window);          gtk_widget_show_all(d->vol_window);
90          instance = NULL;          instance = NULL;
91  }  }
92    

Legend:
Removed from v.17  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26