mocicon: define variables for the actions
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
3ad2b807e8
commit
82d541698d
1 changed files with 23 additions and 16 deletions
39
mocicon.c
39
mocicon.c
|
@ -1,11 +1,18 @@
|
||||||
//MocIcon. see README for help.
|
//MocIcon. see README for help.
|
||||||
//compile with gcc -Wall -g mocicon.c -o mocicon `pkg-config --cflags --libs gtk+-2.0`
|
//compile with: gcc -Wall -g mocicon.c -o mocicon $(pkg-config --cflags --libs gtk+-3.0)
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
static char *notify = "bash -c 'notify-send -t 2000 \"$(mocp -Q %artist)\" \"$(mocp -Q %song)\" -i gtk-cdrom'";
|
static char *notify = "bash -c 'notify-send -t 2000 \"$(mocp -Q %artist)\" \"$(mocp -Q %song)\" -i gtk-cdrom'";
|
||||||
|
|
||||||
GtkWidget *menu, *quit_item, *launch_item, *play_item, *stop_item, *start_item, *next_item, *prev_item;
|
GtkWidget *menu, *quit_item, *launch_item, *play_item, *stop_item, *start_item, *next_item, *prev_item;
|
||||||
|
|
||||||
|
#define PTR_START 0
|
||||||
|
#define PTR_PLAYTOGGLE 1
|
||||||
|
#define PTR_EXIT 2
|
||||||
|
#define PTR_NEXT 3
|
||||||
|
#define PTR_PREV 4
|
||||||
|
#define PTR_NOTIFY 5
|
||||||
|
#define PTR_LAUNCH 6
|
||||||
|
|
||||||
static gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data);
|
static gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data);
|
||||||
|
|
||||||
|
@ -13,25 +20,25 @@ static void
|
||||||
send( GtkMenuItem *item, gpointer data) {
|
send( GtkMenuItem *item, gpointer data) {
|
||||||
|
|
||||||
switch(GPOINTER_TO_INT(data)) {
|
switch(GPOINTER_TO_INT(data)) {
|
||||||
case 0:
|
case PTR_START:
|
||||||
g_spawn_command_line_async("mocp --play", NULL);
|
g_spawn_command_line_async("mocp --play", NULL);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case PTR_PLAYTOGGLE:
|
||||||
g_spawn_command_line_async("mocp --toggle-pause", NULL);
|
g_spawn_command_line_async("mocp --toggle-pause", NULL);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case PTR_EXIT:
|
||||||
g_spawn_command_line_async("mocp --exit", NULL);
|
g_spawn_command_line_async("mocp --exit", NULL);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case PTR_NEXT:
|
||||||
g_spawn_command_line_async("mocp --next", NULL);
|
g_spawn_command_line_async("mocp --next", NULL);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case PTR_PREV:
|
||||||
g_spawn_command_line_async("mocp --previous", NULL);
|
g_spawn_command_line_async("mocp --previous", NULL);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case PTR_NOTIFY:
|
||||||
g_spawn_command_line_async(notify, NULL);
|
g_spawn_command_line_async(notify, NULL);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case PTR_LAUNCH:
|
||||||
g_spawn_command_line_async("xterm -C mocp", NULL);
|
g_spawn_command_line_async("xterm -C mocp", NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -63,12 +70,12 @@ static void setup() {
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(play_item), gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU));
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(play_item), gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU));
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(launch_item), gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU));
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(launch_item), gtk_image_new_from_stock(GTK_STOCK_EXECUTE, GTK_ICON_SIZE_MENU));
|
||||||
g_signal_connect(G_OBJECT(quit_item), "activate", G_CALLBACK(gtk_main_quit), NULL);
|
g_signal_connect(G_OBJECT(quit_item), "activate", G_CALLBACK(gtk_main_quit), NULL);
|
||||||
g_signal_connect(G_OBJECT(play_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 1 ));
|
g_signal_connect(G_OBJECT(play_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_PLAYTOGGLE ));
|
||||||
g_signal_connect(G_OBJECT(start_item),"activate", G_CALLBACK(send), GINT_TO_POINTER( 0 ));
|
g_signal_connect(G_OBJECT(start_item),"activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_START ));
|
||||||
g_signal_connect(G_OBJECT(stop_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 2 ));
|
g_signal_connect(G_OBJECT(stop_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_EXIT ));
|
||||||
g_signal_connect(G_OBJECT(next_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 3 ));
|
g_signal_connect(G_OBJECT(next_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_NEXT ));
|
||||||
g_signal_connect(G_OBJECT(prev_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 4 ));
|
g_signal_connect(G_OBJECT(prev_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_PREV ));
|
||||||
g_signal_connect(G_OBJECT(launch_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 6 ));
|
g_signal_connect(G_OBJECT(launch_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( PTR_LAUNCH ));
|
||||||
|
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), stop_item);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), stop_item);
|
||||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), start_item);
|
gtk_menu_shell_append(GTK_MENU_SHELL(menu), start_item);
|
||||||
|
@ -94,12 +101,12 @@ gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_
|
||||||
|
|
||||||
}
|
}
|
||||||
if(ev->button == 2) {
|
if(ev->button == 2) {
|
||||||
send(NULL, GINT_TO_POINTER( 5 ));
|
send(NULL, GINT_TO_POINTER( PTR_NOTIFY ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(ev->button == 1) {
|
if(ev->button == 1) {
|
||||||
send(NULL, GINT_TO_POINTER( 1 ));
|
send(NULL, GINT_TO_POINTER( PTR_PLAYTOGGLE ));
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue