]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - krell.c
Remove para_sdl_gui, para_slider, para_krell.
[paraslash.git] / krell.c
diff --git a/krell.c b/krell.c
deleted file mode 100644 (file)
index baafbf3..0000000
--- a/krell.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright (C) 2004-2005 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
-
-
-//#define PRINTF printf
-#define PRINTF(a, ...)
-
-#include <gkrellm2/gkrellm.h>
-#include <utime.h>
-#include <dirent.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-
-static void create_para_ctrl(GtkWidget *, gint);
-static void update_para_ctrl(void);
-static void create_tab(GtkWidget *);
-static void apply_config(void);
-static void load_config(gchar *);
-static void save_config(FILE *);
-
-static GkrellmMonitor monitor = {
-        "Parakrell",            /* Name, for config tab. */
-        0,                      /* Id,  0 if a plugin */
-        create_para_ctrl,       /* The create function */
-        update_para_ctrl,       /* The update function */
-        create_tab,             /* The config tab create function */
-        apply_config,           /* Apply the config function */
-        save_config,            /* Save user config */
-        load_config,            /* Load user config */
-        "para_krell",           /* config keyword */
-        NULL,                   /* Undefined 2  */
-        NULL,                   /* Undefined 1  */
-        NULL,                   /* Undefined 0  */
-        MON_APM,                /* Insert plugin before this monitor */
-        NULL,                   /* Handle if a plugin, filled in by GKrellM */
-        NULL                    /* path if a plugin, filled in by GKrellM */
-};
-
-typedef struct {
-       GkrellmPiximage *image;
-       GkrellmDecalbutton *button;
-       gint x,y,w,h;
-       double x_scale,y_scale;
-} ControlButton;
-
-static ControlButton prev_button = {
-       .image = NULL,
-       .button = NULL,
-       .x = 10,
-       .y = 10,
-       .w = 50,
-       .h = 50,
-       .x_scale = 1,
-       .y_scale = 1,
-};
-
-GkrellmPiximage *piximage;
-GkrellmPanel *panel;
-GtkWidget *fileread_vbox;
-GdkPixbuf *pixbuf;
-gint song_change_input_id;
-FILE *song_change_fd;
-GIOChannel *song_change_channel;
-
-static struct timeval sc_open_time;
-
-static gchar *info_text =
-        "Parakrell displays an image corresponding to the soundfile\n"
-        "currently played by paraslash.\n\n"
-
-        "The plugin's panel is divided in 9 small squares, like      \n"
-        "the numpad on a PC keyboard.  For each square there is an   \n"
-        "associated button and a number between 1 and 9.\n           \n"
-
-        "Each button is bound to three different commands for left,  \n"
-        "middle and right mouse button.  Middle and right button are \n"
-        "reserved for setting volume and jumping around in the song, \n"
-        "respectively. Left button works as follows:\n               \n"
-
-       "7  8  9                       7: slider, 8: sdl_gui, 9: next \n"
-       "4  5  6                       4: ps,     5: play,    6: dbadm \n"
-       "1  2  3                       1: stop,   2: gui,     3: pause\n"
-
-       "\n\nAuthor:\n"
-       "Andre Noll <maan@systemlinux.org>\n"
-       "Copyright (C) 2004-2005\n"
-       "Distributed under the GNU General Public License.\n";
-
-#define MAXLINE 255
-
-static gboolean launch_cmd(char *cmd)
-{
-
-       gchar **argv;
-       GError *err = NULL;
-       gboolean res;
-
-       PRINTF("%s: \n", __func__);
-        if (!cmd || *cmd == '\0')
-               return -1;
-
-        g_shell_parse_argv(cmd, NULL, &argv, NULL);
-       res = g_spawn_async(
-               NULL,
-               argv,
-               NULL,
-               G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
-               NULL,
-               NULL,
-               NULL,
-               &err
-       );
-        if (!res && err) {
-               gkrellm_message_dialog(NULL, err->message);
-               g_error_free(err);
-       }
-        g_strfreev(argv);
-       return res;
-}
-
-static gboolean cb_in_button(GkrellmDecalbutton *b,
-       GdkEventButton *ev, ControlButton *cbut)
-{
-       gint x, y, area, width = gkrellm_chart_width();
-       x = (int) (3 * ev->x / width);
-       y = (int) (3 - 3 * ev->y / width);
-       area = 3 * y + x + 1;
-       char buf[MAXLINE];
-
-       PRINTF("%s: button %i pressed on area %i\n", __func__,
-               ev->button, area);
-       if (ev->button == 1) {
-               switch (area) {
-               case 1:
-                       launch_cmd("para_client stop");
-                       return 0;
-               case 2:
-                       launch_cmd("xterm -e para_gui -a");
-                       return 0;
-               case 3:
-                       launch_cmd("para_client pause");
-                       return 0;
-               case 4:
-                       launch_cmd("para_client ps");
-                       return 0;
-               case 5:
-                       launch_cmd("para_client play");
-                       return 0;
-               case 6:
-                       launch_cmd("xterm -e para_dbadm");
-                       return 0;
-               case 7:
-                       launch_cmd("para_slider");
-                       return 0;
-               case 8:
-                       launch_cmd("para_sdl_gui -f");
-                       return 0;
-               case 9:
-                       launch_cmd("para_client next");
-                       return 0;
-               }
-               return 0;
-       }
-       sprintf(buf, "%s %i", ev->button == 2? "aumix -v" : "para_client jmp",
-               area * 10);
-       return launch_cmd(buf);
-}
-
-static void make_button(ControlButton *cbut, gint fn_id)
-{
-       PRINTF("%s: gkrellm_make_scaled_button\n", __func__);
-        cbut->button = gkrellm_make_scaled_button(
-               panel,
-               cbut->image,
-                NULL,
-               GINT_TO_POINTER(fn_id),
-               FALSE,
-               FALSE,
-               2,
-               0,
-               1,
-                cbut->x,
-               cbut->y,
-               cbut->w,
-               cbut->h
-       );
-       PRINTF("%s: making botton\n", __func__);
-        gkrellm_set_in_button_callback(cbut->button, cb_in_button, cbut);
-}
-
-
-static void load_img(void)
-{
-       gint width = gkrellm_chart_width();
-       gint out = 0, ret;
-       FILE *pipe = NULL;
-       char buf[MAXLINE];
-       size_t num_read = 0;
-       gchar *filename = gkrellm_make_data_file_name("para", "pic.jpg");
-
-       PRINTF("%s: Opening %s\n", __func__, filename);
-       if ((out = creat(filename, S_IRUSR | S_IWUSR)) < 0) {
-               perror("open");
-               goto out;
-       }
-       pipe = popen("para_client pic", "r");
-       if (!pipe)
-               goto out;
-       while ((ret = read(fileno(pipe), buf, sizeof(buf) - 1)) > 0) {
-               if (write(out, buf, ret) < 0) {
-                       perror("Write");
-                       goto out;
-               }
-               num_read += ret;
-       }
-       if (ret < 0) {
-               PRINTF("%s: Read Error\n", __func__);
-               goto out;
-       }
-       PRINTF("%s: new pic created (%i bytes)\n", __func__, num_read);
-       if (num_read < 500)
-               goto out;
-
-       if (piximage) {
-               gkrellm_destroy_piximage(piximage);
-               g_free(pixbuf);
-       }
-       PRINTF("%s: creating new piximage\n", __func__);
-       piximage = gkrellm_piximage_new_from_file(filename);
-       if (!piximage) {
-               PRINTF("%s: can not load image\n", __func__);
-               goto out;
-       }
-       pixbuf = gkrellm_scale_piximage_to_pixbuf(piximage, width, width);
-out:
-       g_free(filename);
-       if (pipe)
-               pclose(pipe);
-       if (out)
-               close(out);
-}
-
-static void create_tab(GtkWidget *tab_vbox)
-{
-       GtkTextBuffer *textbuf;
-       GtkWidget *text;
-       GtkWidget *scrolled, *vbox = tab_vbox;
-
-       PRINTF("%s: \n", __func__);
-
-       scrolled = gtk_scrolled_window_new(NULL, NULL);
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
-                                      GTK_POLICY_AUTOMATIC,
-                                      GTK_POLICY_AUTOMATIC);
-       textbuf = gtk_text_buffer_new(NULL);
-       gtk_text_buffer_set_text(textbuf, info_text, -1);
-       text = gtk_text_view_new_with_buffer(textbuf);
-       gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
-       gtk_container_add(GTK_CONTAINER(scrolled), text);
-       gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
-}
-
-static gboolean song_change(GIOChannel *channel, GIOCondition condition,
-               gpointer panel)
-{
-       char *str_return;
-       gsize length;
-
-       PRINTF("%s: input condition %i "
-               "(song_change channel fd = %i)\n", __func__, condition,
-               g_io_channel_unix_get_fd(song_change_channel));
-       if (!song_change_fd) {
-               PRINTF("%s: no song_change_fd\n", __func__);
-               goto err_out;
-       }
-       if (!(condition & (G_IO_IN | G_IO_PRI))) {
-               PRINTF("%s: song change pipe died\n", __func__);
-               song_change_fd = NULL;
-               wait(NULL);
-               return TRUE;
-               goto err_out;
-       }
-       if (!channel->is_readable) {
-               PRINTF("%s: fd not readable\n", __func__);
-               goto err_out;
-       }
-       PRINTF("%s: reading data\n", __func__);
-       if (g_io_channel_read_line(channel, &str_return,
-                       &length, NULL, NULL) == G_IO_STATUS_NORMAL) {
-               PRINTF("%s: next song: %s", __func__, str_return);
-               g_free(str_return);
-               if (channel != song_change_channel)
-                       goto err_out;
-               load_img();
-               return TRUE;
-       }
-err_out:
-       g_io_channel_unref(channel);
-       g_io_channel_shutdown(channel, TRUE, NULL);
-       return FALSE;
-}
-
-static void create_song_change(void)
-{
-       if (song_change_fd)
-               return;
-       gettimeofday(&sc_open_time, NULL);
-       PRINTF("%s: para_client sc\n", __func__);
-       song_change_fd = popen("para_client sc", "r");
-       if (!song_change_fd) {
-               PRINTF("%s: para_client sc failed\n", __func__);
-               return;
-       }
-       song_change_channel = g_io_channel_unix_new(fileno(song_change_fd));
-       g_io_channel_set_close_on_unref(song_change_channel, TRUE);
-       g_io_add_watch(song_change_channel,
-               G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-               &song_change, panel);
-}
-
-static void update_para_ctrl(void)
-{
-       GdkDrawable  *drawable = panel->drawing_area->window;
-       gint width = gkrellm_chart_width();
-
-       if (!drawable)
-               PRINTF("%s: No drawable\n", __func__);
-       else
-               gkrellm_paste_pixbuf(pixbuf, drawable, 0, 0, width, width);
-       if (!song_change_fd) {
-               struct timeval now;
-               PRINTF("%s: no song_change_fd\n", __func__);
-
-               gettimeofday(&now, NULL);
-               if (now.tv_sec > sc_open_time.tv_sec + 5)
-                       create_song_change();
-       }
-}
-
-static void destroy_panel(void)
-{
-       PRINTF("%s: \n", __func__);
-       if (!panel) 
-               return;
-       PRINTF("%s: destroying panel\n", __func__);
-       gkrellm_panel_destroy(panel);
-       panel = NULL;
-}
-
-#if 0
-static void destroy_song_change(void)
-{
-       PRINTF("%s: \n", __func__);
-       if (!song_change_fd)
-               return;
-}
-#endif
-static void destroy_all(void)
-{
-//     destroy_song_change();
-       destroy_panel();
-}
-
-static void create_para_ctrl(GtkWidget *vbox, gint first_create)
-{
-       gint style_id = gkrellm_lookup_meter_style_id(UPTIME_STYLE_NAME);
-       GkrellmStyle *style = gkrellm_meter_style(style_id);
-       gint width = gkrellm_chart_width();
-
-       destroy_all();
-       create_song_change();
-       panel = gkrellm_panel_new0();
-       gkrellm_panel_configure(panel, NULL, style);
-       gkrellm_panel_configure_set_height(panel, width);
-       PRINTF("%s: creating panel\n", __func__);
-       gkrellm_panel_create(vbox, &monitor, panel);
-       make_button(&prev_button, 1);
-}
-
-static void apply_config(void)
-{
-       PRINTF("%s: \n", __func__);
-}
-
-static void load_config(gchar * arg)
-{
-        PRINTF("%s: \n", __func__);
-
-}
-
-static void save_config(FILE * f)
-{
-        PRINTF("%s: \n", __func__);
-}
-
-GkrellmMonitor *gkrellm_init_plugin(void)
-{
-       return &monitor;
-}