summaryrefslogtreecommitdiff
path: root/source4/lib/registry
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-05-23 13:50:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:53:54 -0500
commitb4c23f5a52ca5f3fa93e42f95efc74f5d6b47d50 (patch)
tree8da09303ebef0b40358172fdff00c1ef66c1bf35 /source4/lib/registry
parent5b5e793d1637da2521fbb43028bc7547f4ed58d3 (diff)
downloadsamba-b4c23f5a52ca5f3fa93e42f95efc74f5d6b47d50.tar.gz
samba-b4c23f5a52ca5f3fa93e42f95efc74f5d6b47d50.tar.bz2
samba-b4c23f5a52ca5f3fa93e42f95efc74f5d6b47d50.zip
r832: Only show menu items for backends if they're present
(This used to be commit 9228aeeafd956a2885b5f1dfaa6feacb555b7483)
Diffstat (limited to 'source4/lib/registry')
-rw-r--r--source4/lib/registry/common/reg_interface.c31
-rw-r--r--source4/lib/registry/tools/gregedit.c32
2 files changed, 39 insertions, 24 deletions
diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c
index e748c836cf..93e5b60984 100644
--- a/source4/lib/registry/common/reg_interface.c
+++ b/source4/lib/registry/common/reg_interface.c
@@ -58,7 +58,19 @@ NTSTATUS registry_register(void *_function)
/* Find a backend in the list of available backends */
static struct reg_init_function_entry *reg_find_backend_entry(const char *name)
{
- struct reg_init_function_entry *entry = backends;
+ struct reg_init_function_entry *entry;
+ static BOOL reg_first_init = True;
+
+ if(reg_first_init) {
+ status = register_subsystem("registry", registry_register);
+ if (!NT_STATUS_IS_OK(status))
+ return WERR_GENERAL_FAILURE;
+
+ static_init_registry;
+ reg_first_init = False;
+ }
+
+ entry = backends;
while(entry) {
if (strcmp(entry->functions->name, name)==0) return entry;
@@ -68,25 +80,20 @@ static struct reg_init_function_entry *reg_find_backend_entry(const char *name)
return NULL;
}
+BOOL reg_has_backend(const char *backend)
+{
+ return reg_find_backend_entry(backend)?True:False;
+}
+
/* Open a registry file/host/etc */
WERROR reg_open(const char *backend, const char *location, const char *credentials, REG_HANDLE **h)
{
struct reg_init_function_entry *entry;
- static BOOL reg_first_init = True;
TALLOC_CTX *mem_ctx;
REG_HANDLE *ret;
NTSTATUS status;
WERROR werr;
-
- if(reg_first_init) {
- status = register_subsystem("registry", registry_register);
- if (!NT_STATUS_IS_OK(status))
- return WERR_GENERAL_FAILURE;
-
- static_init_registry;
- reg_first_init = False;
- }
-
+
entry = reg_find_backend_entry(backend);
if (!entry) {
diff --git a/source4/lib/registry/tools/gregedit.c b/source4/lib/registry/tools/gregedit.c
index e8800c6ee9..5b78292061 100644
--- a/source4/lib/registry/tools/gregedit.c
+++ b/source4/lib/registry/tools/gregedit.c
@@ -450,21 +450,29 @@ static GtkWidget* create_mainwin (void)
menu_file_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_file), menu_file_menu);
- open_nt4 = gtk_image_menu_item_new_with_mnemonic("_Open NT4 file");
- gtk_widget_show (open_nt4);
- gtk_container_add (GTK_CONTAINER (menu_file_menu), open_nt4);
+ if(reg_has_backend("nt4")) {
+ open_nt4 = gtk_image_menu_item_new_with_mnemonic("_Open NT4 file");
+ gtk_widget_show (open_nt4);
+ gtk_container_add (GTK_CONTAINER (menu_file_menu), open_nt4);
+ }
- open_w95 = gtk_image_menu_item_new_with_mnemonic("_Open Win9x file");
- gtk_widget_show (open_w95);
- gtk_container_add (GTK_CONTAINER (menu_file_menu), open_w95);
+ if(reg_has_backend("w95")) {
+ open_w95 = gtk_image_menu_item_new_with_mnemonic("_Open Win9x file");
+ gtk_widget_show (open_w95);
+ gtk_container_add (GTK_CONTAINER (menu_file_menu), open_w95);
+ }
- open_gconf = gtk_image_menu_item_new_with_mnemonic ("_Open GConf");
- gtk_widget_show (open_gconf);
- gtk_container_add (GTK_CONTAINER (menu_file_menu), open_gconf);
+ if(reg_has_backend("gconf")) {
+ open_gconf = gtk_image_menu_item_new_with_mnemonic ("_Open GConf");
+ gtk_widget_show (open_gconf);
+ gtk_container_add (GTK_CONTAINER (menu_file_menu), open_gconf);
+ }
- open_remote = gtk_menu_item_new_with_mnemonic ("_Open Remote");
- gtk_widget_show (open_remote);
- gtk_container_add (GTK_CONTAINER (menu_file_menu), open_remote);
+ if(reg_has_backend("rpc")) {
+ open_remote = gtk_menu_item_new_with_mnemonic ("_Open Remote");
+ gtk_widget_show (open_remote);
+ gtk_container_add (GTK_CONTAINER (menu_file_menu), open_remote);
+ }
save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
gtk_widget_show (save);