From e53565a4fb3338d9eb7158c727cd5673b985b7b1 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 08:53:36 -0500 Subject: [PATCH 1/7] a little tidying Signed-off-by: Vincent Batts --- CHANGELOG | 5 ----- Makefile | 3 +-- README => README.md | 24 ++++++++++++------------ config.mk | 2 -- 4 files changed, 13 insertions(+), 21 deletions(-) rename README => README.md (61%) diff --git a/CHANGELOG b/CHANGELOG index af4b962..e254d7b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,8 +7,3 @@ -- Added notification support. Default IS notify-send, but you can redefine it in the source. variable is named notify (MUTU) -- GTK-STOCK-QUIT fix - - - - - diff --git a/Makefile b/Makefile index c3db02a..ee32fe4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ -# surf - simple browser -# See LICENSE file for copyright and license details. +#See LICENSE file for copyright and license details. include config.mk diff --git a/README b/README.md similarity index 61% rename from README rename to README.md index ccb726f..bea3943 100644 --- a/README +++ b/README.md @@ -1,31 +1,31 @@ -README +# mocicon Mocicon is a Music On Console tray icon for quick access. Report Bugs (which there aren't any) or suggestions to MutantTurkey@gmail.com, MutantTurkey@freenode.net By Calvin Morrison 2009 -Mocicon.sourceforge.net +https://sourceforge.net/projects/mocicon -OPTIONS/SOURCE: +## OPTIONS/SOURCE: The source is fairly simple, and there are plenty of options to go around. I don't do much source commenting, but it is all fairly self explanitory. -compiling without make:gcc -Wall -g -O2 mocicon.c -o mocicon `pkg-config --cflags --libs gtk+-2.0` +compiling without make: + +```shell +gcc -Wall -g -O2 mocicon.c -o mocicon $(pkg-config --cflags --libs gtk+-2.0) +``` with make it is the regular as root: -Make clean install +```shell +make clean install +``` it's simple enough. you'll need the gtk+ 2.0 libs and that's it. - -run ./install as root. it just installs mocicon in /usr/local/bin/ - - - - - +run `./install` as root. It just installs mocicon in `/usr/local/bin/` diff --git a/config.mk b/config.mk index ec568b6..4660fee 100644 --- a/config.mk +++ b/config.mk @@ -7,9 +7,7 @@ VERSION = 0.1.4 PREFIX = /usr MANPREFIX = ${PREFIX}/share/man - # includes and libs - GTKINC=$(shell pkg-config --cflags gtk+-2.0) GTKLIB=$(shell pkg-config --libs gtk+-2.0 ) From d3380eeca7b142dd1041c19401c46a1977dd2ff7 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 08:59:36 -0500 Subject: [PATCH 2/7] update to GTK+-3.0 is smooth :-) Signed-off-by: Vincent Batts --- config.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.mk b/config.mk index 4660fee..d962983 100644 --- a/config.mk +++ b/config.mk @@ -8,8 +8,8 @@ PREFIX = /usr MANPREFIX = ${PREFIX}/share/man # includes and libs -GTKINC=$(shell pkg-config --cflags gtk+-2.0) -GTKLIB=$(shell pkg-config --libs gtk+-2.0 ) +GTKINC=$(shell pkg-config --cflags gtk+-3.0) +GTKLIB=$(shell pkg-config --libs gtk+-3.0 ) INCS = -I. -I/usr/include ${GTKINC} LIBS = -L/usr/lib -lc ${GTKLIB} From ffbcc5a73296b97b37bf8dfd39cc7dae6f0e5609 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 09:01:43 -0500 Subject: [PATCH 3/7] README: show deps and gtk version Signed-off-by: Vincent Batts --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bea3943..79826e2 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,17 @@ https://sourceforge.net/projects/mocicon ## OPTIONS/SOURCE: -The source is fairly simple, and there are plenty of options to go around. -I don't do much source commenting, but it is all fairly self explanitory. +On debian, build dependencies install with: + +```shell +apt install -y build-essential libgtk-3-dev +``` + compiling without make: ```shell -gcc -Wall -g -O2 mocicon.c -o mocicon $(pkg-config --cflags --libs gtk+-2.0) +gcc -Wall -g -O2 mocicon.c -o mocicon $(pkg-config --cflags --libs gtk+-3.0) ``` with make it is the regular as root: @@ -25,7 +29,7 @@ with make it is the regular as root: make clean install ``` -it's simple enough. you'll need the gtk+ 2.0 libs and that's it. +it's simple enough. you'll need the gtk+ 3.0 libs and that's it. run `./install` as root. It just installs mocicon in `/usr/local/bin/` From 2b31077230625b0dbc66fa71663781edaabda4fc Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 09:24:26 -0500 Subject: [PATCH 4/7] LICENSE: make-shift effort to resepct attribution and otherwise Calvin did not assign a LICENSE (despite alluding to one), though Copyright was reserved. I emailed Calvin at MutantTurkey@gmail.com, but the email was returned as the account no longer exists. There once existed a https://github.com/mutantturkey/mocicon, but that account is also deleted. This MIT license likely legally may only cover chagnes introduced _after_ Calvin's orginal works. Signed-off-by: Vincent Batts --- LICENSE | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4df4519 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2009 Calvin Morrison + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 3ad2b807e872137712476b2fafee180f64f557a1 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 09:35:16 -0500 Subject: [PATCH 5/7] README: info about the attribution and original author Signed-off-by: Vincent Batts --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 79826e2..0646137 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,6 @@ # mocicon Mocicon is a Music On Console tray icon for quick access. -Report Bugs (which there aren't any) or suggestions to MutantTurkey@gmail.com, MutantTurkey@freenode.net - -By Calvin Morrison 2009 - -https://sourceforge.net/projects/mocicon - ## OPTIONS/SOURCE: @@ -16,7 +10,6 @@ On debian, build dependencies install with: apt install -y build-essential libgtk-3-dev ``` - compiling without make: ```shell @@ -33,3 +26,11 @@ it's simple enough. you'll need the gtk+ 3.0 libs and that's it. run `./install` as root. It just installs mocicon in `/usr/local/bin/` +## Attribution + +The MIT License was introduced for changes after the original author's works. +(The email addresses and existing contacts all bounced as the author deleted all those accounts) + +Copyright 2009 Calvin Morrison +Original project: https://sourceforge.net/projects/mocicon + From 82d541698d58b32a804c1fee1a62747889a99c4f Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 10:02:44 -0500 Subject: [PATCH 6/7] mocicon: define variables for the actions Signed-off-by: Vincent Batts --- mocicon.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/mocicon.c b/mocicon.c index abbe8f3..5829043 100644 --- a/mocicon.c +++ b/mocicon.c @@ -1,11 +1,18 @@ //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 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; +#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); @@ -13,25 +20,25 @@ static void send( GtkMenuItem *item, gpointer data) { switch(GPOINTER_TO_INT(data)) { - case 0: + case PTR_START: g_spawn_command_line_async("mocp --play", NULL); break; - case 1: + case PTR_PLAYTOGGLE: g_spawn_command_line_async("mocp --toggle-pause", NULL); break; - case 2: + case PTR_EXIT: g_spawn_command_line_async("mocp --exit", NULL); break; - case 3: + case PTR_NEXT: g_spawn_command_line_async("mocp --next", NULL); break; - case 4: + case PTR_PREV: g_spawn_command_line_async("mocp --previous", NULL); break; - case 5: + case PTR_NOTIFY: g_spawn_command_line_async(notify, NULL); break; - case 6: + case PTR_LAUNCH: g_spawn_command_line_async("xterm -C mocp", NULL); break; 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(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(play_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 1 )); - g_signal_connect(G_OBJECT(start_item),"activate", G_CALLBACK(send), GINT_TO_POINTER( 0 )); - g_signal_connect(G_OBJECT(stop_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 2 )); - g_signal_connect(G_OBJECT(next_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 3 )); - g_signal_connect(G_OBJECT(prev_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 4 )); - g_signal_connect(G_OBJECT(launch_item), "activate", G_CALLBACK(send), GINT_TO_POINTER( 6 )); + 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( PTR_START )); + 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( PTR_NEXT )); + 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( PTR_LAUNCH )); gtk_menu_shell_append(GTK_MENU_SHELL(menu), stop_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) { - send(NULL, GINT_TO_POINTER( 5 )); + send(NULL, GINT_TO_POINTER( PTR_NOTIFY )); } if(ev->button == 1) { - send(NULL, GINT_TO_POINTER( 1 )); + send(NULL, GINT_TO_POINTER( PTR_PLAYTOGGLE )); } return FALSE; } From 7b25f80de68e606c5bc103ed4b40263defc2f034 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 7 Feb 2022 10:11:11 -0500 Subject: [PATCH 7/7] mocicon: mostly formatting cleanup Signed-off-by: Vincent Batts --- mocicon.c | 139 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/mocicon.c b/mocicon.c index 5829043..6b4c6cf 100644 --- a/mocicon.c +++ b/mocicon.c @@ -17,59 +17,60 @@ 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 void -send( GtkMenuItem *item, gpointer data) { - - switch(GPOINTER_TO_INT(data)) { - case PTR_START: - g_spawn_command_line_async("mocp --play", NULL); - break; - case PTR_PLAYTOGGLE: - g_spawn_command_line_async("mocp --toggle-pause", NULL); - break; - case PTR_EXIT: - g_spawn_command_line_async("mocp --exit", NULL); - break; - case PTR_NEXT: - g_spawn_command_line_async("mocp --next", NULL); - break; - case PTR_PREV: - g_spawn_command_line_async("mocp --previous", NULL); - break; - case PTR_NOTIFY: - g_spawn_command_line_async(notify, NULL); - break; - case PTR_LAUNCH: - g_spawn_command_line_async("xterm -C mocp", NULL); - break; +send( GtkMenuItem *item, gpointer data) +{ + switch(GPOINTER_TO_INT(data)) { + case PTR_START: + g_spawn_command_line_async("mocp --play", NULL); + break; + case PTR_PLAYTOGGLE: + g_spawn_command_line_async("mocp --toggle-pause", NULL); + break; + case PTR_EXIT: + g_spawn_command_line_async("mocp --exit", NULL); + break; + case PTR_NEXT: + g_spawn_command_line_async("mocp --next", NULL); + break; + case PTR_PREV: + g_spawn_command_line_async("mocp --previous", NULL); + break; + case PTR_NOTIFY: + g_spawn_command_line_async(notify, NULL); + break; + case PTR_LAUNCH: + g_spawn_command_line_async("xterm -C mocp", NULL); + break; default: - break; - } + break; + } } - -static void setup() { +static void +setup() +{ GtkStatusIcon *icon; icon = gtk_status_icon_new_from_stock(GTK_STOCK_MEDIA_PLAY); g_signal_connect(icon,"button-press-event", G_CALLBACK(button_press_cb), NULL); menu = gtk_menu_new(); - -// Create Items - start_item = gtk_image_menu_item_new_with_label("Start Server"); - stop_item = gtk_image_menu_item_new_with_label("Stop Server"); - next_item = gtk_image_menu_item_new_with_label("Next"); - prev_item = gtk_image_menu_item_new_with_label("Previous"); - play_item = gtk_image_menu_item_new_with_label("Play/Pause"); - launch_item = gtk_image_menu_item_new_with_label("Launch Moc"); - quit_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); - + + // Create Items + start_item = gtk_image_menu_item_new_with_label("Start Server"); + stop_item = gtk_image_menu_item_new_with_label("Stop Server"); + next_item = gtk_image_menu_item_new_with_label("Next"); + prev_item = gtk_image_menu_item_new_with_label("Previous"); + play_item = gtk_image_menu_item_new_with_label("Play/Pause"); + launch_item = gtk_image_menu_item_new_with_label("Launch Moc"); + quit_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); + // Comment this section out if you don't want icons. sorry about the quit, it's stock. - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(start_item), gtk_image_new_from_stock(GTK_STOCK_YES, GTK_ICON_SIZE_MENU)); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(start_item), gtk_image_new_from_stock(GTK_STOCK_YES, GTK_ICON_SIZE_MENU)); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(stop_item), gtk_image_new_from_stock(GTK_STOCK_NO, GTK_ICON_SIZE_MENU)); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(next_item), gtk_image_new_from_stock(GTK_STOCK_MEDIA_FORWARD, GTK_ICON_SIZE_MENU)); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(prev_item), gtk_image_new_from_stock(GTK_STOCK_MEDIA_REWIND, 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)); - 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( PTR_PLAYTOGGLE )); 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( PTR_EXIT )); @@ -79,46 +80,48 @@ static void setup() { 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), play_item); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), play_item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), next_item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), prev_item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), launch_item); gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit_item); - // show widgets - 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 )); + // show widgets + gtk_widget_show_all(menu); } - - - if(ev->button == 1) { + +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) { send(NULL, GINT_TO_POINTER( PTR_PLAYTOGGLE )); - } + } return FALSE; } //this whole section really should just be one function with an if/then statement instead of a dozen different little functions //play or pause -gint main(gint argc, gchar **argv) +gint +main(gint argc, gchar **argv) { - gtk_init(&argc, &argv); - setup(); - gtk_main(); + gtk_init(&argc, &argv); + setup(); + gtk_main(); - return 0; + return 0; }