[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/gtkshell Makefile clock.c updated.h u...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/gtkshell Makefile clock.c updated.h u... |
Date: |
Sun, 22 Jul 2007 17:51:21 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/07/22 17:51:21
Modified files:
gtkshell : Makefile clock.c updated.h updated_label.c
updated_progress.c
Log message:
Consolidated updater add procedure to convenience macro.
Allocate clock time string into stack buffer, rather than heap.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/clock.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.h?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_label.c?cvsroot=antiright&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_progress.c?cvsroot=antiright&r1=1.17&r2=1.18
Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- Makefile 9 Jul 2007 02:12:25 -0000 1.41
+++ Makefile 22 Jul 2007 17:51:21 -0000 1.42
@@ -26,7 +26,7 @@
include ../config.mk
CFLAGS+=$(DEFS) $(INCLUDE)
-ARFLAGS=-L. -lshell -L../libantiright -lantiright
+ARFLAGS=-L. -lgtkshell -L../libantiright -lantiright
GTKFLAGS=$(ARFLAGS) $(LDFLAGS)
#LDFLAGS+=-lefence
Index: clock.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/clock.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- clock.c 11 Jun 2007 21:32:38 -0000 1.4
+++ clock.c 22 Jul 2007 17:51:21 -0000 1.5
@@ -23,50 +23,47 @@
#include "gtkshell.h"
#include <time.h>
-static gchar *
-get_time_string()
+#define GSH_CLOCK_TIME_STRING_SIZE 20
+
+static void
+get_time_string(gchar * time_string)
{
- gchar * time_string;
- struct tm split_time;
time_t time_value;
(void)time(&time_value);
+ {
+ struct tm split_time;
+
(void)localtime_r(&time_value, &split_time);
- asprintf(&time_string, "%.2d/%.2d/%.2d\n%.2d:%.2d:%.2d",
+ (void)snprintf(time_string,
+ GSH_CLOCK_TIME_STRING_SIZE,
+ "%.2d/%.2d/%.2d\n%.2d:%.2d:%.2d",
split_time.tm_mon+1,
split_time.tm_mday,
split_time.tm_year%100,
split_time.tm_hour,
split_time.tm_min,
split_time.tm_sec);
-
- return time_string;
+ }
}
static void
update_clock(const gchar * command, gpointer clock_pointer)
{
- GtkWidget * clock;
- gchar * time_string;
+ gchar time_string[GSH_CLOCK_TIME_STRING_SIZE];
- UNUSED(command);
- clock=(GtkWidget *)clock_pointer;
- time_string=get_time_string();
- gtk_label_set_text(GTK_LABEL(clock), time_string);
- g_free(time_string);
+ get_time_string(time_string);
+ gtk_label_set_text(GTK_LABEL((GtkWidget *)clock_pointer),
+ time_string);
}
GtkWidget *
gsh_clock_new(GSH * gsh)
{
GtkWidget * clock;
- struct GSHUpdatedWidget * updated_widget;
- clock=gtk_label_new(NULL);
- gsh_widget_set_font(clock, NULL);
- updated_widget=ARNEW(gsh, GSHUpdatedWidget,
- &update_clock, NULL, clock);
- $(gsh->update, add, updated_widget);
+ gsh_widget_set_font(clock=gtk_label_new(NULL), "Mono 10");
+ GSH_NEW_UPDATER(gsh, update_clock, clock);
return clock;
}
Index: updated.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- updated.h 11 Jun 2007 21:32:45 -0000 1.11
+++ updated.h 22 Jul 2007 17:51:21 -0000 1.12
@@ -36,4 +36,10 @@
gsh_new_GSHUpdatedWidget(void (*function)(const gchar *, gpointer),
const gchar * command, GtkWidget * widget);
+#define GSH_NEW_UPDATER_WITH_COMMAND(gsh, function, widget, command)\
+ $(gsh->update, add, ARNEW(gsh, GSHUpdatedWidget,\
+ &function, command, widget))
+#define GSH_NEW_UPDATER(gsh, function, widget)\
+ GSH_NEW_UPDATER_WITH_COMMAND(gsh, function, widget, NULL)
+
#endif
Index: updated_label.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_label.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- updated_label.c 11 Jun 2007 21:32:45 -0000 1.23
+++ updated_label.c 22 Jul 2007 17:51:21 -0000 1.24
@@ -60,18 +60,15 @@
void
gsh_add_updated_label(struct GSH * gsh, const gchar *command)
{
-#define GWA gsh->widgets.app
- GtkWidget * status = GWA.status;
-#ifdef DEBUG
- g_message("gsh_add_updated_label()");
- ARPASSERT(gsh);
- ARPASSERT(command);
-#endif /* DEBUG */
- $(gsh->update, add, ARNEW(gsh, GSHUpdatedWidget, &gsh_update_label,
- command, (GSH_FLAG(GSH_APP_MODE) && status)
- ? status : gsh_add_label(gsh, (char *)command)));
+ GtkWidget * update_target;
+
+#define GSH_STATUS_WIDGET gsh->widgets.app.status
+ if(!(GSH_FLAG(GSH_APP_MODE) && (update_target=GSH_STATUS_WIDGET)))
+ update_target=gsh_add_label(gsh, (char *) command);
+ GSH_NEW_UPDATER_WITH_COMMAND(gsh, gsh_update_label,
+ update_target, command);
GSH_UNSET(GSH_APP_MODE);
/* Prevent two updaters from being
assigned to the status bar label. */
- GWA.status=NULL;
+ GSH_STATUS_WIDGET=NULL;
}
Index: updated_progress.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_progress.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- updated_progress.c 11 Jun 2007 21:32:45 -0000 1.17
+++ updated_progress.c 22 Jul 2007 17:51:21 -0000 1.18
@@ -27,13 +27,8 @@
{
gchar *results;
-#ifdef DEBUG
- ARPASSERT(command);
- ARPASSERT(widget);
-#endif /* DEBUG */
-
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR((GtkWidget *) widget),
- strtod(results=antiright_pipe_read((char*)command), NULL));
+ g_strtod(results=antiright_pipe_read(command), NULL));
g_free(results);
}
@@ -42,12 +37,7 @@
{
GtkWidget *progress;
-#ifdef DEBUG
- ARPASSERT(gsh);
- ARPASSERT(command);
-#endif /* DEBUG */
- progress=gtk_progress_bar_new();
- $(gsh, manage, progress);
- $(gsh->update, add, ARNEW(gsh, GSHUpdatedWidget,
- &gsh_update_progress, command, progress));
+ $(gsh, manage, progress=gtk_progress_bar_new());
+ GSH_NEW_UPDATER_WITH_COMMAND(gsh, gsh_update_progress,
+ progress, command);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright/gtkshell Makefile clock.c updated.h u...,
Jeffrey Bedard <=