[Initng-svn] r3679 - initng-gui/initconf/src
svn at initng.thinktux.net
svn at initng.thinktux.net
Wed Apr 5 10:25:14 CEST 2006
Author: danne
Date: Wed Apr 5 10:25:12 2006
New Revision: 3679
Modified:
initng-gui/initconf/src/callbacks.c
initng-gui/initconf/src/initconf.glade
initng-gui/initconf/src/initconf_globals.h
initng-gui/initconf/src/ngchandler.c
initng-gui/initconf/src/ngchandler.h
initng-gui/initconf/src/ngehandler.c
initng-gui/initconf/src/serviceparser.h
Log:
Nge events about services not already in service list now adds them to the list. I also added functionality for starting services including * (Try it out yourself). I'll add the same functionality for adding them to runlevels...
Modified: initng-gui/initconf/src/callbacks.c
==============================================================================
--- initng-gui/initconf/src/callbacks.c (original)
+++ initng-gui/initconf/src/callbacks.c Wed Apr 5 10:25:12 2006
@@ -217,6 +217,21 @@
gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
}
+void on_cancel_start_service_button_clicked (GtkButton *button, gpointer user_data)
+{
+ gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
+}
+
+void on_ok_start_service_button_clicked (GtkButton *button, gpointer user_data)
+{
+ GtkWidget *start_service_name_entry;
+
+ start_service_name_entry = glade_xml_get_widget(xml_start_service, "start_service_name_entry");
+
+ start_service(gtk_entry_get_text(GTK_ENTRY(start_service_name_entry)));
+ gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button)));
+}
+
void on_service_list_row_activated (GtkTreeView *treeview, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data)
{
Modified: initng-gui/initconf/src/initconf.glade
==============================================================================
--- initng-gui/initconf/src/initconf.glade (original)
+++ initng-gui/initconf/src/initconf.glade Wed Apr 5 10:25:12 2006
@@ -14,6 +14,7 @@
<property name="default_height">750</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
+ <property name="icon">pixmaps/initconf-icon.png</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
@@ -504,7 +505,7 @@
<widget class="GtkDialog" id="initconf_new_runlevel">
<property name="visible">True</property>
- <property name="title" translatable="yes">dialog1</property>
+ <property name="title" translatable="yes">Add new runlevel</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@@ -568,60 +569,47 @@
</child>
<child>
- <widget class="GtkVBox" id="vbox1">
+ <widget class="GtkLabel" id="new_runlevel_name_label">
<property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
-
- <child>
- <widget class="GtkLabel" id="new_runlevel_name_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">What is the name of the new runlevel?</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">What is the name of the new runlevel?</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
- <child>
- <widget class="GtkEntry" id="new_runlevel_name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal name="activate" handler="gtk_window_activate_default" object="initconf_new_runlevel" last_modification_time="Mon, 16 Jan 2006 12:21:28 GMT"/>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <child>
+ <widget class="GtkEntry" id="new_runlevel_name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="gtk_window_activate_default" object="initconf_new_runlevel" last_modification_time="Mon, 16 Jan 2006 12:21:28 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
</packing>
</child>
</widget>
@@ -678,4 +666,230 @@
</child>
</widget>
+<widget class="GtkDialog" id="initconf_add_service">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Add service to runlevel</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancel_add_service_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ <signal name="clicked" handler="on_cancel_add_service_button_clicked" last_modification_time="Fri, 13 Jan 2006 14:22:45 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="ok_add_service_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ <signal name="clicked" handler="on_ok_add_service_button_clicked" last_modification_time="Fri, 13 Jan 2006 14:22:32 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="add_service_name_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">What is the name of the service to add?</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="add_service_name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="gtk_window_activate_default" object="initconf_add_service" last_modification_time="Mon, 16 Jan 2006 12:21:28 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+<widget class="GtkDialog" id="initconf_start_service">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Start service</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">True</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancel_start_service_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ <signal name="clicked" handler="on_cancel_start_service_button_clicked" last_modification_time="Fri, 13 Jan 2006 14:22:45 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="ok_start_service_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ <signal name="clicked" handler="on_ok_start_service_button_clicked" last_modification_time="Fri, 13 Jan 2006 14:22:32 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="start_service_name_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">What is the name of the service to start?</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="start_service_name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="gtk_window_activate_default" object="initconf_start_service" last_modification_time="Mon, 16 Jan 2006 12:21:28 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Modified: initng-gui/initconf/src/initconf_globals.h
==============================================================================
--- initng-gui/initconf/src/initconf_globals.h (original)
+++ initng-gui/initconf/src/initconf_globals.h Wed Apr 5 10:25:12 2006
@@ -1,11 +1,14 @@
#ifndef INITCONF_GLOBALS_H
#define INITCONF_GLOBALS_H
+#include <glade/glade.h>
+
#define FILENAME INITCONF_GLADE_DIR "/initconf.glade"
#define SECONDARY_FILENAME "src/initconf.glade"
#define ROOTNODE "initconf_app"
GladeXML *xml;
GladeXML *xml_new_runlevel;
+GladeXML *xml_start_service;
#endif
Modified: initng-gui/initconf/src/ngchandler.c
==============================================================================
--- initng-gui/initconf/src/ngchandler.c (original)
+++ initng-gui/initconf/src/ngchandler.c Wed Apr 5 10:25:12 2006
@@ -40,7 +40,24 @@
}
void start_service(const char *name) {
- ngc_send('u', name);
+ if(strrchr(name, '*')) {
+ gchar *newname = malloc(strlen(name));
+ xml_start_service = glade_xml_new(FILENAME, "initconf_start_service", NULL);
+ if(!xml_start_service)
+ xml_start_service = glade_xml_new(SECONDARY_FILENAME,
+ "initconf_start_service", NULL);
+ GtkWidget *start_service_name_entry = glade_xml_get_widget(xml_start_service,
+ "start_service_name_entry");
+ strncpy(newname, name, strlen(name)-1);
+ newname[strlen(name)-1] = 0;
+ fprintf(stderr, "Copying %s to %s\n", name, newname);
+ gtk_entry_set_text(GTK_ENTRY(start_service_name_entry), newname);
+ gtk_editable_set_position(GTK_EDITABLE(start_service_name_entry), -1);
+ glade_xml_signal_autoconnect(xml_start_service);
+ free(newname);
+ } else {
+ ngc_send('u', name);
+ }
}
void stop_service(const char *name) {
Modified: initng-gui/initconf/src/ngchandler.h
==============================================================================
--- initng-gui/initconf/src/ngchandler.h (original)
+++ initng-gui/initconf/src/ngchandler.h Wed Apr 5 10:25:12 2006
@@ -17,10 +17,18 @@
* Boston, MA 02110-1301, USA.
*/
+#ifndef NGCHANDLER_H
+#define NGCHANDLER_H
+
#include <initng-paths.h>
+#include <gnome.h>
+
#include "libngcclient.h"
+#include "initconf_globals.h"
void start_service(const char *name);
void stop_service(const char *name);
void restart_service(const char *name);
+
+#endif
Modified: initng-gui/initconf/src/ngehandler.c
==============================================================================
--- initng-gui/initconf/src/ngehandler.c (original)
+++ initng-gui/initconf/src/ngehandler.c Wed Apr 5 10:25:12 2006
@@ -33,44 +33,55 @@
GtkTreeModelFilter *filtermodel = GTK_TREE_MODEL_FILTER(gtk_tree_view_get_model(service_list));
GtkTreeModel *service_model = gtk_tree_model_filter_get_model(filtermodel);
GtkTreeIter iter;
+ gchar *str_data;
gboolean valid = gtk_tree_model_get_iter_first(service_model, &iter);
while(valid) {
- gchar *str_data;
gtk_tree_model_get(service_model, &iter, 0, &str_data, -1);
if(!strcmp(str_data, service)) {
- struct s_info *serviceinfo;
- gtk_tree_model_get(service_model, &iter, 4, &serviceinfo, -1);
- serviceinfo->status_id = is;
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 2, state, -1);
- switch(is) {
- case IS_UP:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#00FF00", -1);
- break;
- case IS_DOWN:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#0000FF", -1);
- break;
- case IS_FAILED:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FF0000", -1);
- break;
- case IS_STARTING:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FFFF00", -1);
- break;
- case IS_STOPPING:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#00FFFF", -1);
- break;
- case IS_WAITING:
- gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FF00FF", -1);
- break;
- }
break;
}
- g_free(str_data);
valid = gtk_tree_model_iter_next(service_model, &iter);
+ }
+
+ if(!valid) {
+ fprintf(stderr, "Service %s not found in service list!\n", service);
+
+ struct s_info *serviceinfo = malloc(sizeof(struct s_info));
+ serviceinfo->startline = NULL;
+ gtk_list_store_append (GTK_LIST_STORE(service_model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 0, service, 1, "unknown",
+ 2, NULL, 4, serviceinfo, -1);
+ serviceinfo->name = service;
+ serviceinfo->type = UNKNOWN;
+ serviceinfo->path = NULL;
+ }
- if(!valid)
- fprintf(stderr, "Service %s not found in service list!\n", service);
+ struct s_info *serviceinfo;
+ gtk_tree_model_get(service_model, &iter, 4, &serviceinfo, -1);
+ serviceinfo->status_id = is;
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 2, state, -1);
+ switch(is) {
+ case IS_UP:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#00FF00", -1);
+ break;
+ case IS_DOWN:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#0000FF", -1);
+ break;
+ case IS_FAILED:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FF0000", -1);
+ break;
+ case IS_STARTING:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FFFF00", -1);
+ break;
+ case IS_STOPPING:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#00FFFF", -1);
+ break;
+ case IS_WAITING:
+ gtk_list_store_set(GTK_LIST_STORE(service_model), &iter, 3, "#FF00FF", -1);
+ break;
}
+ g_free(str_data);
//TODO: Is there a way of not refiltering entire list every time?
gtk_tree_model_filter_refilter(filtermodel);
Modified: initng-gui/initconf/src/serviceparser.h
==============================================================================
--- initng-gui/initconf/src/serviceparser.h (original)
+++ initng-gui/initconf/src/serviceparser.h Wed Apr 5 10:25:12 2006
@@ -34,7 +34,8 @@
RUNLEVEL = 0,
SERVICE,
DAEMON,
- VIRTUAL
+ VIRTUAL,
+ UNKNOWN
};
struct s_info {
More information about the Initng-svn
mailing list