/[antiright]/antiright/src/arshell/update.c
ViewVC logotype

Diff of /antiright/src/arshell/update.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by jefbed, Thu Aug 19 21:51:11 2004 UTC revision 1.3 by jefbed, Mon Aug 23 01:15:56 2004 UTC
# Line 25  Line 25 
25  void  void
26  arshell_update()  arshell_update()
27  {  {
28    int counter;    struct arshell_update_struct *iterator=arshell.updater;
29    for(counter=0; counter < arshell.updaters_int; counter++)    while(iterator->next!=NULL)
30      {      {
31        char *input_string=        char *input_string;
32          antiright_pipe_read(arshell.updater[counter].command_string);        iterator=iterator->next;
33          input_string=antiright_pipe_read(iterator->command_string);
34        input_string[strlen(input_string)-1]='\0';        input_string[strlen(input_string)-1]='\0';
35        if(XmIsLabel(arshell.updater[counter].widget))        
36          if(XmIsLabel(iterator->widget))
37          {          {
38            antiright_label_string(arshell.updater[counter].widget,            antiright_label_string(iterator->widget,
39                                   input_string);                                   input_string);
40          }          }
41        else if(XmIsScrollBar(arshell.updater[counter].widget))        else if(XmIsScrollBar(iterator->widget))
42          {          {
43            int value_int=atoi(input_string);            int value_int=atoi(input_string);
44            if((value_int>0)&(value_int<=100))            if((value_int>0)&(value_int<=100))
45              {              {
46                XtVaSetValues(arshell.updater[counter].widget,                XtVaSetValues(iterator->widget,
47                              XmNsliderSize, value_int,                              XmNsliderSize, value_int,
48                              NULL);                              NULL);
49              }              }
50          }          }
51        else if(arshell.updater[counter].widget==arshell.gui.widgets.work)        else if(iterator->widget==arshell.gui.widgets.work)
52          {          {
53              assert(arshell.gui.widgets.work != NULL);
54              assert(iterator->widget != NULL);
55            /* Append input_string to the work area.  */            /* Append input_string to the work area.  */
56            XmTextInsert(arshell.gui.widgets.work,            XmTextInsert(arshell.gui.widgets.work,
57                         XmTextGetLastPosition(arshell.gui.widgets.work),                         XmTextGetLastPosition(arshell.gui.widgets.work),
# Line 56  arshell_update() Line 60  arshell_update()
60                         XmTextGetLastPosition(arshell.gui.widgets.work),                         XmTextGetLastPosition(arshell.gui.widgets.work),
61                         "\n");                         "\n");
62          }          }
63        else if(arshell.updater[counter].widget==antiright.parent_widget)        else if(iterator->widget==antiright.parent_widget)
64          {          {
65            /* Set the title to input_string.  */            /* Set the title to input_string.  */
66            antiright_set_title(input_string);            antiright_set_title(input_string);
# Line 66  arshell_update() Line 70  arshell_update()
70  }  }
71    
72  void  void
73  arshell_add_updater(Widget widget, char* command_string)  arshell_restart_timers()
74  {  {
   arshell.updater[arshell.updaters_int].widget=widget;  
   strncpy(arshell.updater[arshell.updaters_int].command_string,  
           command_string, ARSHELL_MAX_STRLEN);  
   arshell.updaters_int++;  
75    if((arshell.timer_id)!=NULL)    if((arshell.timer_id)!=NULL)
76      XtRemoveTimeOut((*arshell.timer_id));      XtRemoveTimeOut((*arshell.timer_id));
77    arshell_update();    arshell_update();
# Line 80  arshell_add_updater(Widget widget, char* Line 80  arshell_add_updater(Widget widget, char*
80  }  }
81    
82  void  void
83    arshell_add_updater(Widget widget, char* command_string)
84    {
85      struct arshell_update_struct *iterator;
86    
87      /* Initialize the global instance, if necessary.  */
88      if(arshell.updater==NULL)
89        {
90          arshell.updater=
91            (struct arshell_update_struct *)xmalloc
92            (sizeof(struct arshell_update_struct));
93          arshell.updater->next=NULL;
94        }
95    
96      /* Initialize from global instance.  */
97      iterator=arshell.updater;
98    
99      /* Go to the end of the list.  */
100      while(iterator->next!=NULL)
101        iterator=iterator->next;
102    
103      /* Append the updating rules.  */
104      iterator->next=
105        (struct arshell_update_struct *)xmalloc
106        (sizeof(struct arshell_update_struct));
107      iterator=iterator->next;
108      iterator->next=NULL;
109      iterator->widget=widget;
110      strncpy(iterator->command_string, command_string, ARSHELL_MAX_STRLEN);
111      arshell_restart_timers();
112    }
113    
114    void
115  arshell_update_work_procedure(XtPointer client_data,  arshell_update_work_procedure(XtPointer client_data,
116                                XtIntervalId *timer_id)                                XtIntervalId *timer_id)
117  {    {  
118    arshell_update();    arshell_update();
119    *timer_id=    *timer_id=
120      XtAppAddTimeOut(antiright.app_context, arshell.update_frequency,      XtAppAddTimeOut(antiright.app_context, arshell.update_frequency,
121                      arshell_update_work_procedure, NULL);                      arshell_update_work_procedure, client_data);
122    arshell.timer_id=timer_id;    arshell.timer_id=timer_id;
123  }  }
124    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26