Mailing List Archive

NessusClient/nessus/prefs_dialog readonly.h, NONE, 1.1 readonly.c, NONE, 1.1 prefs_plugins_tree.h, 1.4, 1.5 prefs_plugins_tree.c, 1.5, 1.6 prefs_plugins.h, 1.2, 1.3 prefs_plugins.c, 1.7, 1.8 prefs_dialog_user.h, 1.2, 1.3 prefs_dialog_user.c, 1.2, 1.3 pref
Update of /usr/local/cvs/NessusClient/nessus/prefs_dialog
In directory raccoon.nessus.org:/tmp/cvs-serv60771/nessus/prefs_dialog

Modified Files:
prefs_plugins_tree.h prefs_plugins_tree.c prefs_plugins.h
prefs_plugins.c prefs_dialog_user.h prefs_dialog_user.c
prefs_dialog_scan_opt.h prefs_dialog_scan_opt.c
prefs_dialog_plugins_prefs.h prefs_dialog_plugins_prefs.c
prefs_context.c listnotebook.c
Added Files:
readonly.h readonly.c
Log Message:
GUI part of the report plugin cache feature. This is a bit tricky as we
have to make sure that the user can see all the plugin information but
not modify it. So we have to make may parts of the options notebook
page sensitive but not all.


--- NEW FILE: readonly.h ---
/* $Id: readonly.h,v 1.1 2006/04/25 15:36:09 bh Exp $
*
* Copyright (C) 2006 by Intevation GmbH
* Author(s):
* Bernhard Herzog <bh@intevation.de> (2006)
*
* This program is free software under the GNU GPL (>=v2)
* Read the file COPYING coming with the software for details.
*
* In addition, as a special exception, Intevation GmbH gives
* permission to link the code of this program with the OpenSSL
* library (or with modified versions of OpenSSL that use the same
* license as OpenSSL), and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
* respects for all of the code used other than OpenSSL. If you
* modify this file, you may extend this exception to your version
* of the file, but you are not obligated to do so. If you do not
* wish to do so, delete this exception statement from your version.
*/

#ifndef READONLY_H__
#define READONLY_H__

void read_only_set_read_only(GtkWidget *, gboolean);
void read_only_set_recurse(GtkWidget *);
void read_only_set_active(GtkWidget *);


#endif /* READONLY_H__ */

--- NEW FILE: readonly.c ---
/* $Id: readonly.c,v 1.1 2006/04/25 15:36:09 bh Exp $
*
* Copyright (C) 2006 by Intevation GmbH
* Author(s):
* Bernhard Herzog <bh@intevation.de> (2006)
*
* This program is free software under the GNU GPL (>=v2)
* Read the file COPYING coming with the software for details.
*
* In addition, as a special exception, Intevation GmbH gives
* permission to link the code of this program with the OpenSSL
* library (or with modified versions of OpenSSL that use the same
* license as OpenSSL), and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
* respects for all of the code used other than OpenSSL. If you
* modify this file, you may extend this exception to your version
* of the file, but you are not obligated to do so. If you do not
* wish to do so, delete this exception statement from your version.
*/

/* Implement a mechanism to make a container widget "readonly". This is
* different from the container being insensitive in that some of it's
* children may remain sensitive. In NessusClient this is used to let
* the user browse e.g. the plugin information of a report where the
* users need to interact with a tree view but should no be able to
* change the information shown.
*/

#include <gtk/gtk.h>
#include "readonly.h"

static void
set_read_only_recursively(GtkWidget *widget, gpointer data)
{
if (g_object_get_data(G_OBJECT(widget), "read-only-active"))
{
gtk_widget_set_sensitive(widget, TRUE);
}
else if (GTK_IS_CONTAINER(widget)
&& g_object_get_data(G_OBJECT(widget), "read-only-recurse"))
{
gtk_container_foreach(GTK_CONTAINER(widget), set_read_only_recursively,
data);
}
else
{
gtk_widget_set_sensitive(widget, !GPOINTER_TO_INT(data));
}
}

void
read_only_set_read_only(GtkWidget *widget, gboolean readonly)
{
set_read_only_recursively(widget, GINT_TO_POINTER(readonly));
}

void
read_only_set_recurse(GtkWidget *widget)
{
g_object_set_data(G_OBJECT(widget), "read-only-recurse",
GINT_TO_POINTER(TRUE));
}

void
read_only_set_active(GtkWidget*widget)
{
g_object_set_data(G_OBJECT(widget), "read-only-active",
GINT_TO_POINTER(TRUE));
}

Index: prefs_plugins_tree.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_plugins_tree.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- prefs_plugins_tree.h 9 Feb 2006 00:28:16 -0000 1.4
+++ prefs_plugins_tree.h 25 Apr 2006 15:36:10 -0000 1.5
@@ -34,6 +34,7 @@
gboolean);
void prefs_plugin_tree_enable_all(GtkTreeView*, int);
void prefs_plugin_tree_statistics(GtkTreeView*, int*, int*);
+void prefs_plugin_tree_read_only(GtkTreeView*, gboolean);

#endif /* _NESSUSC_PREFS_PLUGINS_TREE_H */


Index: prefs_plugins_tree.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_plugins_tree.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- prefs_plugins_tree.c 9 Feb 2006 00:28:16 -0000 1.5
+++ prefs_plugins_tree.c 25 Apr 2006 15:36:10 -0000 1.6
@@ -372,6 +372,7 @@
{
struct nessus_plugin *plugin;
gboolean is_active = FALSE;
+ GObject *tree_view = G_OBJECT(data);

if (gtk_tree_model_iter_has_child(model, iter))
{
@@ -384,6 +385,11 @@
}

g_object_set(G_OBJECT(cell), "active", is_active, NULL);
+
+ /* the cell is activatable if the tree is not in read-only mode */
+ g_object_set(G_OBJECT(cell), "activatable",
+ (gboolean)!GPOINTER_TO_INT(g_object_get_data(tree_view, "read-only")),
+ NULL);
}


@@ -451,7 +457,7 @@
column = gtk_tree_view_column_new_with_attributes(_("Active"), renderer,
NULL);
gtk_tree_view_column_set_cell_data_func(column, renderer, active_data_func,
- NULL, NULL);
+ tree, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
g_object_set_data(G_OBJECT(column), "colnum", GINT_TO_POINTER(2));

@@ -661,5 +667,14 @@
}
}

+/* Make the tree "read only", meaning that the user cannot change the
+ * "active" tflag.
+ */
+void
+prefs_plugin_tree_read_only(GtkTreeView* tree_view, gboolean readonly)
+{
+ g_object_set_data(G_OBJECT(tree_view), "read-only",
+ GINT_TO_POINTER(readonly));
+}

#endif /* USE_GTK */

Index: prefs_plugins.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_plugins.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_plugins.h 9 Feb 2006 00:28:16 -0000 1.2
+++ prefs_plugins.h 25 Apr 2006 15:36:10 -0000 1.3
@@ -33,4 +33,5 @@

struct arglist *prefs_dialog_plugins(struct context *);
void fill_plugins_family(struct context *, struct arglist *);
+void prefs_plugins_read_only(struct arglist *, gboolean);
#endif

Index: prefs_plugins.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_plugins.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- prefs_plugins.c 9 Feb 2006 00:28:16 -0000 1.7
+++ prefs_plugins.c 25 Apr 2006 15:36:10 -0000 1.8
@@ -42,6 +42,7 @@
#include "filter.h"
#include "prefs_plugins.h"
#include "prefs_plugins_tree.h"
+#include "readonly.h"



@@ -238,14 +239,17 @@
frame = gtk_frame_new(_("Plugin selection"));
gtk_container_border_width(GTK_CONTAINER(frame), 10);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+ read_only_set_recurse(frame);

w_box = gtk_vbox_new(TRUE, 5);
gtk_container_border_width(GTK_CONTAINER(w_box), 5);
gtk_container_add(GTK_CONTAINER(frame), w_box);
gtk_box_set_homogeneous(GTK_BOX(w_box), FALSE);
+ read_only_set_recurse(w_box);

/* tree view of the plugins */
tree_window = gtk_scrolled_window_new(NULL, NULL);
+ read_only_set_active(tree_window);
gtk_container_border_width(GTK_CONTAINER(tree_window), 10);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tree_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -256,6 +260,7 @@
gtk_container_add(GTK_CONTAINER(tree_window), tree);
gtk_widget_show(tree);
gtk_widget_show(tree_window);
+ arg_add_value(ctrls, "PLUGIN_TREE", ARG_PTR, -1, tree);

/* Label showing some statistics */
label = gtk_label_new(_("No plugins"));
@@ -300,6 +305,7 @@
hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(w_box), hbox, FALSE, FALSE, 0);
gtk_widget_show(hbox);
+ read_only_set_active(hbox);

button = gtk_button_new_with_label(_("Expand all"));
gtk_signal_connect(GTK_OBJECT(button),
@@ -345,6 +351,17 @@
return (ctrls);
}

+/* make the plugins widgets "read only" so that the user can browse the
+ * plugins tree but cannot make modifications.
+ */
+void
+prefs_plugins_read_only(struct arglist * ctrls, gboolean readonly)
+{
+ read_only_set_read_only(GTK_WIDGET(arg_get_value(ctrls, "FRAME")),
+ readonly);
+ prefs_plugin_tree_read_only(GTK_TREE_VIEW(arg_get_value(ctrls,"PLUGIN_TREE")),
+ readonly);
+}

void
fill_plugins_family(context, ctrls)

Index: prefs_dialog_user.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_user.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_dialog_user.h 9 Feb 2006 00:28:16 -0000 1.2
+++ prefs_dialog_user.h 25 Apr 2006 15:36:10 -0000 1.3
@@ -31,5 +31,6 @@

void fill_rules_list(struct context *, struct arglist *);
struct arglist *prefs_dialog_user();
+void prefs_dialog_user_read_only(struct arglist *, gboolean);

#endif

Index: prefs_dialog_user.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_user.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_dialog_user.c 9 Feb 2006 00:28:16 -0000 1.2
+++ prefs_dialog_user.c 25 Apr 2006 15:36:10 -0000 1.3
@@ -35,6 +35,7 @@

#ifdef USE_GTK
#include <gtk/gtk.h>
+#include "readonly.h"

/*
* Reset the rules tree to the three default groups
@@ -279,9 +280,11 @@
gtk_container_border_width(GTK_CONTAINER(frame), 10);
gtk_widget_show(frame);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+ read_only_set_recurse(frame);

/* the overall vbox that will contain all widgets */
vbox = gtk_vbox_new(FALSE, 4);
+ read_only_set_recurse(vbox);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);

@@ -329,6 +332,7 @@

/* The scrolled window where to have the treelist */
scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
+ read_only_set_active(scrolledwindow);
gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 5);
gtk_widget_show(scrolledwindow);

@@ -368,4 +372,12 @@

return(ctrls);
}
+
+void
+prefs_dialog_user_read_only(struct arglist * ctrls, gboolean readonly)
+{
+ read_only_set_read_only(GTK_WIDGET(arg_get_value(ctrls, "FRAME")),
+ readonly);
+}
+
#endif

Index: prefs_dialog_scan_opt.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_scan_opt.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_dialog_scan_opt.h 9 Feb 2006 00:28:16 -0000 1.2
+++ prefs_dialog_scan_opt.h 25 Apr 2006 15:36:10 -0000 1.3
@@ -33,4 +33,5 @@

struct arglist *prefs_dialog_scan_opt(struct context *);
void fill_scanner_list(struct context *, struct arglist *);
+void prefs_dialog_scan_opt_readonly(struct arglist *, gboolean);
#endif

Index: prefs_dialog_scan_opt.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_scan_opt.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- prefs_dialog_scan_opt.c 9 Feb 2006 00:28:15 -0000 1.2
+++ prefs_dialog_scan_opt.c 25 Apr 2006 15:36:10 -0000 1.3
@@ -36,6 +36,7 @@
#include "../plugin_infos.h"
#include "../error_dialog.h"
#include "prefs_dialog_scan_opt.h"
+#include "readonly.h"
#include "globals.h"

#include "../nessus_i18n.h"
@@ -65,11 +66,13 @@
frame = gtk_frame_new(_("General scan options"));
gtk_container_border_width(GTK_CONTAINER(frame), 10);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+ read_only_set_recurse(frame);

gtk_widget_show(frame);


box = gtk_vbox_new(FALSE, 5);
+ read_only_set_recurse(box);

gtk_container_add(GTK_CONTAINER(frame), box);
gtk_container_border_width(GTK_CONTAINER(box), 10);
@@ -165,6 +168,7 @@
gtk_widget_show(use_mac_addr);

scanners_window = gtk_scrolled_window_new(NULL,NULL);
+ read_only_set_recurse(scanners_window);
gtk_container_border_width(GTK_CONTAINER(scanners_window), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scanners_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -276,4 +280,12 @@
scanner = gtk_object_get_data(list_item,"list_item_data");
plugin_info_window_setup(Context->scanners, scanner);
}
+
+void
+prefs_dialog_scan_opt_readonly(struct arglist * ctrls, gboolean readonly)
+{
+ read_only_set_read_only(GTK_WIDGET(arg_get_value(ctrls, "FRAME")),
+ readonly);
+}
+
#endif

Index: prefs_dialog_plugins_prefs.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_plugins_prefs.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- prefs_dialog_plugins_prefs.h 10 Sep 2005 17:36:45 -0000 1.1.1.1
+++ prefs_dialog_plugins_prefs.h 25 Apr 2006 15:36:10 -0000 1.2
@@ -5,4 +5,5 @@

struct arglist *prefs_dialog_plugins_prefs();
void prefs_plugins_prefs_redraw(struct context *, struct arglist *);
+void prefs_dialog_plugins_prefs_read_only(struct arglist *, gboolean);
#endif

Index: prefs_dialog_plugins_prefs.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_dialog_plugins_prefs.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- prefs_dialog_plugins_prefs.c 9 Feb 2006 00:28:15 -0000 1.16
+++ prefs_dialog_plugins_prefs.c 25 Apr 2006 15:36:10 -0000 1.17
@@ -35,6 +35,7 @@
#include "comm.h"
#include "prefs_dialog_plugins_prefs.h"
#include "listnotebook.h"
+#include "readonly.h"

#include "nessus_i18n.h"

@@ -56,14 +57,17 @@
GtkWidget *cred_s_window, *cred_vbox;

listnotebook = listnotebook_new(FALSE, TRUE);
+ read_only_set_recurse(listnotebook);
gtk_container_set_border_width(GTK_CONTAINER(listnotebook), 10);

cred_s_window = gtk_scrolled_window_new(NULL, NULL);
+ read_only_set_recurse(cred_s_window);
gtk_container_border_width(GTK_CONTAINER(cred_s_window), 10);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cred_s_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

cred_vbox = gtk_vbox_new(FALSE, FALSE);
+ read_only_set_recurse(cred_vbox);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(cred_s_window),
cred_vbox);
gtk_widget_show(cred_vbox);
@@ -97,12 +101,14 @@
gtk_container_border_width(GTK_CONTAINER(frame), 10);
gtk_widget_show(frame);
arg_add_value(ctrls, "FRAME", ARG_PTR, -1, frame);
+ read_only_set_recurse(frame);


cred_frame = gtk_frame_new(_("Credentials"));
gtk_container_border_width(GTK_CONTAINER(cred_frame), 10);
gtk_widget_show(cred_frame);
arg_add_value(ctrls, "FRAME_CREDENTIALS", ARG_PTR, -1, cred_frame);
+ read_only_set_recurse(cred_frame);

create_plugin_prefs_containers(ctrls);

@@ -110,12 +116,24 @@
gtk_container_add(GTK_CONTAINER(frame), plugin_prefs);
gtk_widget_show(plugin_prefs);
cred_s_window = arg_get_value(ctrls, "SCROLLED_WINDOW_CREDENTIALS");
+ read_only_set_recurse(cred_s_window);
gtk_container_add(GTK_CONTAINER(cred_frame), cred_s_window);
gtk_widget_show(cred_s_window);

return (ctrls);
}

+
+void
+prefs_dialog_plugins_prefs_read_only(struct arglist *ctrls, gboolean readonly)
+{
+ read_only_set_read_only(GTK_WIDGET(arg_get_value(ctrls, "FRAME")),
+ readonly);
+ read_only_set_read_only(GTK_WIDGET(arg_get_value(ctrls,
+ "FRAME_CREDENTIALS")), readonly);
+}
+
+
static int is_credentials(char * plugin_name, char * preference_name)
{
if ( strcmp(plugin_name, "SSH settings") == 0 )
@@ -295,6 +313,7 @@
GtkWidget *listnotebook = arg_get_value(ctrls, "PLUGIN_PREFS");
GtkWidget *s_window = gtk_scrolled_window_new(NULL, NULL);

+ read_only_set_recurse(s_window);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(s_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(s_window);

Index: prefs_context.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/prefs_context.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- prefs_context.c 13 Oct 2005 15:55:47 -0000 1.7
+++ prefs_context.c 25 Apr 2006 15:36:11 -0000 1.8
@@ -172,14 +172,17 @@
}

void
-prefs_context_update_options_enable(enable)
- gboolean enable;
+prefs_context_update_options_enable(gboolean enable)
{
- prefs_context_enable_options_frame("SCAN_OPTIONS", enable);
- prefs_context_enable_options_frame("PLUGINS", enable);
- prefs_context_enable_options_frame("PLUGINS_PREFS", enable);
+ struct arglist *options = arg_get_value(MainDialog, "OPTIONS");
+
+ prefs_dialog_scan_opt_readonly(arg_get_value(options, "SCAN_OPTIONS"),
+ !enable);
+ prefs_plugins_read_only(arg_get_value(options, "PLUGINS"), !enable);
+ prefs_dialog_plugins_prefs_read_only(arg_get_value(options, "PLUGINS_PREFS"),
+ !enable);
prefs_context_enable_options_frame("TARGET", enable);
- prefs_context_enable_options_frame("USER", enable);
+ prefs_dialog_user_read_only(arg_get_value(options, "USER"), !enable);
prefs_context_enable_options_frame("SAVE_KB", enable);
}

@@ -354,6 +357,9 @@
}
gtk_frame_set_label(GTK_FRAME(contextframe), text);
g_free(text);
+
+ /* make sure the plugin cache of a report is loaded */
+ report_load_plugin_cache(context);

prefs_context_update_widgets(context);
prefs_context_update_comment(context);

Index: listnotebook.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/prefs_dialog/listnotebook.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- listnotebook.c 9 Feb 2006 00:28:15 -0000 1.5
+++ listnotebook.c 25 Apr 2006 15:36:11 -0000 1.6
@@ -36,6 +36,7 @@
#include <gtk/gtk.h>

#include "listnotebook.h"
+#include "readonly.h"

enum {
COL_PAGENAME,
@@ -151,6 +152,7 @@
COL_PAGENAME, GTK_SORT_ASCENDING);

scrolled = gtk_scrolled_window_new(NULL, NULL);
+ read_only_set_active(scrolled);
/* in a horizontal listnotebook, we don't want horizontal scrollbars
* in the list of pages. If we allow horizontal scrollbars the
* initial size is much too narrow */
@@ -180,6 +182,7 @@
* Set up a notebook in the box
*/
notebook = gtk_notebook_new();
+ read_only_set_recurse(notebook);
gtk_paned_add2(GTK_PANED(paned), notebook);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs