antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright/gtkshell updated.c updated.h updated_...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright/gtkshell updated.c updated.h updated_...
Date: Thu, 03 May 2007 04:36:18 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/05/03 04:36:18

Modified files:
        gtkshell       : updated.c updated.h updated_options.c 
                         updated_progress.c 
Added files:
        gtkshell       : update_manager.c update_manager.h 
                         update_manager_struct.h 

Log message:
        Finished up changes to updater code.  Added new manager class
        for updater list.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.c?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated.h?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_options.c?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/updated_progress.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/update_manager.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/update_manager.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/update_manager_struct.h?cvsroot=antiright&rev=1.1

Patches:
Index: updated.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- updated.c   3 May 2007 03:42:31 -0000       1.14
+++ updated.c   3 May 2007 04:36:18 -0000       1.15
@@ -29,29 +29,26 @@
        g_free(item);
 }
 
+static void
+gsh_GSHUpdatedWidget_update(struct GSHUpdatedWidget * item)
+{
+       item->function(item->command, item->widget);
+}
+
 struct GSHUpdatedWidget *
 gsh_new_GSHUpdatedWidget(void (*function)(const gchar *, gpointer), 
        const gchar * command, GtkWidget * widget)
 {
-       struct gsh_GSHUpdatedWidget * updater;
-       updater=xmalloc(sizeof(struct gsh_GSHUpdatedWidget));
+       struct GSHUpdatedWidget * updater;
+
+       updater=xmalloc(sizeof(struct GSHUpdatedWidget));
        updater->command=g_strdup(command);
        updater->widget=widget;
-       updater->update=function;
+       updater->function=function;
+       updater->update=&gsh_GSHUpdatedWidget_update;
        updater->delete=&gsh_delete_GSHUpdatedWidget;
-}
 
-
-void
-gsh_add_updater(struct GSH * gsh,
-               void (*function) (const gchar *, gpointer),
-               const gchar *command, GtkWidget *widget)
-{
-       struct GSHUpdatedWidget * item;
-
-       /* Allocate memory for ITEM cell.  */
-       item=ARNEW(gsh, GSHUpdatedWidget, function, command, widget);
-       /* Add to singly linked list.  */
-       gsh_append_updater(gsh, item);
+       return updater;
 }
 
+

Index: updated.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- updated.h   3 May 2007 03:42:31 -0000       1.8
+++ updated.h   3 May 2007 04:36:18 -0000       1.9
@@ -27,8 +27,8 @@
 {
        GtkWidget * widget;
        gchar * command;
-       void (*update) (struct GSHUpdatedWidget *, 
-               const gchar *, gpointer);
+       void (*function)(const gchar *, gpointer);
+       void (*update)(struct GSHUpdatedWidget *);
        void (*delete)(struct GSHUpdatedWidget *);
 };
 

Index: updated_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_options.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- updated_options.c   4 Mar 2007 03:20:14 -0000       1.12
+++ updated_options.c   3 May 2007 04:36:18 -0000       1.13
@@ -25,11 +25,13 @@
 static void
 gsh_test_updating(struct GSH * gsh)
 {
+#ifdef DEBUG
        ARPASSERT(gsh);
-       if((gsh->bflags & GSH_UPDATING) != GSH_UPDATING)
+#endif /* DEBUG */
+       if(!(GSH_FLAG(GSH_UPDATING)))
        {
-               gsh_start_updates(gsh);
-               gsh->bflags |= GSH_UPDATING;
+               $(gsh->update, start);
+               GSH_SET(GSH_UPDATING);
        }
 
 }

Index: updated_progress.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/updated_progress.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- updated_progress.c  3 May 2007 03:42:31 -0000       1.11
+++ updated_progress.c  3 May 2007 04:36:18 -0000       1.12
@@ -30,7 +30,7 @@
 #ifdef DEBUG
        ARPASSERT(command);
        ARPASSERT(widget);
-#endif /* DEBUG
+#endif /* DEBUG */
 
        results = antiright_pipe_read((char *)command);
 #ifdef DEBUG

Index: update_manager.c
===================================================================
RCS file: update_manager.c
diff -N update_manager.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ update_manager.c    3 May 2007 04:36:18 -0000       1.1
@@ -0,0 +1,160 @@
+/*
+  AntiRight
+  (c) 2002-2006 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight 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.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#include "gtkshell.h"
+
+static void
+gsh_GSHUpdateManager_add(struct GSHUpdateManager * updaters, 
+       struct GSHUpdatedWidget * item)
+{
+
+#ifdef DEBUG
+       ARBUG("gsh_append_updater()");
+
+       if (ARPBOOL(updaters) && ARPBOOL(item))
+#endif                         /* DEBUG */
+               updaters->list = g_slist_prepend(updaters->list, item);
+
+#ifdef DEBUG
+       ARBUG("end gsh_append_updater()");
+#endif                         /* DEBUG */
+}
+
+static void
+gsh_update_each(gpointer data, gpointer user_data)
+{
+#ifdef DEBUG
+       UNUSED(user_data);      /* USER_DATA is unused.  */
+#endif /* DEBUG */
+
+       /*
+        * Ensure that the argument containing the structure is not
+        * empty.
+        */
+#ifdef DEBUG
+       ARWIFNP(data)
+       {
+#endif /* DEBUG */
+               struct GSHUpdatedWidget *item;
+
+               /*
+                * Assign data to structure and call function pointer
+                * with parameters.
+                */
+               item = (struct GSHUpdatedWidget *) data;
+#ifdef DEBUG
+               ARPASSERT(item->update);
+#endif /* DEBUG */
+               $(item, update);
+#ifdef DEBUG
+       }
+#endif /* DEBUG */
+}
+
+static gint
+gsh_perform_updates(gpointer data)
+{
+       struct GSHUpdateManager * updaters;
+
+#ifdef DEBUG
+       ARBUG("gsh_perform_updates()");
+#endif                         /* DEBUG */
+
+       updaters = (struct GSHUpdateManager *) data;
+
+
+#ifdef DEBUG
+       if (updaters && updaters->list)
+#endif /* DEBUG */
+               g_slist_foreach(updaters->list, gsh_update_each, NULL);
+#ifdef DEBUG
+       else
+       {
+               ARWARN("data invalid, operation not performed.");
+               return FALSE;
+       }
+#endif /* DEBUG */
+
+       return TRUE;
+}
+
+static void
+gsh_GSHUpdateManager_start(struct GSHUpdateManager * updaters)
+{
+
+#ifdef DEBUG
+       ARBUG("gsh_start_updates()");
+#endif                         /* DEBUG */
+
+#ifdef DEBUG
+       ARWIFNP (updaters)
+       {
+#endif /* DEBUG */
+               (void) gsh_perform_updates(updaters);
+               (void) g_timeout_add(updaters->period, gsh_perform_updates,
+                                    updaters);
+#ifdef DEBUG
+       }
+#endif /* DEBUG */
+}
+
+static void
+gsh_delete_each_updater(gpointer data, gpointer user_data)
+{
+       struct GSHUpdatedWidget * item;
+
+       item=(struct GSHUpdatedWidget *)data;
+       $(item, delete);
+}
+
+static void
+gsh_delete_GSHUpdateManager(struct GSHUpdateManager * updaters)
+{
+       g_slist_foreach(updaters->list, gsh_delete_each_updater, NULL);
+       g_slist_free(updaters->list);
+       g_free(updaters);
+}
+
+static void
+gsh_setup_GSHUpdateManager(struct GSHUpdateManager * update)
+{
+       update->period = 1000;
+
+       /* Pointer must have not previously been used.  */
+       update->list = (GSList *) NULL;
+       update->delete=&gsh_delete_GSHUpdateManager;
+       update->add=&gsh_GSHUpdateManager_add;
+       update->start=&gsh_GSHUpdateManager_start;
+}
+
+struct GSHUpdateManager *
+gsh_new_GSHUpdateManager()
+{
+       struct GSHUpdateManager * updater;
+
+       updater=xmalloc(sizeof(struct GSHUpdateManager));
+       gsh_setup_GSHUpdateManager(updater);
+
+       return updater;
+}
+
+

Index: update_manager.h
===================================================================
RCS file: update_manager.h
diff -N update_manager.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ update_manager.h    3 May 2007 04:36:18 -0000       1.1
@@ -0,0 +1,30 @@
+/*
+  AntiRight
+  (c) 2002-2006 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight 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.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#ifndef GSH_UPD_MAN_H
+#define GSH_UPD_MAN_H
+
+struct GSHUpdateManager *
+gsh_new_GSHUpdateManager();
+
+#endif /* GSH_UPD_MAN_H */
+

Index: update_manager_struct.h
===================================================================
RCS file: update_manager_struct.h
diff -N update_manager_struct.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ update_manager_struct.h     3 May 2007 04:36:18 -0000       1.1
@@ -0,0 +1,36 @@
+/*
+  AntiRight
+  (c) 2002-2006 Jeffrey Bedard
+  address@hidden
+
+  This file is part of AntiRight.
+
+  AntiRight 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.
+
+  AntiRight is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with AntiRight; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+*/
+
+#ifndef GSH_UMS_H
+#define GSH_UMS_H
+
+struct GSHUpdateManager
+{
+       unsigned int period;
+       /address@hidden@*/ GSList *list;
+       void (*delete)(struct GSHUpdateManager *);
+       void (*add)(struct GSHUpdateManager * , struct GSHUpdatedWidget *);
+       void (*start)(struct GSHUpdateManager *);
+};
+
+#endif /* GSH_UMS_H */
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]