remove trailing whitespace
This commit is contained in:
parent
0a78bb3c74
commit
29e0d27bba
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
|
|
||||||
# this makefile is part of the "wmtrash" project.
|
# this makefile is part of the "wmtrash" project.
|
||||||
# Copyright (C) 2003 by Jean Philippe GUILLEMIN <jp.guillemin@free.fr>
|
# Copyright (C) 2003 by Jean Philippe GUILLEMIN <jp.guillemin@free.fr>
|
||||||
# license: This software is under GPL version 2 of license
|
# license: This software is under GPL version 2 of license
|
||||||
|
|
||||||
|
|
||||||
HEADERS =
|
HEADERS =
|
||||||
|
|
||||||
OBJECTS =
|
OBJECTS =
|
||||||
|
|
||||||
# customize install path as you need
|
# customize install path as you need
|
||||||
SRC = wmtrash.c
|
SRC = wmtrash.c
|
||||||
BIN = wmtrash
|
BIN = wmtrash
|
||||||
PREFIX = /usr
|
PREFIX = /usr
|
||||||
CONFDIR = /etc/wmtrash
|
CONFDIR = /etc/wmtrash
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
SHAREDIR = /share/wmtrash
|
SHAREDIR = /share/wmtrash
|
||||||
|
|
||||||
SRCPATH = .
|
SRCPATH = .
|
||||||
|
|
|
@ -30,17 +30,17 @@ int main( int argc, char *argv[] ) {
|
||||||
static char *homedir;
|
static char *homedir;
|
||||||
homecf = malloc(MEDIUM_STRING);
|
homecf = malloc(MEDIUM_STRING);
|
||||||
configfile = malloc(MEDIUM_STRING);
|
configfile = malloc(MEDIUM_STRING);
|
||||||
|
|
||||||
defaultcf = malloc(MEDIUM_STRING);
|
defaultcf = malloc(MEDIUM_STRING);
|
||||||
strncpy(defaultcf, __CONFPATH, MEDIUM_STRING);
|
strncpy(defaultcf, __CONFPATH, MEDIUM_STRING);
|
||||||
strcat(defaultcf, "/");
|
strcat(defaultcf, "/");
|
||||||
strcat(defaultcf, __CONFFILE);
|
strcat(defaultcf, __CONFFILE);
|
||||||
|
|
||||||
homedir = malloc(SHORT_STRING);
|
homedir = malloc(SHORT_STRING);
|
||||||
homedir = getenv("HOME");
|
homedir = getenv("HOME");
|
||||||
|
|
||||||
strncpy(homecf, homedir, SHORT_STRING);
|
strncpy(homecf, homedir, SHORT_STRING);
|
||||||
strcat(homecf, "/");
|
strcat(homecf, "/");
|
||||||
strcat(homecf, ".wmtrash.cf");
|
strcat(homecf, ".wmtrash.cf");
|
||||||
|
|
||||||
int test1, test2;
|
int test1, test2;
|
||||||
|
@ -49,9 +49,9 @@ int main( int argc, char *argv[] ) {
|
||||||
fprintf (stderr,"Error creating config file %s !\n",homecf);
|
fprintf (stderr,"Error creating config file %s !\n",homecf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (argc < 2){
|
if (argc < 2){
|
||||||
configfile = homecf;
|
configfile = homecf;
|
||||||
}else{
|
}else{
|
||||||
|
@ -64,8 +64,8 @@ int main( int argc, char *argv[] ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
dockapp = (GtkWidget *) build_dockapp(configfile);
|
dockapp = (GtkWidget *) build_dockapp(configfile);
|
||||||
gtk_widget_show_all (dockapp);
|
gtk_widget_show_all (dockapp);
|
||||||
|
@ -81,43 +81,43 @@ GtkWidget * build_dockapp(char *configfile) {
|
||||||
static GtkWidget *pixmap;
|
static GtkWidget *pixmap;
|
||||||
static GdkBitmap *mask;
|
static GdkBitmap *mask;
|
||||||
static GtkWidget *pixmap_widget;
|
static GtkWidget *pixmap_widget;
|
||||||
|
|
||||||
static struct wmtrash *wmtrash;
|
static struct wmtrash *wmtrash;
|
||||||
wmtrash = malloc(sizeof(struct wmtrash));
|
wmtrash = malloc(sizeof(struct wmtrash));
|
||||||
memset(wmtrash, 0, sizeof(struct wmtrash));
|
memset(wmtrash, 0, sizeof(struct wmtrash));
|
||||||
|
|
||||||
|
|
||||||
char *image_path_file;
|
char *image_path_file;
|
||||||
|
|
||||||
strncpy (wmtrash->param_img, "trashicon", MEDIUM_STRING);
|
strncpy (wmtrash->param_img, "trashicon", MEDIUM_STRING);
|
||||||
strncpy (wmtrash->param_fm, "filemanager", MEDIUM_STRING);
|
strncpy (wmtrash->param_fm, "filemanager", MEDIUM_STRING);
|
||||||
strncpy (wmtrash->param_path, "trashpath", MEDIUM_STRING);
|
strncpy (wmtrash->param_path, "trashpath", MEDIUM_STRING);
|
||||||
strncpy (wmtrash->configfile, configfile, MEDIUM_STRING);
|
strncpy (wmtrash->configfile, configfile, MEDIUM_STRING);
|
||||||
|
|
||||||
image_path_file = malloc(LONG_STRING);
|
image_path_file = malloc(LONG_STRING);
|
||||||
|
|
||||||
parse_from_config(wmtrash->configfile, wmtrash->param_img, wmtrash->imagefile);
|
parse_from_config(wmtrash->configfile, wmtrash->param_img, wmtrash->imagefile);
|
||||||
sprintf(image_path_file, "%s/%s", __ICONPATH, wmtrash->imagefile);
|
sprintf(image_path_file, "%s/%s", __ICONPATH, wmtrash->imagefile);
|
||||||
parse_from_config(wmtrash->configfile, wmtrash->param_fm, wmtrash->fm);
|
parse_from_config(wmtrash->configfile, wmtrash->param_fm, wmtrash->fm);
|
||||||
parse_from_config(wmtrash->configfile, wmtrash->param_path, wmtrash->path);
|
parse_from_config(wmtrash->configfile, wmtrash->param_path, wmtrash->path);
|
||||||
|
|
||||||
// GTK stuff *******************************************************************
|
// GTK stuff *******************************************************************
|
||||||
gtk_widget_destroy(mainwin);
|
gtk_widget_destroy(mainwin);
|
||||||
mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_realize(mainwin);
|
gtk_widget_realize(mainwin);
|
||||||
mainbox = create_main_dockapp_icon_window(mainwin, 52);
|
mainbox = create_main_dockapp_icon_window(mainwin, 52);
|
||||||
|
|
||||||
box = gtk_event_box_new();
|
box = gtk_event_box_new();
|
||||||
pixmap = (gpointer) gdk_pixmap_create_from_xpm (mainwin->window, &mask,
|
pixmap = (gpointer) gdk_pixmap_create_from_xpm (mainwin->window, &mask,
|
||||||
NULL, image_path_file);
|
NULL, image_path_file);
|
||||||
pixmap_widget = gtk_pixmap_new((gpointer) pixmap, mask);
|
pixmap_widget = gtk_pixmap_new((gpointer) pixmap, mask);
|
||||||
gtk_container_add(GTK_CONTAINER(box), pixmap_widget);
|
gtk_container_add(GTK_CONTAINER(box), pixmap_widget);
|
||||||
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (mainbox), box);
|
gtk_container_add (GTK_CONTAINER (mainbox), box);
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT(box), "button_press_event", GTK_SIGNAL_FUNC(launchonclick), wmtrash);
|
gtk_signal_connect (GTK_OBJECT(box), "button_press_event", GTK_SIGNAL_FUNC(launchonclick), wmtrash);
|
||||||
|
|
||||||
free(image_path_file);
|
free(image_path_file);
|
||||||
return mainwin;
|
return mainwin;
|
||||||
}
|
}
|
||||||
|
@ -127,35 +127,35 @@ GtkWidget * build_dockapp(char *configfile) {
|
||||||
|
|
||||||
GtkWidget *create_main_dockapp_icon_window
|
GtkWidget *create_main_dockapp_icon_window
|
||||||
(GtkWidget *mw,
|
(GtkWidget *mw,
|
||||||
unsigned int s)
|
unsigned int s)
|
||||||
{
|
{
|
||||||
GtkWidget *dockappbox; // This will become icon box
|
GtkWidget *dockappbox; // This will become icon box
|
||||||
Window xmw;
|
Window xmw;
|
||||||
XWMHints *wm_hints;
|
XWMHints *wm_hints;
|
||||||
|
|
||||||
xmw = GDK_WINDOW_XWINDOW(mw->window);
|
xmw = GDK_WINDOW_XWINDOW(mw->window);
|
||||||
|
|
||||||
dockappbox = gtk_event_box_new();
|
dockappbox = gtk_event_box_new();
|
||||||
gtk_widget_set_usize(dockappbox, s, s);
|
gtk_widget_set_usize(dockappbox, s, s);
|
||||||
gtk_container_add (GTK_CONTAINER (mw), dockappbox);
|
gtk_container_add (GTK_CONTAINER (mw), dockappbox);
|
||||||
gtk_widget_realize(dockappbox);
|
gtk_widget_realize(dockappbox);
|
||||||
|
|
||||||
// Time for game with Xlib
|
// Time for game with Xlib
|
||||||
wm_hints = XAllocWMHints();
|
wm_hints = XAllocWMHints();
|
||||||
wm_hints->window_group = xmw;
|
wm_hints->window_group = xmw;
|
||||||
wm_hints->icon_window = GDK_WINDOW_XWINDOW(dockappbox->window);
|
wm_hints->icon_window = GDK_WINDOW_XWINDOW(dockappbox->window);
|
||||||
wm_hints->icon_x = 0;
|
wm_hints->icon_x = 0;
|
||||||
wm_hints->icon_y = 0;
|
wm_hints->icon_y = 0;
|
||||||
wm_hints->initial_state = WithdrawnState;
|
wm_hints->initial_state = WithdrawnState;
|
||||||
wm_hints->flags = StateHint |
|
wm_hints->flags = StateHint |
|
||||||
IconPositionHint |
|
IconPositionHint |
|
||||||
WindowGroupHint |
|
WindowGroupHint |
|
||||||
IconWindowHint;
|
IconWindowHint;
|
||||||
|
|
||||||
XSetWMHints(GDK_DISPLAY(), xmw, wm_hints);
|
XSetWMHints(GDK_DISPLAY(), xmw, wm_hints);
|
||||||
|
|
||||||
XFree(wm_hints);
|
XFree(wm_hints);
|
||||||
|
|
||||||
return dockappbox;
|
return dockappbox;
|
||||||
} // end create_main_dockapp_icon_window
|
} // end create_main_dockapp_icon_window
|
||||||
|
|
||||||
|
@ -164,12 +164,12 @@ GtkWidget *create_main_dockapp_icon_window
|
||||||
or change the command and pixmap icon when right button is 2-clicked */
|
or change the command and pixmap icon when right button is 2-clicked */
|
||||||
|
|
||||||
void launchonclick
|
void launchonclick
|
||||||
(GtkWidget *event_box,
|
(GtkWidget *event_box,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
struct wmtrash *data)
|
struct wmtrash *data)
|
||||||
{
|
{
|
||||||
char *cmd;
|
char *cmd;
|
||||||
cmd=malloc(BIG_STRING);
|
cmd=malloc(BIG_STRING);
|
||||||
memset(cmd, 0, BIG_STRING);
|
memset(cmd, 0, BIG_STRING);
|
||||||
|
|
||||||
/* left button of mouse is clicked */
|
/* left button of mouse is clicked */
|
||||||
|
@ -185,7 +185,7 @@ void launchonclick
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((event->button == 3)&&(event->type == GDK_2BUTTON_PRESS)) {
|
if((event->button == 3)&&(event->type == GDK_2BUTTON_PRESS)) {
|
||||||
strcat (cmd, "rm -rf");
|
strcat (cmd, "rm -rf");
|
||||||
strcat (cmd, " ");
|
strcat (cmd, " ");
|
||||||
strcat (cmd, data->path);
|
strcat (cmd, data->path);
|
||||||
|
@ -199,10 +199,10 @@ void launchonclick
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* right button of mouse is 2-clicked */
|
/* right button of mouse is 2-clicked */
|
||||||
if((event->button == 2)&&(event->type == GDK_2BUTTON_PRESS)){
|
if((event->button == 2)&&(event->type == GDK_2BUTTON_PRESS)){
|
||||||
|
|
||||||
/* create a new text entry window for entering the new command */
|
/* create a new text entry window for entering the new command */
|
||||||
GtkWidget *dialog, *table, *vbox;
|
GtkWidget *dialog, *table, *vbox;
|
||||||
GtkWidget *entry1, *entry2, *button;
|
GtkWidget *entry1, *entry2, *button;
|
||||||
|
@ -210,38 +210,38 @@ void launchonclick
|
||||||
dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), "Change command & pixmap");
|
gtk_window_set_title (GTK_WINDOW (dialog), "Change command & pixmap");
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
|
||||||
|
|
||||||
|
|
||||||
table = gtk_table_new(2,2, TRUE);
|
table = gtk_table_new(2,2, TRUE);
|
||||||
gtk_table_set_col_spacings(GTK_TABLE (table), 5);
|
gtk_table_set_col_spacings(GTK_TABLE (table), 5);
|
||||||
gtk_table_set_row_spacings(GTK_TABLE (table), 5);
|
gtk_table_set_row_spacings(GTK_TABLE (table), 5);
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 0);
|
vbox = gtk_vbox_new (FALSE, 0);
|
||||||
|
|
||||||
// entry box parameters
|
// entry box parameters
|
||||||
entry1 = gtk_entry_new ();
|
entry1 = gtk_entry_new ();
|
||||||
entry2 = gtk_entry_new ();
|
entry2 = gtk_entry_new ();
|
||||||
gtk_entry_set_max_length (GTK_ENTRY (entry1), 120);
|
gtk_entry_set_max_length (GTK_ENTRY (entry1), 120);
|
||||||
gtk_entry_set_max_length (GTK_ENTRY (entry2), 120);
|
gtk_entry_set_max_length (GTK_ENTRY (entry2), 120);
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (entry1), "changed", GTK_SIGNAL_FUNC (enter_callback1), data);
|
gtk_signal_connect (GTK_OBJECT (entry1), "changed", GTK_SIGNAL_FUNC (enter_callback1), data);
|
||||||
gtk_signal_connect (GTK_OBJECT (entry2), "changed", GTK_SIGNAL_FUNC (enter_callback2), data);
|
gtk_signal_connect (GTK_OBJECT (entry2), "changed", GTK_SIGNAL_FUNC (enter_callback2), data);
|
||||||
|
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry1), data->fm);
|
gtk_entry_set_text (GTK_ENTRY (entry1), data->fm);
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry2), data->path);
|
gtk_entry_set_text (GTK_ENTRY (entry2), data->path);
|
||||||
gtk_editable_set_editable (GTK_EDITABLE (entry1), TRUE);
|
gtk_editable_set_editable (GTK_EDITABLE (entry1), TRUE);
|
||||||
gtk_entry_set_visibility (GTK_ENTRY (entry1), TRUE);
|
gtk_entry_set_visibility (GTK_ENTRY (entry1), TRUE);
|
||||||
gtk_editable_set_editable (GTK_EDITABLE (entry2), TRUE);
|
gtk_editable_set_editable (GTK_EDITABLE (entry2), TRUE);
|
||||||
gtk_entry_set_visibility (GTK_ENTRY (entry2), TRUE);
|
gtk_entry_set_visibility (GTK_ENTRY (entry2), TRUE);
|
||||||
|
|
||||||
// button parameters
|
// button parameters
|
||||||
button = gtk_button_new_with_label("OK");
|
button = gtk_button_new_with_label("OK");
|
||||||
//label = gtk_label_new ("OK");
|
//label = gtk_label_new ("OK");
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (close_callback), data);
|
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (close_callback), data);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (vbox), entry1);
|
gtk_container_add (GTK_CONTAINER (vbox), entry1);
|
||||||
gtk_container_add (GTK_CONTAINER (vbox), entry2);
|
gtk_container_add (GTK_CONTAINER (vbox), entry2);
|
||||||
|
|
||||||
gtk_table_attach_defaults(GTK_TABLE(table), vbox, 0,1, 0,2);
|
gtk_table_attach_defaults(GTK_TABLE(table), vbox, 0,1, 0,2);
|
||||||
gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2, 0,2);
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2, 0,2);
|
||||||
|
|
||||||
|
@ -254,37 +254,37 @@ void launchonclick
|
||||||
} // end launchonclick
|
} // end launchonclick
|
||||||
|
|
||||||
/* some callback to handle change of values in entry boxes************************* */
|
/* some callback to handle change of values in entry boxes************************* */
|
||||||
void enter_callback1(
|
void enter_callback1(
|
||||||
GtkWidget *entry,
|
GtkWidget *entry,
|
||||||
struct wmtrash *data){
|
struct wmtrash *data){
|
||||||
char *entry_text;
|
char *entry_text;
|
||||||
entry_text = malloc(BIG_STRING);
|
entry_text = malloc(BIG_STRING);
|
||||||
memset(entry_text, 0, BIG_STRING);
|
memset(entry_text, 0, BIG_STRING);
|
||||||
strncpy (entry_text, gtk_entry_get_text (GTK_ENTRY (entry)), BIG_STRING);
|
strncpy (entry_text, gtk_entry_get_text (GTK_ENTRY (entry)), BIG_STRING);
|
||||||
memset(data->fm, 0, BIG_STRING);
|
memset(data->fm, 0, BIG_STRING);
|
||||||
strncpy (data->fm, entry_text, BIG_STRING);
|
strncpy (data->fm, entry_text, BIG_STRING);
|
||||||
|
|
||||||
}
|
}
|
||||||
void enter_callback2(
|
void enter_callback2(
|
||||||
GtkWidget *entry,
|
GtkWidget *entry,
|
||||||
struct wmtrash *data){
|
struct wmtrash *data){
|
||||||
char *entry_text;
|
char *entry_text;
|
||||||
entry_text = malloc(BIG_STRING);
|
entry_text = malloc(BIG_STRING);
|
||||||
memset(entry_text, 0, BIG_STRING);
|
memset(entry_text, 0, BIG_STRING);
|
||||||
strncpy (entry_text, gtk_entry_get_text (GTK_ENTRY (entry)), BIG_STRING);
|
strncpy (entry_text, gtk_entry_get_text (GTK_ENTRY (entry)), BIG_STRING);
|
||||||
memset(data->path, 0, BIG_STRING);
|
memset(data->path, 0, BIG_STRING);
|
||||||
strncpy (data->path, entry_text, BIG_STRING);
|
strncpy (data->path, entry_text, BIG_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_callback(
|
void close_callback(
|
||||||
GtkWidget *entry,
|
GtkWidget *entry,
|
||||||
struct wmtrash *data){
|
struct wmtrash *data){
|
||||||
|
|
||||||
GtkWidget *parent;
|
GtkWidget *parent;
|
||||||
GtkWidget *dockapp;
|
GtkWidget *dockapp;
|
||||||
replace_value_in_config(data->configfile, data->param_fm, data->fm);
|
replace_value_in_config(data->configfile, data->param_fm, data->fm);
|
||||||
replace_value_in_config(data->configfile, data->param_path, data->path);
|
replace_value_in_config(data->configfile, data->param_path, data->path);
|
||||||
parent = gtk_widget_get_ancestor(entry, GTK_TYPE_WINDOW);
|
parent = gtk_widget_get_ancestor(entry, GTK_TYPE_WINDOW);
|
||||||
gtk_widget_destroy(parent); // close the dialog box
|
gtk_widget_destroy(parent); // close the dialog box
|
||||||
dockapp = (GtkWidget *) build_dockapp(data->configfile); // will redraw icons
|
dockapp = (GtkWidget *) build_dockapp(data->configfile); // will redraw icons
|
||||||
gtk_widget_show_all (dockapp);
|
gtk_widget_show_all (dockapp);
|
||||||
|
@ -293,31 +293,31 @@ void close_callback(
|
||||||
|
|
||||||
// the function to parse the config file for parameters *********************************************
|
// the function to parse the config file for parameters *********************************************
|
||||||
int parse_from_config
|
int parse_from_config
|
||||||
(char *filename,
|
(char *filename,
|
||||||
char *param,
|
char *param,
|
||||||
char *value)
|
char *value)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *sep,
|
char *sep,
|
||||||
*buffer,
|
*buffer,
|
||||||
*line,
|
*line,
|
||||||
*val;
|
*val;
|
||||||
line = malloc(LONG_STRING);
|
line = malloc(LONG_STRING);
|
||||||
buffer = malloc(MEDIUM_STRING);
|
buffer = malloc(MEDIUM_STRING);
|
||||||
sep = malloc(SHORT_STRING);
|
sep = malloc(SHORT_STRING);
|
||||||
val = malloc(MEDIUM_STRING);
|
val = malloc(MEDIUM_STRING);
|
||||||
|
|
||||||
if((file=fopen(filename, "rb")) == 0) {
|
if((file=fopen(filename, "rb")) == 0) {
|
||||||
fprintf (stderr,"Error opening file %s !\n",filename);
|
fprintf (stderr,"Error opening file %s !\n",filename);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets (line, LONG_STRING, file) !=NULL) {
|
while (fgets (line, LONG_STRING, file) !=NULL) {
|
||||||
if (strstr (line, "[") !=0) continue;
|
if (strstr (line, "[") !=0) continue;
|
||||||
if (strstr (line, "#") !=0) continue;
|
if (strstr (line, "#") !=0) continue;
|
||||||
memset(val, 0, MEDIUM_STRING);
|
memset(val, 0, MEDIUM_STRING);
|
||||||
c = sscanf (line, "%s %s %s", buffer, sep, val);
|
c = sscanf (line, "%s %s %s", buffer, sep, val);
|
||||||
|
|
||||||
if (strncmp (param, buffer, MEDIUM_STRING) == 0) {
|
if (strncmp (param, buffer, MEDIUM_STRING) == 0) {
|
||||||
memset(value, 0, BIG_STRING);
|
memset(value, 0, BIG_STRING);
|
||||||
|
@ -331,12 +331,12 @@ int parse_from_config
|
||||||
fclose (file);
|
fclose (file);
|
||||||
return(EXIT_SUCCESS);
|
return(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
memset(line, 0, LONG_STRING);
|
memset(line, 0, LONG_STRING);
|
||||||
}
|
}
|
||||||
fclose (file);
|
fclose (file);
|
||||||
free(sep);
|
free(sep);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
free(line);
|
free(line);
|
||||||
free(val);
|
free(val);
|
||||||
return(EXIT_FAILURE);
|
return(EXIT_FAILURE);
|
||||||
} // end parse_from_config
|
} // end parse_from_config
|
||||||
|
@ -344,39 +344,39 @@ int parse_from_config
|
||||||
|
|
||||||
// the function to parse the config file to replace the value of a given parameter ****************************
|
// the function to parse the config file to replace the value of a given parameter ****************************
|
||||||
int replace_value_in_config
|
int replace_value_in_config
|
||||||
(char *filename,
|
(char *filename,
|
||||||
char *param,
|
char *param,
|
||||||
char *new_value)
|
char *new_value)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char *bigbuffer,
|
char *bigbuffer,
|
||||||
*sep,
|
*sep,
|
||||||
*buffer,
|
*buffer,
|
||||||
*line,
|
*line,
|
||||||
*old_value;
|
*old_value;
|
||||||
bigbuffer = malloc(EXTRALONG_STRING);
|
bigbuffer = malloc(EXTRALONG_STRING);
|
||||||
line = malloc(LONG_STRING);
|
line = malloc(LONG_STRING);
|
||||||
buffer = malloc(MEDIUM_STRING);
|
buffer = malloc(MEDIUM_STRING);
|
||||||
sep = malloc(MEDIUM_STRING);
|
sep = malloc(MEDIUM_STRING);
|
||||||
old_value = malloc(BIG_STRING);
|
old_value = malloc(BIG_STRING);
|
||||||
|
|
||||||
if((file=fopen(filename, "rb")) == 0) {
|
if((file=fopen(filename, "rb")) == 0) {
|
||||||
fprintf (stderr,"Error opening file %s !\n",filename);
|
fprintf (stderr,"Error opening file %s !\n",filename);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(bigbuffer, 0, EXTRALONG_STRING);
|
memset(bigbuffer, 0, EXTRALONG_STRING);
|
||||||
while (fgets (line, LONG_STRING, file) !=NULL) {
|
while (fgets (line, LONG_STRING, file) !=NULL) {
|
||||||
memset(buffer, 0, MEDIUM_STRING);
|
memset(buffer, 0, MEDIUM_STRING);
|
||||||
c = sscanf (line, "%s %s %s\n", buffer, sep, old_value);
|
c = sscanf (line, "%s %s %s\n", buffer, sep, old_value);
|
||||||
|
|
||||||
if (strncmp (param, buffer, MEDIUM_STRING) == 0) {
|
if (strncmp (param, buffer, MEDIUM_STRING) == 0) {
|
||||||
memset(line, 0, LONG_STRING);
|
memset(line, 0, LONG_STRING);
|
||||||
sprintf(line, "%s %s %s\n", buffer, sep, new_value);
|
sprintf(line, "%s %s %s\n", buffer, sep, new_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
strncat (bigbuffer, line, LONG_STRING);
|
strncat (bigbuffer, line, LONG_STRING);
|
||||||
memset(line, 0, LONG_STRING);
|
memset(line, 0, LONG_STRING);
|
||||||
}
|
}
|
||||||
fclose (file);
|
fclose (file);
|
||||||
|
@ -388,11 +388,11 @@ int replace_value_in_config
|
||||||
fprintf(file,bigbuffer);
|
fprintf(file,bigbuffer);
|
||||||
fclose (file);
|
fclose (file);
|
||||||
memset(bigbuffer, 0, EXTRALONG_STRING);
|
memset(bigbuffer, 0, EXTRALONG_STRING);
|
||||||
|
|
||||||
free(bigbuffer);
|
free(bigbuffer);
|
||||||
free(sep);
|
free(sep);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
free(line);
|
free(line);
|
||||||
free(old_value);
|
free(old_value);
|
||||||
return(EXIT_SUCCESS);
|
return(EXIT_SUCCESS);
|
||||||
} // end replace_value_in_config *************************************************************************
|
} // end replace_value_in_config *************************************************************************
|
||||||
|
@ -422,10 +422,10 @@ int usage(char *homecf, char *defaultcf) {
|
||||||
|
|
||||||
|
|
||||||
// this one just copy sfile into dfile :)
|
// this one just copy sfile into dfile :)
|
||||||
int fcopy( char *sfile,
|
int fcopy( char *sfile,
|
||||||
char *dfile){
|
char *dfile){
|
||||||
int c; /* Character read/written between files */
|
int c; /* Character read/written between files */
|
||||||
FILE *IPFile; /* Pointer to the I/P file. FILE is a
|
FILE *IPFile; /* Pointer to the I/P file. FILE is a
|
||||||
structure defined in <stdio.h> */
|
structure defined in <stdio.h> */
|
||||||
FILE *OPFile;
|
FILE *OPFile;
|
||||||
|
|
||||||
|
@ -438,8 +438,8 @@ if ((OPFile = fopen(dfile,"w")) == 0) {
|
||||||
fprintf (stderr,"Error opening file %s !\n",dfile);
|
fprintf (stderr,"Error opening file %s !\n",dfile);
|
||||||
return (EXIT_FAILURE);
|
return (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/* Read one character at a time, checking
|
/* Read one character at a time, checking
|
||||||
for the End of File. EOF is defined
|
for the End of File. EOF is defined
|
||||||
in <stdio.h> as -1 */
|
in <stdio.h> as -1 */
|
||||||
while ((c = fgetc(IPFile)) != EOF){
|
while ((c = fgetc(IPFile)) != EOF){
|
||||||
fputc(c, OPFile); /* O/P the character */
|
fputc(c, OPFile); /* O/P the character */
|
||||||
|
|
|
@ -44,35 +44,35 @@ GtkWidget *create_main_dockapp_icon_window
|
||||||
unsigned int size);
|
unsigned int size);
|
||||||
|
|
||||||
void launchonclick
|
void launchonclick
|
||||||
(GtkWidget *event_box,
|
(GtkWidget *event_box,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
struct wmtrash *data);
|
struct wmtrash *data);
|
||||||
|
|
||||||
int parse_from_config
|
int parse_from_config
|
||||||
(char *filename,
|
(char *filename,
|
||||||
char *param,
|
char *param,
|
||||||
char *value);
|
char *value);
|
||||||
|
|
||||||
int replace_value_in_config
|
int replace_value_in_config
|
||||||
(char *filename,
|
(char *filename,
|
||||||
char *param,
|
char *param,
|
||||||
char *new_value);
|
char *new_value);
|
||||||
|
|
||||||
void enter_callback1(
|
void enter_callback1(
|
||||||
GtkWidget *entry1,
|
|
||||||
struct wmtrash *data);
|
|
||||||
|
|
||||||
void enter_callback2(
|
|
||||||
GtkWidget *entry1,
|
GtkWidget *entry1,
|
||||||
struct wmtrash *data);
|
struct wmtrash *data);
|
||||||
|
|
||||||
void close_callback(
|
void enter_callback2(
|
||||||
|
GtkWidget *entry1,
|
||||||
|
struct wmtrash *data);
|
||||||
|
|
||||||
|
void close_callback(
|
||||||
GtkWidget *entry,
|
GtkWidget *entry,
|
||||||
struct wmtrash *data);
|
struct wmtrash *data);
|
||||||
|
|
||||||
int usage(char *homecf, char *defaultcf);
|
int usage(char *homecf, char *defaultcf);
|
||||||
|
|
||||||
int fcopy( char *sfile,
|
int fcopy( char *sfile,
|
||||||
char *dfile);
|
char *dfile);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue