mocicon: mostly formatting cleanup

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2022-02-07 10:11:11 -05:00
parent 82d541698d
commit 7b25f80de6
Signed by: vbatts
GPG key ID: 10937E57733F1362

View file

@ -17,8 +17,8 @@ GtkWidget *menu, *quit_item, *launch_item, *play_item, *stop_item, *start_item,
static gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data); static gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data);
static void static void
send( GtkMenuItem *item, gpointer data) { send( GtkMenuItem *item, gpointer data)
{
switch(GPOINTER_TO_INT(data)) { switch(GPOINTER_TO_INT(data)) {
case PTR_START: case PTR_START:
g_spawn_command_line_async("mocp --play", NULL); g_spawn_command_line_async("mocp --play", NULL);
@ -46,14 +46,15 @@ send( GtkMenuItem *item, gpointer data) {
} }
} }
static void
static void setup() { setup()
{
GtkStatusIcon *icon; GtkStatusIcon *icon;
icon = gtk_status_icon_new_from_stock(GTK_STOCK_MEDIA_PLAY); icon = gtk_status_icon_new_from_stock(GTK_STOCK_MEDIA_PLAY);
g_signal_connect(icon,"button-press-event", G_CALLBACK(button_press_cb), NULL); g_signal_connect(icon,"button-press-event", G_CALLBACK(button_press_cb), NULL);
menu = gtk_menu_new(); menu = gtk_menu_new();
// Create Items // Create Items
start_item = gtk_image_menu_item_new_with_label("Start Server"); start_item = gtk_image_menu_item_new_with_label("Start Server");
stop_item = gtk_image_menu_item_new_with_label("Stop Server"); stop_item = gtk_image_menu_item_new_with_label("Stop Server");
next_item = gtk_image_menu_item_new_with_label("Next"); next_item = gtk_image_menu_item_new_with_label("Next");
@ -86,24 +87,25 @@ static void setup() {
gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit_item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit_item);
// show widgets // show widgets
gtk_widget_show_all(menu); gtk_widget_show_all(menu);
};
gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data)
{
// I am not entirely sure what to do, double click implementation is possible. say double click to get info. single click just pause/plays. but it will STILL register the first click, so it would pause and then give info.
// Idk. needs work.
{
if(ev->button == 3)
// Popup the menu
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, ev->button, ev->time);
}
if(ev->button == 2) {
send(NULL, GINT_TO_POINTER( PTR_NOTIFY ));
} }
gboolean
button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_data)
{
// I am not entirely sure what to do, double click implementation is
// possible. say double click to get info. single click just
// pause/plays. but it will STILL register the first click, so it would
// pause and then give info.
// Idk. needs work.
if(ev->button == 3) {
// Popup the menu
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, ev->button, ev->time);
}
if(ev->button == 2) {
send(NULL, GINT_TO_POINTER( PTR_NOTIFY ));
}
if(ev->button == 1) { if(ev->button == 1) {
send(NULL, GINT_TO_POINTER( PTR_PLAYTOGGLE )); send(NULL, GINT_TO_POINTER( PTR_PLAYTOGGLE ));
@ -114,7 +116,8 @@ gboolean button_press_cb(GtkStatusIcon *icon, GdkEventButton *ev, gpointer user_
//this whole section really should just be one function with an if/then statement instead of a dozen different little functions //this whole section really should just be one function with an if/then statement instead of a dozen different little functions
//play or pause //play or pause
gint main(gint argc, gchar **argv) gint
main(gint argc, gchar **argv)
{ {
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
setup(); setup();