/* * gpe-conf * * Copyright (C) 2002 Pierre TARDY * 2003 Florian Boor * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * GPE keybindings software setup utility (here: keylaunch) * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "applets.h" #include "keyctl.h" #include static char *keylaunchrc = NULL; static gboolean menuselect = FALSE; #define NUM_BUTTONS 5 #define NUM_COMMANDS 9 #define KEYLAUNCH_BIN PREFIX "/bin/keylaunch" /* local types */ typedef struct { char *pixname; char *ident; char *modificator; char *command; char *title; int type; } t_buttondef; typedef struct { char *title; char *command; } t_scommand; /* local variables */ static struct { GtkWidget *button[NUM_BUTTONS]; GdkPixbuf *p; GtkWidget *edit; GtkWidget *icon; GtkWidget *select; } self; t_buttondef buttondef[NUM_BUTTONS] = { {NULL, "XF86AudioRecord","???Pressed","gpe-soundbite record --autogenerate-filename $HOME_VOLATILE",0}, {NULL, "XF86Calendar","???Pressed","gpe-calendar",0}, {NULL, "telephone","???Pressed","gpe-contacts",0}, {NULL, "XF86Mail","???Pressed","gpe-taskmanager",0}, {NULL, "XF86Start","???Pressed","mbcontrol -desktop",0}}; t_scommand commands[NUM_COMMANDS] = { {NULL,""}, {NULL,"gpe-soundbite record --autogenerate-filename $HOME_VOLATILE"}, {NULL,"gpe-calendar"}, {NULL,"gpe-contacts"}, {NULL,"gpe-taskmanager"}, {NULL,"gpe-nmf"}, {NULL,"dillo"}, {NULL,"gpe-todo"}, {NULL,"mbcontrol -desktop"}}; static int active_button = 0; struct gpe_icon local_icons[] = { { "ipaq" , PREFIX "/share/pixmaps/ipaq-s1.png"}, { "button1", PREFIX "/share/pixmaps/ibutton1.png" }, { "button2", PREFIX "/share/pixmaps/ibutton2.png" }, { "button3", PREFIX "/share/pixmaps/ibutton3.png" }, { "button4", PREFIX "/share/pixmaps/ibutton4.png" }, { "button5", PREFIX "/share/pixmaps/ibutton5.png" }, { NULL, NULL } }; void FileSelected (char *file, gpointer data); void init_buttons () { FILE *fd; char *buffer = NULL; char *slash; int i; size_t len; active_button = 0; /* make string variables from initial constants */ /* modificators stay constant for now */ for (i=0;i 0) { for (i = 0;i < NUM_BUTTONS;i++) if (strlen(buffer) && (buffer[0] !='#') && strstr(buffer,buttondef[i].ident) && !strstr(buffer,"???Combine")) { slash = strrchr (buffer, ':'); if (slash && ((slash - buffer) > 0)) { slash++; if (slash[strlen(slash)-1] == '\n') slash[strlen(slash)-1] = 0; g_free(buttondef[i].command); buttondef[i].command = g_strdup(slash); } } } fclose (fd); } } void on_button_clicked (GtkButton * button, gpointer user_data) { ask_user_a_file ("/usr/bin", NULL, FileSelected, NULL, button); } void on_button_select (GtkButton * button, gpointer user_data) { int nr = (int)user_data; int i; char *bname; if ((nr == active_button) || ((active_button < 0) && (active_button >= NUM_BUTTONS))) return; g_free(buttondef[active_button].command); buttondef[active_button].command = g_strdup(gtk_entry_get_text(GTK_ENTRY(self.edit))); gtk_entry_set_text(GTK_ENTRY(self.edit),buttondef[nr].command); active_button = nr; bname = g_strdup_printf("button%i",nr+1); gtk_image_set_from_pixbuf(GTK_IMAGE(self.icon),gpe_find_icon(bname)); for (i=1;i