gtkmeat 0.5.5
This commit is contained in:
parent
96f4e1a07f
commit
e3e6450c9c
7 changed files with 57 additions and 24 deletions
|
|
@ -1,3 +1,11 @@
|
|||
Mon Jan 11 1999 v0.5.5 Troy Engel <tengel@sonic.net>
|
||||
* replaced non ANSI C func strsep with strtok (Sun Solaris)
|
||||
* replaced getenv("HOME") with glib equiv
|
||||
* functions made static
|
||||
* reworked g_malloc/g_free code, probably lost some mem leaks :)
|
||||
* void main -> int main
|
||||
* fixed RC buffer problem (darn \0)
|
||||
|
||||
Sun Jan 03 1999 Troy Engel <tengel@sonic.net>
|
||||
* versioned to 0.5.4
|
||||
* initial public release
|
||||
|
|
|
|||
4
NEWS
4
NEWS
|
|
@ -1,3 +1 @@
|
|||
Version 0.5.4
|
||||
* initial public release
|
||||
|
||||
See ChangeLog
|
||||
|
|
|
|||
4
README
4
README
|
|
@ -3,7 +3,7 @@ gtkMeat - freshmeat new submissions ticker
|
|||
http://www.sonic.net/~tengel/gtkmeat/
|
||||
-----------------------------------------
|
||||
|
||||
01/03/99, v0.5.4
|
||||
01/11/99, v0.5.5
|
||||
|
||||
|
||||
General
|
||||
|
|
@ -17,7 +17,7 @@ gtkMeat requires Gtk+ (http://www.gtk.org) and curl
|
|||
file retrieval, respectively. Additionally, if you want to
|
||||
browse a news article from within gtkMeat you'll need some
|
||||
sort of web browser. Currently it is working just fine with
|
||||
Gtk 1.1.3 (Windows) Gtk 1.1.9 (*nix) and curl 5.3 (both).
|
||||
Gtk 1.1.3 (Windows) Gtk 1.1.12 (*nix) and curl 5.4 (both).
|
||||
|
||||
If you are on Windows, the Gtk+ version which has been used is
|
||||
from Tor Lillqvist; he also ports Gdk and GIMP. If you don't
|
||||
|
|
|
|||
2
aclocal.m4
vendored
2
aclocal.m4
vendored
|
|
@ -160,7 +160,7 @@ AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run
|
|||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $GTK_CFLAGS"
|
||||
LIBS="$LIBS $GTK_LIBS"
|
||||
LIBS="$GTK_LIBS $LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed GTK is sufficiently new. (Also sanity
|
||||
dnl checks the results of gtk-config to some extent
|
||||
|
|
|
|||
4
configure
vendored
4
configure
vendored
|
|
@ -526,7 +526,7 @@ else
|
|||
fi
|
||||
|
||||
|
||||
GTKMEAT_VERSION=0.5.4
|
||||
GTKMEAT_VERSION=0.5.5
|
||||
|
||||
AUTOMAKE_OPTIONS=no-dependencies
|
||||
VERSION=$GTKMEAT_VERSION
|
||||
|
|
@ -1097,7 +1097,7 @@ echo "configure:1084: checking for GTK - version >= $min_gtk_version" >&5
|
|||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $GTK_CFLAGS"
|
||||
LIBS="$LIBS $GTK_LIBS"
|
||||
LIBS="$GTK_LIBS $LIBS"
|
||||
rm -f conf.gtktest
|
||||
if test "$cross_compiling" = yes; then
|
||||
echo $ac_n "cross compiling; assumed OK... $ac_c"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
|
|||
dnl $Id$
|
||||
dnl ---------------------------------------------------------------------------
|
||||
AC_INIT(gtkmeat.c)
|
||||
GTKMEAT_VERSION=0.5.4
|
||||
GTKMEAT_VERSION=0.5.5
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl for automake:
|
||||
|
|
|
|||
57
gtkmeat.c
57
gtkmeat.c
|
|
@ -48,7 +48,7 @@
|
|||
#define MSG_RETR_ERR "Error retrieving recentnews.txt!"
|
||||
#define MSG_LAUNCH "Launching web browser..."
|
||||
#define MSG_LAUNCH_ERR "Error launching browser!"
|
||||
#define MSG_IDLE "Status: Idle (gtkMeat 0.5.4)"
|
||||
#define MSG_IDLE "Status: Idle (gtkMeat 0.5.5)"
|
||||
|
||||
/* read from RC file */
|
||||
gint refresh_timeout;
|
||||
|
|
@ -62,6 +62,7 @@ gint num_fields;
|
|||
GtkWidget *status;
|
||||
|
||||
/* retrieves a line from a linefeed delimited textfile */
|
||||
static
|
||||
gchar *app_getLine(FILE *file) {
|
||||
char *tmp, in;
|
||||
int cnt = 0, retIn;
|
||||
|
|
@ -94,7 +95,8 @@ gchar *app_getLine(FILE *file) {
|
|||
}
|
||||
}
|
||||
|
||||
/* loads ultramode.txt into our clist */
|
||||
/* loads recentnews.txt into our clist */
|
||||
static
|
||||
BOOL app_loadFile(GtkWidget *list, const gchar *fname) {
|
||||
gchar *line;
|
||||
gchar *article[2], *link;
|
||||
|
|
@ -115,9 +117,13 @@ BOOL app_loadFile(GtkWidget *list, const gchar *fname) {
|
|||
link = NULL;
|
||||
rewind(fHnd);
|
||||
while (line) {
|
||||
gboolean bGotit = FALSE;
|
||||
if (line) /* should only happen once from above */
|
||||
g_free(line);
|
||||
for (i = 0 ; i<num_fields; i++) {
|
||||
line = app_getLine(fHnd);
|
||||
if (line) {
|
||||
bGotit = TRUE;
|
||||
switch (i) {
|
||||
case 0: /* title */
|
||||
article[0] = line;
|
||||
|
|
@ -128,13 +134,20 @@ BOOL app_loadFile(GtkWidget *list, const gchar *fname) {
|
|||
case 2: /* link */
|
||||
link = line;
|
||||
break;
|
||||
default: /* unused */
|
||||
g_free(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (line) {
|
||||
int index;
|
||||
if (bGotit) {
|
||||
gint index;
|
||||
index = gtk_clist_append(GTK_CLIST(list), article);
|
||||
gtk_clist_set_row_data(GTK_CLIST(list), index, link);
|
||||
for (i=0; i<3; i++) {
|
||||
if (article[i])
|
||||
g_free(article[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fHnd);
|
||||
|
|
@ -144,6 +157,7 @@ BOOL app_loadFile(GtkWidget *list, const gchar *fname) {
|
|||
}
|
||||
|
||||
/* launches a given app */
|
||||
static
|
||||
BOOL app_startApp(const gchar *cmd, BOOL bWait, WORD wShowState) {
|
||||
#ifndef WIN32
|
||||
char **args, *work, *twrk;
|
||||
|
|
@ -172,17 +186,16 @@ BOOL app_startApp(const gchar *cmd, BOOL bWait, WORD wShowState) {
|
|||
} else {
|
||||
work = g_malloc(sizeof(char) * (len + 1));
|
||||
strcpy(work, cmd);
|
||||
twrk = (char *) strsep(&work, " ");
|
||||
twrk = (char*)strtok(work, " ");
|
||||
args[0] = twrk;
|
||||
cnt = 1;
|
||||
while (twrk) {
|
||||
twrk = (char *) strsep(&work, " ");
|
||||
twrk = (char*)strtok(NULL, " ");
|
||||
args[cnt] = twrk;
|
||||
cnt++;
|
||||
}
|
||||
args[cnt] = work;
|
||||
}
|
||||
/* TODO: wait for curl to finish on unix */
|
||||
execvp(args[0], args);
|
||||
} else {
|
||||
_exit(0);
|
||||
|
|
@ -222,6 +235,7 @@ BOOL app_startApp(const gchar *cmd, BOOL bWait, WORD wShowState) {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
static
|
||||
BOOL app_getFile(const gchar *fname) {
|
||||
gchar cmd[MAX_BUFF];
|
||||
sprintf(cmd, curl_cmd, fname);
|
||||
|
|
@ -230,6 +244,7 @@ BOOL app_getFile(const gchar *fname) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
BOOL app_isZeroByte(const gchar *fname) {
|
||||
FILE *fHnd;
|
||||
gint ch = 0;
|
||||
|
|
@ -246,17 +261,20 @@ BOOL app_isZeroByte(const gchar *fname) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
gint app_timer_idle(gpointer data) {
|
||||
gtk_label_set(GTK_LABEL(status), MSG_IDLE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
gint app_exit(GtkWidget *widget, GdkEvent *event, gpointer data) {
|
||||
gtk_main_quit();
|
||||
exit(0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static
|
||||
gint app_timer_refresh(GtkWidget *list) {
|
||||
gchar *home_env, *fname;
|
||||
gint retval;
|
||||
|
|
@ -264,7 +282,7 @@ gint app_timer_refresh(GtkWidget *list) {
|
|||
gchar mypath[MAX_BUFF];
|
||||
#endif
|
||||
|
||||
home_env = getenv("HOME");
|
||||
home_env = g_get_home_dir();
|
||||
#ifdef WIN32 /* no HOME dir */
|
||||
if (home_env == NULL) {
|
||||
gchar *cutme;
|
||||
|
|
@ -274,7 +292,7 @@ gint app_timer_refresh(GtkWidget *list) {
|
|||
home_env = mypath;
|
||||
}
|
||||
#endif
|
||||
fname = g_malloc(sizeof(char) * (strlen(home_env) + 15));
|
||||
fname = g_malloc(sizeof(gchar) * (strlen(home_env) + 16));
|
||||
strcpy(fname, home_env);
|
||||
strcat(fname, DIR_CHAR);
|
||||
strcat(fname, "recentnews.tmp");
|
||||
|
|
@ -304,11 +322,13 @@ gint app_timer_refresh(GtkWidget *list) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
static
|
||||
gint app_refresh(GtkWidget *widget, GtkWidget *list) {
|
||||
return app_timer_refresh(list);
|
||||
}
|
||||
|
||||
/* launch our article */
|
||||
static
|
||||
void app_article_browse(GtkWidget *widget, gpointer data) {
|
||||
gint rerr;
|
||||
struct stat buff;
|
||||
|
|
@ -317,7 +337,7 @@ void app_article_browse(GtkWidget *widget, gpointer data) {
|
|||
|
||||
url = gtk_clist_get_row_data(GTK_CLIST(data), GTK_CLIST(data)->focus_row);
|
||||
#ifndef WIN32
|
||||
home = getenv("HOME");
|
||||
home = g_get_home_dir();
|
||||
fname = g_malloc(sizeof(gchar) * (strlen(home) + 16));
|
||||
strcpy(fname, home);
|
||||
strcat(fname, "/.netscape/lock");
|
||||
|
|
@ -337,6 +357,7 @@ void app_article_browse(GtkWidget *widget, gpointer data) {
|
|||
}
|
||||
|
||||
/* sorting */
|
||||
static
|
||||
void app_click_column(GtkCList *clist, gint column, gpointer data) {
|
||||
if (column == clist->sort_column) {
|
||||
clist->sort_type = (clist->sort_type == GTK_SORT_ASCENDING) ?
|
||||
|
|
@ -347,12 +368,14 @@ void app_click_column(GtkCList *clist, gint column, gpointer data) {
|
|||
gtk_clist_sort(clist);
|
||||
}
|
||||
|
||||
static
|
||||
BOOL app_parse_rc() {
|
||||
gchar *home_env, *fname;
|
||||
gint retval;
|
||||
|
||||
home_env = getenv("HOME");
|
||||
fname = g_malloc(sizeof(gchar) * (strlen(home_env) + 15));
|
||||
home_env = g_get_home_dir();
|
||||
/* /home/foobar + /. + myrc + \0 */
|
||||
fname = g_malloc(sizeof(gchar) * (strlen(home_env)+2+strlen(APP_RC)+1));
|
||||
strcpy(fname, home_env);
|
||||
strcat(fname, DIR_CHAR);
|
||||
strcat(fname, DOT_CHAR);
|
||||
|
|
@ -366,10 +389,12 @@ BOOL app_parse_rc() {
|
|||
#ifdef WIN32
|
||||
gchar tmp[MAX_BUFF];
|
||||
GetWindowsDirectory(tmp, sizeof(tmp));
|
||||
fname = g_malloc(sizeof(gchar) * (sizeof(tmp) + 1 + sizeof(APP_RC)));
|
||||
/* c:\windows + \ + myrc + \0 */
|
||||
fname = g_malloc(sizeof(gchar) * (sizeof(tmp) + 1 + sizeof(APP_RC) + 1));
|
||||
strcpy(fname, tmp);
|
||||
#else
|
||||
fname = g_malloc(sizeof(gchar) * (4 + 1 + strlen(APP_RC)));
|
||||
/* /etc + / + myrc + \0 */
|
||||
fname = g_malloc(sizeof(gchar) * (4 + 1 + strlen(APP_RC) + 1));
|
||||
strcpy(fname, "/etc");
|
||||
#endif
|
||||
strcat(fname, DIR_CHAR);
|
||||
|
|
@ -389,6 +414,7 @@ BOOL app_parse_rc() {
|
|||
return retval;
|
||||
}
|
||||
|
||||
static
|
||||
void app_window() {
|
||||
GtkWidget *window, *vbox, *clist, *scrolled_win, *hbox, *but;
|
||||
gchar *titles[2] = {"Title", "Date"};
|
||||
|
|
@ -461,7 +487,7 @@ void app_window() {
|
|||
#ifdef WIN32
|
||||
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd) {
|
||||
#else
|
||||
void main(int argc, char **argv) {
|
||||
int main(int argc, char **argv) {
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
|
@ -501,4 +527,5 @@ void main(int argc, char **argv) {
|
|||
app_parse_rc();
|
||||
app_window();
|
||||
gtk_main();
|
||||
return(0) ;
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue