[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/button.c gtkshell/geometry.c...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/button.c gtkshell/geometry.c... |
Date: |
Sat, 17 Feb 2007 23:07:32 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/02/17 23:07:31
Modified files:
gtkshell : button.c geometry.c gtkshell.c gtkshell.h
option_options.c row.c updated.c updated.h
updated_label.c updated_options.c
updated_progress.c
libantiright : util.c
Log message:
Converted the updater code to use the new application structure
framework.
Unified debugging message formats. Changed xmalloc to a raw g_malloc
call,
as g_malloc will terminate if memory allocation unsuccessful.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/geometry.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.c?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/row.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.c?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.h?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_label.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_options.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_progress.c?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/util.c?cvsroot=antiright&r1=1.5&r2=1.6
Patches:
Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/button.c 16 Feb 2007 22:18:01 -0000 1.4
+++ gtkshell/button.c 17 Feb 2007 23:07:31 -0000 1.5
@@ -30,6 +30,10 @@
char *label_text;
struct GSH_CBData *cb;
+#ifdef DEBUG
+ g_message("gsh_command_button");
+#endif /* DEBUG */
+
/* Allocate and initialize elements. */
cb=(struct GSH_CBData *)xmalloc(sizeof(struct GSH_CBData));
cb->gsh=gsh;
@@ -45,7 +49,8 @@
gsh_manage(gsh, gsh->button);
#ifdef DEBUG
- g_print("row: %d out of %d rows\n", gsh->rows.row, gsh->rows.rows);
+ g_message("==> row: %d out of %d rows\n",
+ gsh->rows.row, gsh->rows.rows);
#endif /* DEBUG */
}
Index: gtkshell/geometry.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/geometry.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/geometry.c 13 Feb 2007 03:23:28 -0000 1.4
+++ gtkshell/geometry.c 17 Feb 2007 23:07:31 -0000 1.5
@@ -34,11 +34,14 @@
void
gsh_check_and_set_geometry(struct GSH *gsh)
{
- if(!gsh->geometry)
+ if(!gsh->geometry && !gsh->flags.dont_scroll)
asprintf(&gsh->geometry, "400x300");
+ if(!gsh->flags.dont_scroll)
+ {
gsh_set_geometry(gsh);
free(gsh->geometry);
+ }
}
Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/gtkshell.c 16 Feb 2007 22:18:01 -0000 1.7
+++ gtkshell/gtkshell.c 17 Feb 2007 23:07:31 -0000 1.8
@@ -50,12 +50,17 @@
rows->rows=8;
}
void
+gsh_GSH_Updater(struct GSH_Updater *update)
+{
+ update->period=1000;
+}
+void
gsh_GSH(struct GSH *gsh)
{
gsh->geometry=NULL;
- gsh->update_period=1000;
gsh_GSH_Flags(&gsh->flags);
gsh_GSH_Rows(&gsh->rows);
+ gsh_GSH_Updater(&gsh->update);
}
struct GSH *
gsh_new_GSH()
Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/gtkshell.h 16 Feb 2007 22:18:01 -0000 1.7
+++ gtkshell/gtkshell.h 17 Feb 2007 23:07:31 -0000 1.8
@@ -41,16 +41,22 @@
unsigned int rows;
};
+struct GSH_Updater
+{
+ unsigned int period;
+ GSList *list;
+};
+
struct GSH
{
GtkWidget *window;
GtkWidget *scrolled_window;
struct GSH_Rows rows;
struct GSH_Flags flags;
+ struct GSH_Updater update;
GtkWidget *label;
GtkWidget *button;
gchar *geometry;
- unsigned int update_period;
};
#include "arguments.h"
Index: gtkshell/option_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gtkshell/option_options.c 12 Feb 2007 16:36:56 -0000 1.2
+++ gtkshell/option_options.c 17 Feb 2007 23:07:31 -0000 1.3
@@ -45,7 +45,7 @@
break;
case 'u':
gsh_count(argc, counter);
- gsh->update_period=atoi(argv[*counter]);
+ gsh->update.period=atoi(argv[*counter]);
break;
}
}
Index: gtkshell/row.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/row.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/row.c 16 Feb 2007 22:18:01 -0000 1.4
+++ gtkshell/row.c 17 Feb 2007 23:07:31 -0000 1.5
@@ -25,14 +25,19 @@
void
gsh_manage(struct GSH *gsh, GtkWidget *widget)
{
+#ifdef DEBUG
+ g_message("gsh_manage()");
+#endif /* DEBUG */
+
gsh_check_row(gsh);
gtk_container_add(GTK_CONTAINER(gsh->rows.v), widget);
gtk_widget_show(widget);
gsh->rows.row++;
#ifdef DEBUG
- g_print("gsh_row: %d, gsh_rows: %d\n", gsh->rows.row, gsh->rows.rows);
-#endif
+ g_message("==> gsh_row: %d, gsh_rows: %d",
+ gsh->rows.row, gsh->rows.rows);
+#endif /* DEBUG */
}
@@ -51,14 +56,16 @@
{
#ifdef DEBUG
- printf("==> gsh_row: %d, gsh_rows: %d\n", gsh->rows.row, gsh->rows.rows);
+ g_message("gsh_check_row()");
+ g_message("==> gsh_row: %d, gsh_rows: %d",
+ gsh->rows.row, gsh->rows.rows);
#endif
if(gsh->rows.row == gsh->rows.rows)
{
#ifdef DEBUG
- g_print("new row");
+ g_message("==> new row");
#endif
gsh_new_row(gsh);
Index: gtkshell/updated.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gtkshell/updated.c 9 Feb 2007 03:16:12 -0000 1.2
+++ gtkshell/updated.c 17 Feb 2007 23:07:31 -0000 1.3
@@ -22,23 +22,16 @@
#include "gtkshell.h"
-/*
-
-TODO: Use hierarchical structures for globals.
- This was done on the Motif version.
- It will allow the use of a single global entity
- on the namespace, and further organization can
- be achieved.
-
-*/
-
-guint gsh_update_period=1000;
-GSList *gsh_updater_list;
void
-gsh_append_updater(gsh_updater_data *item)
+gsh_append_updater(struct GSH *gsh, gsh_updater_data *item)
{
- gsh_updater_list=g_slist_append(gsh_updater_list, item);
+
+#ifdef DEBUG
+ g_message("gsh_append_updater()");
+#endif /* DEBUG */
+
+ gsh->update.list=g_slist_append(gsh->update.list, item);
}
void
@@ -60,6 +53,7 @@
void
gsh_add_updater(
+ struct GSH *gsh,
void (*function)(char*, void*),
char *command, void *widget)
{
@@ -70,7 +64,7 @@
/* Initialize. */
gsh_assign_updater(item, function, command, widget);
/* Add to singly linked list. */
- gsh_append_updater(item);
+ gsh_append_updater(gsh, item);
}
void gsh_update_each(gpointer data, gpointer user_data)
@@ -83,7 +77,7 @@
/* Ensure that the argument containing
the structure is not empty. */
- assert(data != NULL);
+ assert(data);
/* Assign data to structure and call
function pointer with parameters. */
@@ -95,25 +89,34 @@
gint
gsh_perform_updates(gpointer data)
{
+ struct GSH *gsh;
#ifdef DEBUG
g_message("gsh_perform_updates()");
-#endif
+#endif /* DEBUG */
+
+ gsh=(struct GSH *)data;
UNUSED(data); /* DATA is unused. */
- g_slist_foreach(gsh_updater_list, gsh_update_each, NULL);
+#ifdef DEBUG
+ assert (gsh->update.list);
+#endif /* DEBUG */
+
+ g_slist_foreach(gsh->update.list, gsh_update_each, gsh);
return(TRUE);
}
void
-gsh_start_updates()
+gsh_start_updates(struct GSH *gsh)
{
+
#ifdef DEBUG
g_message("gsh_start_updates()");
-#endif
- gsh_perform_updates(NULL);
- g_timeout_add(gsh_update_period, gsh_perform_updates, NULL);
+#endif /* DEBUG */
+
+ gsh_perform_updates(gsh);
+ g_timeout_add(gsh->update.period, gsh_perform_updates, gsh);
}
Index: gtkshell/updated.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/updated.h 1 Feb 2007 20:45:49 -0000 1.1
+++ gtkshell/updated.h 17 Feb 2007 23:07:31 -0000 1.2
@@ -31,11 +31,12 @@
} gsh_updater_data;
void
-gsh_add_updater(void (*function)(char *, void *),
+gsh_add_updater(struct GSH *gsh,
+ void (*function)(char *, void *),
char *command, void *widget);
void
-gsh_start_updates();
+gsh_start_updates(struct GSH *gsh);
#endif
Index: gtkshell/updated_label.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_label.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/updated_label.c 13 Feb 2007 03:23:28 -0000 1.4
+++ gtkshell/updated_label.c 17 Feb 2007 23:07:31 -0000 1.5
@@ -25,7 +25,8 @@
void
gsh_check_results(char **results)
{
- /* This ensures that the result string is not empty, avoiding certain
formatting problems. */
+ /* This ensures that the result string is not empty,
+ avoiding certain formatting problems. */
/* Otherwise, a GTK warning is produced. */
if(!strncmp(*results, "", 1))
{
@@ -40,7 +41,7 @@
char *results;
#ifdef DEBUG
- puts("gsh_update_label()");
+ g_message("gsh_update_label()");
#endif
results=antiright_pipe_read(command);
@@ -57,10 +58,11 @@
GtkWidget *widget;
#ifdef DEBUG
- puts("gsh_add_updated_label()");
+ g_message("gsh_add_updated_label()");
#endif
widget=gtk_label_new("");
gsh_manage(gsh, widget);
- gsh_add_updater(&gsh_update_label, command, (void*)widget);
+ gsh_add_updater(gsh, &gsh_update_label,
+ command, (void*)widget);
}
Index: gtkshell/updated_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_options.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/updated_options.c 13 Feb 2007 03:23:28 -0000 1.4
+++ gtkshell/updated_options.c 17 Feb 2007 23:07:31 -0000 1.5
@@ -27,7 +27,7 @@
{
if(!gsh->flags.updating)
{
- gsh_start_updates();
+ gsh_start_updates(gsh);
gsh->flags.updating=TRUE;
}
}
Index: gtkshell/updated_progress.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_progress.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gtkshell/updated_progress.c 13 Feb 2007 03:23:28 -0000 1.2
+++ gtkshell/updated_progress.c 17 Feb 2007 23:07:31 -0000 1.3
@@ -37,6 +37,7 @@
GtkWidget *widget;
widget=gtk_progress_bar_new();
gsh_manage(gsh, widget);
- gsh_add_updater(&gsh_update_progress, command, (void*)widget);
+ gsh_add_updater(gsh, &gsh_update_progress,
+ command, (void*)widget);
}
Index: libantiright/util.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/util.c 11 Feb 2007 04:23:30 -0000 1.5
+++ libantiright/util.c 17 Feb 2007 23:07:31 -0000 1.6
@@ -25,23 +25,23 @@
gpointer
xmalloc(size_t size)
{
- gpointer pointer;
- pointer=g_malloc(size);
- assert(pointer); /* Ensure that the allocation was
- successful. */
- return(pointer);
+ /* There is no need to check for success,
+ as g_malloc causes the application to
+ terminate on failure. */
+
+ return(g_malloc(size));
}
void
rand_seed()
{
- srand((unsigned int)time(NULL));
+ srandom((unsigned int)time(NULL));
}
int
rand_ranged(int start, int finish)
{
- return rand()%(finish-start)+start;
+ return random()%(finish-start)+start;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/button.c gtkshell/geometry.c...,
Jeffrey Bedard <=