[Initng-svn] r4364 - initng-gui/initng-conf-gtk/src
svn at initng.thinktux.net
svn at initng.thinktux.net
Mon Jun 5 12:28:09 CEST 2006
Author: danne
Date: Mon Jun 5 12:28:07 2006
New Revision: 4364
Modified:
initng-gui/initng-conf-gtk/src/ngchandler.c
initng-gui/initng-conf-gtk/src/ngehandler.c
Log:
Added some more clearity to Jimmys comments from 4343. Also reverted 4348. It makes no sense with a requester since it sometimes can take a while to start or stop a service, meaning the requester will pop up later. It's better to just leave the feedback to the service tree. (I hope you don't mind, Jimmy?)
Modified: initng-gui/initng-conf-gtk/src/ngchandler.c
==============================================================================
--- initng-gui/initng-conf-gtk/src/ngchandler.c (original)
+++ initng-gui/initng-conf-gtk/src/ngchandler.c Mon Jun 5 12:28:07 2006
@@ -43,34 +43,12 @@
return answer;
}
-void ngc_send(const char c, const char *opt, const char *text) {
- reply *rep = NULL;
- GtkWidget * w;
- char *string = malloc(strlen(text) + 100);
- printf("ngc_send(%c, %s, %s);\n", c, opt, text);
-
- rep = ngcclient_send_command(SOCKET_4_FILENAME_REAL, c, NULL, opt);
-
-
- strcpy(string, text);
- if (rep->result.s == S_TRUE)
- {
- strcat(string, " SUCCEDED.");
- } else {
- strcat(string, " FAILED!");
- }
-
- printf("%s\n", string);
+void ngc_send(const char c, const char *opt) {
+ char *string = NULL;
- /* put up the messagebox */
- w=gtk_message_dialog_new(GTK_WINDOW(glade_xml_get_widget(xml, "initconf_app")), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, string);
- gtk_dialog_run(GTK_DIALOG(w));
- gtk_widget_destroy(w);
-
-
- /* free */
- free(string);
- free(rep);
+ string = ngc_send_and_reply(c, opt);
+ if (string)
+ free(string);
}
void start_service(const char *name) {
@@ -89,43 +67,20 @@
glade_xml_signal_autoconnect(xml_start_service);
free(newname);
} else {
- char *str = malloc(strlen(name) + 10);
- strcpy(str, "Starting ");
- strcat(str, name);
- strcat(str, ": ");
-
- ngc_send('u', name, str);
-
- free(str);
+ ngc_send('u', name);
}
}
void stop_service(const char *name) {
- char *str = malloc(strlen(name) + 10);
- strcpy(str, "Stopping ");
- strcat(str, name);
- strcat(str, ": ");
- ngc_send('d', name, str);
- free(str);
+ ngc_send('d', name);
}
void restart_service(const char *name) {
- char *str = malloc(strlen(name) + 10);
- strcpy(str, "Restarting ");
- strcat(str, name);
- strcat(str, ": ");
- ngc_send('r', name, str);
- free(str);
+ ngc_send('r', name);
}
void zap_service(const char *name) {
- char *str = malloc(strlen(name) + 10);
- strcpy(str, "Zapping ");
- strcat(str, name);
- strcat(str, ": ");
-
- ngc_send('z', name, str);
- free(str);
+ ngc_send('z', name);
}
void service_log(const char *name) {
Modified: initng-gui/initng-conf-gtk/src/ngehandler.c
==============================================================================
--- initng-gui/initng-conf-gtk/src/ngehandler.c (original)
+++ initng-gui/initng-conf-gtk/src/ngehandler.c Mon Jun 5 12:28:07 2006
@@ -36,32 +36,30 @@
* defined in initng-conf-gtk.glade */
GtkTreeView *service_list = GTK_TREE_VIEW(glade_xml_get_widget(xml, "service_list"));
- /* get, an pointer to the tree_model set in this list */
+ /* The information about the stuff in the tree is stored in a model. On top of
+ * that there's another model used for filtering, and on top of that there's
+ * a model used for sorting. This means that to get the model we want (the one
+ * that holds the data) we have to get the others first. Hence the following */
GtkTreeModelSort *sortmodel = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(service_list));
-
- /* get, the child model, of the sortmodel used for filtering ? */
GtkTreeModelFilter *filtermodel = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(sortmodel));
-
- /* get, an pointer to the child model of the filter ??? */
GtkTreeModel *service_model = gtk_tree_model_filter_get_model(filtermodel);
-
- /*
- * Itterator used to point out the correct row added by add_node in service_model that
- * we are gonna modify.
- */
+
+ /* Iterator used to point out the correct row added by add_node in service_model that
+ * we are gonna modify. */
GtkTreeIter iter;
/* the real data storage struct from serviceparser.h */
struct s_info *serviceinfo = NULL;
/* if we had to add a new entry to the tree .. */
- /* add_node, defined in serviceparser.c */
+ /* add_node, defined in serviceparser.c, returns false if the node didn't exist */
if(add_node(GTK_TREE_STORE(service_model), &iter, service)) {
- /* create som space for an s_info struct, using calloc to make sure newly allocated area is all NULL */
+ /* create som space for an s_info struct, using calloc to make sure allocated area is all NULL */
serviceinfo = calloc(1,sizeof(struct s_info));
-
- /* dont know what this do, maby sets fuction col to "unknown" */
+
+ /* Store the data in the tree. Since we had to create the node, we have no
+ * way of knowing what type it is, hence the "unknown". */
gtk_tree_store_set(GTK_TREE_STORE(service_model), &iter, 1, _("unknown"),
2, NULL, 4, serviceinfo, -1);
@@ -71,7 +69,7 @@
/* insert the service name */
serviceinfo->fullname = strdup(service);
} else {
- /* Not newly allocated abow, this is not known */
+ /* Not newly allocated above, this is not known */
gtk_tree_model_get(service_model, &iter, 4, &serviceinfo, -1);
}
@@ -86,7 +84,7 @@
* NOTE: state pointer is not valid after this function returns, freed by ngeclient_event_free(e); */
gtk_tree_store_set(GTK_TREE_STORE(service_model), &iter, 2, strdup(state), -1);
- /* put nice little colors to the 4th cell of this tree depending on current state */
+ /* put nice little colors in the tree depending on current state */
switch(is) {
case IS_UP:
gtk_tree_store_set(GTK_TREE_STORE(service_model), &iter, 3, "#AAFFAA", -1);
@@ -127,7 +125,7 @@
GtkTreeModelSort *sortmodel = GTK_TREE_MODEL_SORT(gtk_tree_view_get_model(service_list));
GtkTreeModelFilter *filtermodel = GTK_TREE_MODEL_FILTER(gtk_tree_model_sort_get_model(sortmodel));
- /* as i understand, refilter will update screen */
+ /* Refilter will update the service tree */
gtk_tree_model_filter_refilter(filtermodel);
gdk_threads_leave();
}
@@ -195,7 +193,7 @@
initial_state_finished();
break;
- /* on dissconnect close the socket, and set c to null so the while loop stops */
+ /* on disconnect close the socket, and set c to null so the while loop stops */
case DISSCONNECT:
ngeclient_close(c);
c=NULL;
More information about the Initng-svn
mailing list