|
|
@@ -1,5 +1,5 @@
|
|
|
/*____________________________________________________________________________
|
|
|
-
|
|
|
+
|
|
|
gkrellm multiping plugin
|
|
|
|
|
|
Copyright (C) 2002 Jindrich Makovicka
|
|
|
@@ -27,8 +27,8 @@ ____________________________________________________________________________*/
|
|
|
|
|
|
#include "decal_multiping_status.xpm"
|
|
|
|
|
|
-#define CONFIG_NAME "Multiping"
|
|
|
-#define STYLE_NAME "multiping"
|
|
|
+#define CONFIG_NAME "Multiping"
|
|
|
+#define STYLE_NAME "multiping"
|
|
|
|
|
|
#define COMMAND HELPERDIR"/pinger"
|
|
|
|
|
|
@@ -52,7 +52,7 @@ static GtkWidget *dynamic_checkbutton;
|
|
|
|
|
|
static GtkTreeView *multiping_treeview;
|
|
|
static GtkTreeRowReference *row_reference;
|
|
|
-static GtkTreeSelection *selection;
|
|
|
+static GtkTreeSelection *selection;
|
|
|
|
|
|
static GkrellmPiximage *decal_status_image;
|
|
|
static GdkPixmap *status_pixmap;
|
|
|
@@ -103,13 +103,13 @@ static host_data *host_malloc()
|
|
|
static void host_free(host_data * h)
|
|
|
{
|
|
|
if (h->name_text) {
|
|
|
- gkrellm_destroy_decal(h->name_text);
|
|
|
+ gkrellm_destroy_decal(h->name_text);
|
|
|
}
|
|
|
if (h->msg_text) {
|
|
|
- gkrellm_destroy_decal(h->msg_text);
|
|
|
+ gkrellm_destroy_decal(h->msg_text);
|
|
|
}
|
|
|
if (h->decal_pix) {
|
|
|
- gkrellm_destroy_decal(h->decal_pix);
|
|
|
+ gkrellm_destroy_decal(h->decal_pix);
|
|
|
}
|
|
|
g_string_free(h->name, TRUE);
|
|
|
g_string_free(h->ip, TRUE);
|
|
|
@@ -124,7 +124,7 @@ static void host_free(host_data * h)
|
|
|
static void strip_nl(gchar *buf)
|
|
|
{
|
|
|
if (buf[strlen(buf) - 1] == '\n')
|
|
|
- buf[strlen(buf) - 1] = 0;
|
|
|
+ buf[strlen(buf) - 1] = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -134,8 +134,8 @@ static void host_read_pipe(host_data * h)
|
|
|
|
|
|
char* res = fgets(buf, 512, pinger_pipe);
|
|
|
if (res == 0) {
|
|
|
- helper_err = 1;
|
|
|
- return;
|
|
|
+ helper_err = 1;
|
|
|
+ return;
|
|
|
}
|
|
|
strip_nl(buf);
|
|
|
g_string_assign(h->percentage, buf);
|
|
|
@@ -156,10 +156,10 @@ static void host_read_pipe(host_data * h)
|
|
|
static void kill_pinger()
|
|
|
{
|
|
|
if (pinger_pipe) {
|
|
|
- kill(pinger_pid, SIGTERM);
|
|
|
- waitpid(pinger_pid, NULL, 0);
|
|
|
- fclose(pinger_pipe);
|
|
|
- pinger_pipe = NULL;
|
|
|
+ kill(pinger_pid, SIGTERM);
|
|
|
+ waitpid(pinger_pid, NULL, 0);
|
|
|
+ fclose(pinger_pipe);
|
|
|
+ pinger_pipe = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -173,37 +173,37 @@ static void launch_pipe()
|
|
|
gint mypipe[2];
|
|
|
|
|
|
for (i = 0, list = hosts; list; list = list->next, i++) {
|
|
|
- char freq[5];
|
|
|
- h = (host_data *) list->data;
|
|
|
- g_string_append(s, " ");
|
|
|
- g_string_append(s, h->ip->str);
|
|
|
- g_string_append(s, " ");
|
|
|
- sprintf(freq, "%3d", h->updatefreq);
|
|
|
- g_string_append(s, freq);
|
|
|
- g_string_append(s, " ");
|
|
|
- g_string_append(s, h->dynamic ? "1" : "0");
|
|
|
+ char freq[5];
|
|
|
+ h = (host_data *) list->data;
|
|
|
+ g_string_append(s, " ");
|
|
|
+ g_string_append(s, h->ip->str);
|
|
|
+ g_string_append(s, " ");
|
|
|
+ sprintf(freq, "%3d", h->updatefreq);
|
|
|
+ g_string_append(s, freq);
|
|
|
+ g_string_append(s, " ");
|
|
|
+ g_string_append(s, h->dynamic ? "1" : "0");
|
|
|
}
|
|
|
|
|
|
if (pipe(mypipe)) {
|
|
|
- fprintf(stderr, "Pipe failed.\n");
|
|
|
- return;
|
|
|
+ fprintf(stderr, "Pipe failed.\n");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
pid = fork();
|
|
|
if (pid == 0) {
|
|
|
- /* This is the child process. Execute the shell command. */
|
|
|
- close(mypipe[0]);
|
|
|
- dup2(mypipe[1], 1);
|
|
|
- execl("/bin/sh", "/bin/sh", "-c", s->str, NULL);
|
|
|
- _exit(EXIT_FAILURE);
|
|
|
+ /* This is the child process. Execute the shell command. */
|
|
|
+ close(mypipe[0]);
|
|
|
+ dup2(mypipe[1], 1);
|
|
|
+ execl("/bin/sh", "/bin/sh", "-c", s->str, NULL);
|
|
|
+ _exit(EXIT_FAILURE);
|
|
|
} else if (pid < 0) {
|
|
|
- /* The fork failed. Report failure. */
|
|
|
- fprintf(stderr, "failed to fork\n");
|
|
|
+ /* The fork failed. Report failure. */
|
|
|
+ fprintf(stderr, "failed to fork\n");
|
|
|
} else {
|
|
|
- /* This is the parent process. Prepare the pipe stream. */
|
|
|
- close(mypipe[1]);
|
|
|
- pinger_pipe = fdopen(mypipe[0], "r");
|
|
|
- pinger_pid = pid;
|
|
|
+ /* This is the parent process. Prepare the pipe stream. */
|
|
|
+ close(mypipe[1]);
|
|
|
+ pinger_pipe = fdopen(mypipe[0], "r");
|
|
|
+ pinger_pid = pid;
|
|
|
}
|
|
|
|
|
|
g_string_free(s, TRUE);
|
|
|
@@ -216,7 +216,7 @@ host_append_info(host_data *h, GString *str)
|
|
|
GString *s = g_string_new(NULL);
|
|
|
|
|
|
g_string_sprintf(s, "%s: %s, %s\n",
|
|
|
- h->name->str, h->percentage->str, h->msg->str);
|
|
|
+ h->name->str, h->percentage->str, h->msg->str);
|
|
|
g_string_append(str, s->str);
|
|
|
|
|
|
g_string_free(s, TRUE);
|
|
|
@@ -233,15 +233,15 @@ static void host_draw_msg(host_data * h)
|
|
|
gint n, p;
|
|
|
|
|
|
if (h->show_trip) {
|
|
|
- gkrellm_draw_decal_text(panel, h->msg_text, h->shortmsg->str, -1);
|
|
|
+ gkrellm_draw_decal_text(panel, h->msg_text, h->shortmsg->str, -1);
|
|
|
}
|
|
|
n = sscanf(h->percentage->str, "%d", &p);
|
|
|
if (n != 1 || p == 0) {
|
|
|
- gkrellm_draw_decal_pixmap(panel, h->decal_pix, 0);
|
|
|
+ gkrellm_draw_decal_pixmap(panel, h->decal_pix, 0);
|
|
|
} else if (p < 100) {
|
|
|
- gkrellm_draw_decal_pixmap(panel, h->decal_pix, 2);
|
|
|
+ gkrellm_draw_decal_pixmap(panel, h->decal_pix, 2);
|
|
|
} else {
|
|
|
- gkrellm_draw_decal_pixmap(panel, h->decal_pix, 1);
|
|
|
+ gkrellm_draw_decal_pixmap(panel, h->decal_pix, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -258,38 +258,38 @@ static GList *append_host(GList * list, gchar * name, gchar * ip, gboolean show_
|
|
|
|
|
|
static gint
|
|
|
display_host(host_data * h, GkrellmStyle * style, GkrellmTextstyle * ts,
|
|
|
- GkrellmTextstyle * ts_alt, gint y)
|
|
|
+ GkrellmTextstyle * ts_alt, gint y)
|
|
|
{
|
|
|
if (h->show_trip) {
|
|
|
- h->msg_text =
|
|
|
- gkrellm_create_decal_text(panel, "999", ts_alt, style, 0, y, 0);
|
|
|
+ h->msg_text =
|
|
|
+ gkrellm_create_decal_text(panel, "999", ts_alt, style, 0, y, 0);
|
|
|
|
|
|
- h->msg_text->x = gkrellm_chart_width() - h->msg_text->w + time_xoffset;
|
|
|
+ h->msg_text->x = gkrellm_chart_width() - h->msg_text->w + time_xoffset;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
h->decal_pix =
|
|
|
- gkrellm_create_decal_pixmap(panel, status_pixmap, status_mask, 3,
|
|
|
- style, -1, y);
|
|
|
+ gkrellm_create_decal_pixmap(panel, status_pixmap, status_mask, 3,
|
|
|
+ style, -1, y);
|
|
|
h->name_text =
|
|
|
- gkrellm_create_decal_text(panel, "Ay", ts, style,
|
|
|
- h->decal_pix->x+h->decal_pix->w+hspacing, y, -1);
|
|
|
+ gkrellm_create_decal_text(panel, "Ay", ts, style,
|
|
|
+ h->decal_pix->x+h->decal_pix->w+hspacing, y, -1);
|
|
|
|
|
|
if (h->name_text->h < h->decal_pix->h) {
|
|
|
- h->name_text->y += (h->decal_pix->h-h->name_text->h)/2;
|
|
|
- if (h->show_trip) {
|
|
|
- h->msg_text->y = h->name_text->y;
|
|
|
- }
|
|
|
- return h->decal_pix->y + h->decal_pix->h + vspacing;
|
|
|
+ h->name_text->y += (h->decal_pix->h-h->name_text->h)/2;
|
|
|
+ if (h->show_trip) {
|
|
|
+ h->msg_text->y = h->name_text->y;
|
|
|
+ }
|
|
|
+ return h->decal_pix->y + h->decal_pix->h + vspacing;
|
|
|
} else {
|
|
|
- h->decal_pix->y += (h->name_text->h-h->decal_pix->h)/2;
|
|
|
- return h->name_text->y + h->name_text->h + vspacing;
|
|
|
+ h->decal_pix->y += (h->name_text->h-h->decal_pix->h)/2;
|
|
|
+ return h->name_text->y + h->name_text->h + vspacing;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static gint panel_click_event(GtkWidget * widget, GdkEventButton * ev)
|
|
|
{
|
|
|
if (ev->button == 3)
|
|
|
- gkrellm_open_config_window(monitor);
|
|
|
+ gkrellm_open_config_window(monitor);
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -297,9 +297,9 @@ static gint panel_click_event(GtkWidget * widget, GdkEventButton * ev)
|
|
|
static gint panel_expose_event(GtkWidget * widget, GdkEventExpose * ev)
|
|
|
{
|
|
|
gdk_draw_pixmap(widget->window,
|
|
|
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
|
|
|
- panel->pixmap, ev->area.x, ev->area.y, ev->area.x,
|
|
|
- ev->area.y, ev->area.width, ev->area.height);
|
|
|
+ widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
|
|
|
+ panel->pixmap, ev->area.x, ev->area.y, ev->area.x,
|
|
|
+ ev->area.y, ev->area.width, ev->area.height);
|
|
|
return FALSE;
|
|
|
}
|
|
|
|
|
|
@@ -318,18 +318,18 @@ static void update_plugin()
|
|
|
ret = select(fileno(pinger_pipe) + 1, &fds, 0, 0, &tv);
|
|
|
|
|
|
if (ret) {
|
|
|
- g_list_foreach(hosts, (GFunc) host_read_pipe, NULL);
|
|
|
- g_list_foreach(hosts, (GFunc) host_draw_msg, NULL);
|
|
|
- gkrellm_draw_panel_layers(panel);
|
|
|
+ g_list_foreach(hosts, (GFunc) host_read_pipe, NULL);
|
|
|
+ g_list_foreach(hosts, (GFunc) host_draw_msg, NULL);
|
|
|
+ gkrellm_draw_panel_layers(panel);
|
|
|
}
|
|
|
|
|
|
if (helper_err) {
|
|
|
- kill_pinger();
|
|
|
- launch_pipe();
|
|
|
- helper_err = 0;
|
|
|
+ kill_pinger();
|
|
|
+ launch_pipe();
|
|
|
+ helper_err = 0;
|
|
|
}
|
|
|
-
|
|
|
- /*
|
|
|
+
|
|
|
+ /*
|
|
|
if (GK.minute_tick && tooltip) {
|
|
|
// if (tooltip->tip_window == NULL || !GTK_WIDGET_VISIBLE(tooltip->tip_window)) {
|
|
|
g_list_foreach(hosts, (GFunc)host_append_info, str);
|
|
|
@@ -353,7 +353,7 @@ setup_display(gboolean first_create)
|
|
|
host_data *h;
|
|
|
|
|
|
if (first_create) {
|
|
|
- panel = gkrellm_panel_new0();
|
|
|
+ panel = gkrellm_panel_new0();
|
|
|
}
|
|
|
|
|
|
style = gkrellm_panel_style(style_id);
|
|
|
@@ -362,21 +362,21 @@ setup_display(gboolean first_create)
|
|
|
|
|
|
y = 3;
|
|
|
// y = style->top_margin;
|
|
|
-
|
|
|
+
|
|
|
for (i = 0, list = hosts; list; list = list->next, i++) {
|
|
|
- h = (host_data *) list->data;
|
|
|
- y = display_host(h, style, ts, ts_alt, y);
|
|
|
+ h = (host_data *) list->data;
|
|
|
+ y = display_host(h, style, ts, ts_alt, y);
|
|
|
}
|
|
|
|
|
|
gkrellm_panel_configure(panel, NULL, style);
|
|
|
gkrellm_panel_create(plugin_vbox, monitor, panel);
|
|
|
|
|
|
if (first_create) {
|
|
|
- g_signal_connect(GTK_OBJECT(panel->drawing_area), "expose_event",
|
|
|
- (GtkSignalFunc) panel_expose_event, NULL);
|
|
|
- g_signal_connect(GTK_OBJECT(panel->drawing_area),
|
|
|
- "button_release_event",
|
|
|
- (GtkSignalFunc) panel_click_event, NULL);
|
|
|
+ g_signal_connect(GTK_OBJECT(panel->drawing_area), "expose_event",
|
|
|
+ (GtkSignalFunc) panel_expose_event, NULL);
|
|
|
+ g_signal_connect(GTK_OBJECT(panel->drawing_area),
|
|
|
+ "button_release_event",
|
|
|
+ (GtkSignalFunc) panel_click_event, NULL);
|
|
|
}
|
|
|
|
|
|
g_list_foreach(hosts, (GFunc) host_draw_name, NULL);
|
|
|
@@ -391,17 +391,17 @@ create_plugin(GtkWidget * vbox, gint first_create)
|
|
|
plugin_vbox = vbox;
|
|
|
|
|
|
gkrellm_load_piximage("decal_multiping_status", decal_multiping_status_xpm,
|
|
|
- &decal_status_image, STYLE_NAME);
|
|
|
+ &decal_status_image, STYLE_NAME);
|
|
|
|
|
|
gkrellm_scale_piximage_to_pixmap(decal_status_image, &status_pixmap,
|
|
|
- &status_mask, 0, 0);
|
|
|
+ &status_mask, 0, 0);
|
|
|
|
|
|
if (!gkrellm_get_gkrellmrc_integer("multiping_vspacing", &vspacing))
|
|
|
- vspacing = 2;
|
|
|
+ vspacing = 2;
|
|
|
if (!gkrellm_get_gkrellmrc_integer("multiping_hspacing", &hspacing))
|
|
|
- hspacing = 2;
|
|
|
+ hspacing = 2;
|
|
|
if (!gkrellm_get_gkrellmrc_integer("multiping_time_xoffset", &time_xoffset))
|
|
|
- time_xoffset = 0;
|
|
|
+ time_xoffset = 0;
|
|
|
|
|
|
kill_pinger();
|
|
|
launch_pipe();
|
|
|
@@ -414,9 +414,9 @@ change_row_reference(GtkTreeModel *model, GtkTreePath *path)
|
|
|
{
|
|
|
gtk_tree_row_reference_free(row_reference);
|
|
|
if (model && path)
|
|
|
- row_reference = gtk_tree_row_reference_new(model, path);
|
|
|
+ row_reference = gtk_tree_row_reference_new(model, path);
|
|
|
else
|
|
|
- row_reference = NULL;
|
|
|
+ row_reference = NULL;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -444,12 +444,12 @@ host_new_from_model(GtkTreeModel *model, GtkTreeIter *iter)
|
|
|
|
|
|
h = host_malloc();
|
|
|
gtk_tree_model_get(model, iter,
|
|
|
- LABEL_COLUMN, &label,
|
|
|
- HOST_COLUMN, &host,
|
|
|
- TRIP_COLUMN, &h->show_trip,
|
|
|
- DYNAMIC_COLUMN, &h->dynamic,
|
|
|
- INTERVAL_COLUMN, &h->updatefreq,
|
|
|
- -1);
|
|
|
+ LABEL_COLUMN, &label,
|
|
|
+ HOST_COLUMN, &host,
|
|
|
+ TRIP_COLUMN, &h->show_trip,
|
|
|
+ DYNAMIC_COLUMN, &h->dynamic,
|
|
|
+ INTERVAL_COLUMN, &h->updatefreq,
|
|
|
+ -1);
|
|
|
|
|
|
h->name = g_string_new(label);
|
|
|
h->ip = g_string_new(host);
|
|
|
@@ -462,13 +462,13 @@ static void
|
|
|
set_list_store_model_data(GtkListStore *store, GtkTreeIter *iter, host_data *h)
|
|
|
{
|
|
|
gtk_list_store_set(store, iter,
|
|
|
- LABEL_COLUMN, h->name->str,
|
|
|
- HOST_COLUMN, h->ip->str,
|
|
|
- TRIP_COLUMN, h->show_trip,
|
|
|
- DYNAMIC_COLUMN, h->dynamic,
|
|
|
- INTERVAL_COLUMN, h->updatefreq,
|
|
|
- DUMMY_COLUMN, "",
|
|
|
- -1);
|
|
|
+ LABEL_COLUMN, h->name->str,
|
|
|
+ HOST_COLUMN, h->ip->str,
|
|
|
+ TRIP_COLUMN, h->show_trip,
|
|
|
+ DYNAMIC_COLUMN, h->dynamic,
|
|
|
+ INTERVAL_COLUMN, h->updatefreq,
|
|
|
+ DUMMY_COLUMN, "",
|
|
|
+ -1);
|
|
|
}
|
|
|
|
|
|
static GtkTreeModel *
|
|
|
@@ -480,12 +480,12 @@ create_model(void)
|
|
|
host_data *h;
|
|
|
|
|
|
store = gtk_list_store_new(N_COLUMNS,
|
|
|
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
|
|
|
- G_TYPE_INT, G_TYPE_STRING);
|
|
|
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
|
|
|
+ G_TYPE_INT, G_TYPE_STRING);
|
|
|
for (list = hosts; list; list = list->next) {
|
|
|
- h = (host_data *) list->data;
|
|
|
- gtk_list_store_append(store, &iter);
|
|
|
- set_list_store_model_data(store, &iter, h);
|
|
|
+ h = (host_data *) list->data;
|
|
|
+ gtk_list_store_append(store, &iter);
|
|
|
+ set_list_store_model_data(store, &iter, h);
|
|
|
}
|
|
|
return GTK_TREE_MODEL(store);
|
|
|
}
|
|
|
@@ -493,7 +493,7 @@ create_model(void)
|
|
|
|
|
|
static void
|
|
|
cb_selected(GtkWidget * clist, gint row, gint column,
|
|
|
- GdkEventButton * bevent, gpointer data)
|
|
|
+ GdkEventButton * bevent, gpointer data)
|
|
|
{
|
|
|
GtkTreeIter iter;
|
|
|
GtkTreeModel *model;
|
|
|
@@ -502,8 +502,8 @@ cb_selected(GtkWidget * clist, gint row, gint column,
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected(selection, &model, &iter))
|
|
|
{
|
|
|
- reset_entries();
|
|
|
- return;
|
|
|
+ reset_entries();
|
|
|
+ return;
|
|
|
}
|
|
|
path = gtk_tree_model_get_path(model, &iter);
|
|
|
change_row_reference(model, path);
|
|
|
@@ -518,7 +518,7 @@ cb_selected(GtkWidget * clist, gint row, gint column,
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(updatefreq_spin), h->updatefreq);
|
|
|
|
|
|
host_free(h);
|
|
|
-
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -541,8 +541,8 @@ cb_enter(GtkWidget * widget, gpointer data)
|
|
|
buf[2] = gkrellm_gtk_entry_get_text(&updatefreq_spin);
|
|
|
|
|
|
if ((strlen(buf[0]) == 0) || (strlen(buf[1]) == 0)) {
|
|
|
- host_free(h);
|
|
|
- return;
|
|
|
+ host_free(h);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
h->name = g_string_new(buf[0]);
|
|
|
@@ -552,12 +552,12 @@ cb_enter(GtkWidget * widget, gpointer data)
|
|
|
model = gtk_tree_view_get_model(multiping_treeview);
|
|
|
if (row_reference)
|
|
|
{
|
|
|
- path = gtk_tree_row_reference_get_path(row_reference);
|
|
|
- gtk_tree_model_get_iter(model, &iter, path);
|
|
|
+ path = gtk_tree_row_reference_get_path(row_reference);
|
|
|
+ gtk_tree_model_get_iter(model, &iter, path);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
|
|
+ gtk_list_store_append(GTK_LIST_STORE(model), &iter);
|
|
|
}
|
|
|
|
|
|
set_list_store_model_data(GTK_LIST_STORE(model), &iter, h);
|
|
|
@@ -571,12 +571,12 @@ cb_enter(GtkWidget * widget, gpointer data)
|
|
|
static void
|
|
|
cb_delete(GtkWidget * widget, gpointer data)
|
|
|
{
|
|
|
- GtkTreeModel *model;
|
|
|
- GtkTreePath *path;
|
|
|
- GtkTreeIter iter;
|
|
|
+ GtkTreeModel *model;
|
|
|
+ GtkTreePath *path;
|
|
|
+ GtkTreeIter iter;
|
|
|
|
|
|
if (!row_reference)
|
|
|
- return;
|
|
|
+ return;
|
|
|
model = gtk_tree_view_get_model(multiping_treeview);
|
|
|
path = gtk_tree_row_reference_get_path(row_reference);
|
|
|
gtk_tree_model_get_iter(model, &iter, path);
|
|
|
@@ -663,18 +663,18 @@ static void create_plugin_config(GtkWidget * tab_vbox)
|
|
|
|
|
|
button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
|
|
|
g_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
- (GtkSignalFunc) cb_delete, NULL);
|
|
|
+ (GtkSignalFunc) cb_delete, NULL);
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
|
|
|
|
|
|
button = gtk_button_new_from_stock(GTK_STOCK_ADD);;
|
|
|
g_signal_connect(GTK_OBJECT(button), "clicked",
|
|
|
- (GtkSignalFunc) cb_enter, NULL);
|
|
|
+ (GtkSignalFunc) cb_enter, NULL);
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
|
|
|
|
|
|
scrolled = gtk_scrolled_window_new(NULL, NULL);
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
|
|
|
- GTK_POLICY_AUTOMATIC,
|
|
|
- GTK_POLICY_AUTOMATIC);
|
|
|
+ GTK_POLICY_AUTOMATIC,
|
|
|
+ GTK_POLICY_AUTOMATIC);
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
|
|
|
|
|
|
/* Treeview */
|
|
|
@@ -685,42 +685,42 @@ static void create_plugin_config(GtkWidget * tab_vbox)
|
|
|
gtk_tree_view_set_rules_hint(multiping_treeview, TRUE);
|
|
|
gtk_tree_view_set_reorderable(multiping_treeview, TRUE);
|
|
|
g_signal_connect(G_OBJECT(multiping_treeview), "drag_end",
|
|
|
- G_CALLBACK(cb_drag_end), NULL);
|
|
|
+ G_CALLBACK(cb_drag_end), NULL);
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, "Label",
|
|
|
- renderer,
|
|
|
- "text", LABEL_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "text", LABEL_COLUMN, NULL);
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, "Hostname / IP Address",
|
|
|
- renderer,
|
|
|
- "text", HOST_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "text", HOST_COLUMN, NULL);
|
|
|
renderer = gtk_cell_renderer_toggle_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, "Trip",
|
|
|
- renderer,
|
|
|
- "active", TRIP_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "active", TRIP_COLUMN, NULL);
|
|
|
|
|
|
renderer = gtk_cell_renderer_toggle_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, "Dynamic",
|
|
|
- renderer,
|
|
|
- "active", DYNAMIC_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "active", DYNAMIC_COLUMN, NULL);
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, "Ping int.",
|
|
|
- renderer,
|
|
|
- "text", INTERVAL_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "text", INTERVAL_COLUMN, NULL);
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
gtk_tree_view_insert_column_with_attributes(multiping_treeview, -1, " ",
|
|
|
- renderer,
|
|
|
- "text", DUMMY_COLUMN, NULL);
|
|
|
+ renderer,
|
|
|
+ "text", DUMMY_COLUMN, NULL);
|
|
|
|
|
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(multiping_treeview));
|
|
|
selection = gtk_tree_view_get_selection(multiping_treeview);
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
|
|
g_signal_connect(G_OBJECT(selection), "changed",
|
|
|
- G_CALLBACK(cb_selected), NULL);
|
|
|
+ G_CALLBACK(cb_selected), NULL);
|
|
|
|
|
|
/* About tab */
|
|
|
info_label = gtk_label_new(plugin_about_text);
|
|
|
@@ -731,35 +731,35 @@ static void create_plugin_config(GtkWidget * tab_vbox)
|
|
|
static void apply_plugin_config()
|
|
|
{
|
|
|
if (list_modified) {
|
|
|
- GList *new_hosts;
|
|
|
- GtkTreeModel *model;
|
|
|
- GtkTreeIter iter;
|
|
|
-
|
|
|
- kill_pinger();
|
|
|
-
|
|
|
- new_hosts = NULL;
|
|
|
-
|
|
|
- model = gtk_tree_view_get_model(multiping_treeview);
|
|
|
- if (gtk_tree_model_get_iter_first(model, &iter)) {
|
|
|
- do {
|
|
|
- host_data *h;
|
|
|
- h = host_new_from_model(model, &iter);
|
|
|
- new_hosts = g_list_append(new_hosts, h);
|
|
|
- }
|
|
|
- while (gtk_tree_model_iter_next(model, &iter));
|
|
|
- }
|
|
|
-
|
|
|
- g_list_foreach(hosts, (GFunc) host_free, NULL);
|
|
|
- g_list_free(hosts);
|
|
|
- gkrellm_panel_destroy(panel);
|
|
|
- panel = gkrellm_panel_new0();
|
|
|
-
|
|
|
- hosts = new_hosts;
|
|
|
- setup_display(1);
|
|
|
-
|
|
|
- list_modified = FALSE;
|
|
|
-
|
|
|
- launch_pipe();
|
|
|
+ GList *new_hosts;
|
|
|
+ GtkTreeModel *model;
|
|
|
+ GtkTreeIter iter;
|
|
|
+
|
|
|
+ kill_pinger();
|
|
|
+
|
|
|
+ new_hosts = NULL;
|
|
|
+
|
|
|
+ model = gtk_tree_view_get_model(multiping_treeview);
|
|
|
+ if (gtk_tree_model_get_iter_first(model, &iter)) {
|
|
|
+ do {
|
|
|
+ host_data *h;
|
|
|
+ h = host_new_from_model(model, &iter);
|
|
|
+ new_hosts = g_list_append(new_hosts, h);
|
|
|
+ }
|
|
|
+ while (gtk_tree_model_iter_next(model, &iter));
|
|
|
+ }
|
|
|
+
|
|
|
+ g_list_foreach(hosts, (GFunc) host_free, NULL);
|
|
|
+ g_list_free(hosts);
|
|
|
+ gkrellm_panel_destroy(panel);
|
|
|
+ panel = gkrellm_panel_new0();
|
|
|
+
|
|
|
+ hosts = new_hosts;
|
|
|
+ setup_display(1);
|
|
|
+
|
|
|
+ list_modified = FALSE;
|
|
|
+
|
|
|
+ launch_pipe();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -771,17 +771,17 @@ static void save_plugin_config(FILE * f)
|
|
|
host_data *h;
|
|
|
|
|
|
for (list = hosts; list; list = list->next) {
|
|
|
- h = (host_data *) list->data;
|
|
|
+ h = (host_data *) list->data;
|
|
|
|
|
|
- //when saving, we convert spaces in labels to underscores
|
|
|
- label = g_strdup(h->name->str);
|
|
|
- for (pt = label; *pt; pt++)
|
|
|
- if (*pt == ' ')
|
|
|
- *pt = '_';
|
|
|
+ //when saving, we convert spaces in labels to underscores
|
|
|
+ label = g_strdup(h->name->str);
|
|
|
+ for (pt = label; *pt; pt++)
|
|
|
+ if (*pt == ' ')
|
|
|
+ *pt = '_';
|
|
|
|
|
|
- fprintf(f, "multiping host %s %s %d %d %d\n", label, h->ip->str, h->show_trip,
|
|
|
- h->updatefreq, h->dynamic);
|
|
|
- g_free(label);
|
|
|
+ fprintf(f, "multiping host %s %s %d %d %d\n", label, h->ip->str, h->show_trip,
|
|
|
+ h->updatefreq, h->dynamic);
|
|
|
+ g_free(label);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -800,51 +800,51 @@ static void load_plugin_config(gchar * arg)
|
|
|
n = sscanf(arg, "%s %[^\n]", plugin_config, item);
|
|
|
|
|
|
if (n == 2) {
|
|
|
- if (!strcmp(plugin_config, "host")) {
|
|
|
- if (delete_list) {
|
|
|
- g_list_foreach(hosts, (GFunc) host_free, NULL);
|
|
|
- g_list_free(hosts);
|
|
|
- delete_list = FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- label[0] = '\0';
|
|
|
- ip[0] = '\0';
|
|
|
- show_trip = TRUE;
|
|
|
- dynamic = FALSE;
|
|
|
- sscanf(item, "%25s %75s %d %d %d", label, ip, &show_trip, &updatefreq, &dynamic);
|
|
|
-
|
|
|
- //when loading, we convert underscores in labels to spaces
|
|
|
- for (pt = label; *pt; pt++)
|
|
|
- if (*pt == '_')
|
|
|
- *pt = ' ';
|
|
|
-
|
|
|
- hosts = append_host(hosts, label, ip, show_trip, dynamic, updatefreq);
|
|
|
- }
|
|
|
+ if (!strcmp(plugin_config, "host")) {
|
|
|
+ if (delete_list) {
|
|
|
+ g_list_foreach(hosts, (GFunc) host_free, NULL);
|
|
|
+ g_list_free(hosts);
|
|
|
+ delete_list = FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ label[0] = '\0';
|
|
|
+ ip[0] = '\0';
|
|
|
+ show_trip = TRUE;
|
|
|
+ dynamic = FALSE;
|
|
|
+ sscanf(item, "%25s %75s %d %d %d", label, ip, &show_trip, &updatefreq, &dynamic);
|
|
|
+
|
|
|
+ //when loading, we convert underscores in labels to spaces
|
|
|
+ for (pt = label; *pt; pt++)
|
|
|
+ if (*pt == '_')
|
|
|
+ *pt = ' ';
|
|
|
+
|
|
|
+ hosts = append_host(hosts, label, ip, show_trip, dynamic, updatefreq);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* The monitor structure tells GKrellM how to call the plugin routines.
|
|
|
*/
|
|
|
static GkrellmMonitor plugin_mon = {
|
|
|
- CONFIG_NAME, /* Name, for config tab. */
|
|
|
- 0, /* Id, 0 if a plugin */
|
|
|
- create_plugin, /* The create function */
|
|
|
- update_plugin, /* The update function */
|
|
|
- create_plugin_config, /* The config tab create function */
|
|
|
- apply_plugin_config, /* Apply the config function */
|
|
|
+ CONFIG_NAME, /* Name, for config tab. */
|
|
|
+ 0, /* Id, 0 if a plugin */
|
|
|
+ create_plugin, /* The create function */
|
|
|
+ update_plugin, /* The update function */
|
|
|
+ create_plugin_config, /* The config tab create function */
|
|
|
+ apply_plugin_config, /* Apply the config function */
|
|
|
|
|
|
- save_plugin_config, /* Save user config */
|
|
|
- load_plugin_config, /* Load user config */
|
|
|
- "multiping", /* config keyword */
|
|
|
+ save_plugin_config, /* Save user config */
|
|
|
+ load_plugin_config, /* Load user config */
|
|
|
+ "multiping", /* config keyword */
|
|
|
|
|
|
- NULL, /* Undefined 2 */
|
|
|
- NULL, /* Undefined 1 */
|
|
|
- NULL, /* private */
|
|
|
+ NULL, /* Undefined 2 */
|
|
|
+ NULL, /* Undefined 1 */
|
|
|
+ NULL, /* private */
|
|
|
|
|
|
- MON_MAIL, /* Insert plugin before this monitor */
|
|
|
+ MON_MAIL, /* Insert plugin before this monitor */
|
|
|
|
|
|
- NULL, /* Handle if a plugin, filled in by GKrellM */
|
|
|
- NULL /* path if a plugin, filled in by GKrellM */
|
|
|
+ NULL, /* Handle if a plugin, filled in by GKrellM */
|
|
|
+ NULL /* path if a plugin, filled in by GKrellM */
|
|
|
};
|
|
|
|
|
|
GkrellmMonitor *gkrellm_init_plugin()
|