/[sido]/callbacks.c
ViewVC logotype

Diff of /callbacks.c

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

revision 16 by ben, Sun Oct 11 19:01:42 2009 UTC revision 17 by ben, Fri Oct 16 20:27:45 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, gdouble value, gpointer app_data) {  void volume_on_event (GtkWidget* instance, gpointer app_data) {
47          gchar* cmd = NULL;          gchar* cmd = NULL;
48            gdouble value = 0;
49          AppData* d = (AppData*) app_data;          AppData* d = (AppData*) app_data;
50    
51          cmd = g_strdup_printf ("setvol %.0f", value*100);          value = gtk_range_get_value(GTK_RANGE(d->volume));
52            cmd = g_strdup_printf ("setvol %.0f", value);
53          mpd_control (d->sock, cmd);          mpd_control (d->sock, cmd);
54          g_free (cmd);          g_free (cmd);
55          instance = NULL;          instance = NULL;
# Line 56  void volume_on_event (GtkWidget* instanc Line 58  void volume_on_event (GtkWidget* instanc
58  /* handler for left-button click */  /* handler for left-button click */
59  void status_icon_on_left_click(GtkStatusIcon* instance, gpointer app_data) {  void status_icon_on_left_click(GtkStatusIcon* instance, gpointer app_data) {
60          AppData* d = (AppData*) app_data;          AppData* d = (AppData*) app_data;
61          GtkVolumeButton* volume;          GtkWidget* window;
62          GtkWidget* popup;          gdouble curvol;
         double curvol;  
63    
64          volume = GTK_VOLUME_BUTTON(gtk_volume_button_new());          window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
65          curvol = mpd_get_vol(d->sock) / 100.0;          gtk_window_set_decorated (GTK_WINDOW(window), FALSE);
66          gtk_scale_button_set_value(GTK_SCALE_BUTTON(volume), curvol);          gtk_window_set_default_size(GTK_WINDOW(window), 24, 128);
67          popup = gtk_scale_button_get_popup(GTK_SCALE_BUTTON(volume));          gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
68          gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_MOUSE);          d->volume = gtk_vscale_new_with_range (0, 100, 1);
69          g_signal_connect(G_OBJECT(volume), "value-changed", G_CALLBACK(volume_on_event), app_data);          gtk_range_set_inverted(GTK_RANGE(d->volume), TRUE);
70          g_signal_connect_swapped(popup, "leave-notify-event", G_CALLBACK(gtk_widget_destroy), popup);          curvol = mpd_get_vol(d->sock);
71          gtk_widget_show_all(popup);          gtk_range_set_value(GTK_RANGE(d->volume), curvol);
72          instance = app_data = NULL;          gtk_container_add (GTK_CONTAINER(window), d->volume);
73            g_signal_connect(G_OBJECT(d->volume), "value-changed", G_CALLBACK(volume_on_event), app_data);
74            g_signal_connect_swapped(G_OBJECT(d->volume), "leave-notify-event", G_CALLBACK(gtk_widget_destroy), window);
75            gtk_widget_show_all(window);
76            instance = NULL;
77  }  }
78    
79  /* handler for right-button click */  /* handler for right-button click */

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

  ViewVC Help
Powered by ViewVC 1.1.26