mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r1432: - Move the various Gtk-specific parts from the registry code into a directory gtk/
- Move common "Samba-Gtk" code into gtk/common/ ("Connect to RPC pipe"-dialog, etc) - Add a new utility 'gwcrontab' that can currently list, delete and add 'atsvc' jobs. It still displays times and dates as integers though, will fix that later. Some screenshots available at: http://samba.org/~jelmer/gwcrontab/
This commit is contained in:
parent
ae2e6b5862
commit
d321cf20f1
@ -32,6 +32,7 @@ SMB_INCLUDE_M4(scripting/config.m4)
|
||||
SMB_INCLUDE_M4(client/config.m4)
|
||||
SMB_INCLUDE_M4(utils/config.m4)
|
||||
SMB_INCLUDE_M4(smbd/config.m4)
|
||||
SMB_INCLUDE_M4(gtk/config.m4)
|
||||
|
||||
ALLLIBS_LIBS="$LIBS"
|
||||
ALLLIBS_CFLAGS="$CFLAGS"
|
||||
|
17
source/gtk/README
Normal file
17
source/gtk/README
Normal file
@ -0,0 +1,17 @@
|
||||
This directory contains files for SMB-related Gtk Widgets
|
||||
and helper functions and utilities (frontends) for various SMB
|
||||
things.
|
||||
|
||||
Common code at the moment:
|
||||
GtkRpcBindingDialog - Gtk Dialog Window for obtaining user credentials and a RPC binding string
|
||||
gtk_show_werror() - Show dialog box with a WERROR
|
||||
gtk_show_nterror() - Show dialog box with a NTSTATUS
|
||||
create_gtk_samba_about() - Shows about Window
|
||||
|
||||
Utilities:
|
||||
gregedit - Gtk+ Registry Editor (RPC, NT4 files, W95 files, GConf)
|
||||
gwcrontab - View and edit 'cron/at'-like jobs using the atsvc service (needs a better name)
|
||||
|
||||
Ideas for future utilities:
|
||||
- SAM editor
|
||||
- Eventlog viewer
|
352
source/gtk/common/gtk-smb.c
Normal file
352
source/gtk/common/gtk-smb.c
Normal file
@ -0,0 +1,352 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
SMB-related GTK+ functions
|
||||
|
||||
Copyright (C) Jelmer Vernooij 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "includes.h"
|
||||
|
||||
void gtk_show_werror(GtkWidget *win, WERROR err)
|
||||
{
|
||||
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Windows error: %s\n", win_errstr(err));
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
void gtk_show_ntstatus(GtkWidget *win, NTSTATUS status)
|
||||
{
|
||||
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(win),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Windows error: %s\n", nt_errstr(status));
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void gtk_rpc_binding_dialog_class_init (GtkRpcBindingDialogClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static void gtk_rpc_binding_dialog_init (GtkRpcBindingDialog *gtk_rpc_binding_dialog)
|
||||
{
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *vbox1;
|
||||
GtkWidget *vbox6;
|
||||
GtkWidget *frame_transport;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *lbl_transport;
|
||||
GtkWidget *label1;
|
||||
GtkWidget *frame_host;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *lbl_name;
|
||||
GtkWidget *label2;
|
||||
GtkWidget *frame_security;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *label3;
|
||||
GtkWidget *frame_credentials;
|
||||
GtkWidget *table1;
|
||||
GtkWidget *lbl_username;
|
||||
GtkWidget *lbl_password;
|
||||
GtkWidget *label9;
|
||||
GtkWidget *chk_button;
|
||||
GtkWidget *lbl_credentials;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *btn_cancel;
|
||||
GtkWidget *btn_connect;
|
||||
GSList *transport_smb_group = NULL;
|
||||
|
||||
gtk_rpc_binding_dialog->mem_ctx = talloc_init("gtk_rcp_binding_dialog");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (gtk_rpc_binding_dialog), "Connect");
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (gtk_rpc_binding_dialog)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
vbox1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
|
||||
|
||||
frame_transport = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame_transport);
|
||||
gtk_box_pack_start (GTK_BOX (vbox1), frame_transport, TRUE, TRUE, 0);
|
||||
|
||||
vbox6 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox6);
|
||||
gtk_container_add (GTK_CONTAINER (frame_transport), vbox6);
|
||||
|
||||
gtk_rpc_binding_dialog->transport_smb = gtk_radio_button_new_with_mnemonic (NULL, "RPC over SMB over TCP/IP");
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->transport_smb);
|
||||
gtk_box_pack_start (GTK_BOX (vbox6), gtk_rpc_binding_dialog->transport_smb, FALSE, FALSE, 0);
|
||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_smb), transport_smb_group);
|
||||
transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_smb));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_rpc_binding_dialog->transport_smb), TRUE);
|
||||
|
||||
gtk_rpc_binding_dialog->transport_tcp_ip = gtk_radio_button_new_with_mnemonic (NULL, "RPC over TCP/IP");
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->transport_tcp_ip);
|
||||
gtk_box_pack_start (GTK_BOX (vbox6), gtk_rpc_binding_dialog->transport_tcp_ip, FALSE, FALSE, 0);
|
||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip), transport_smb_group);
|
||||
transport_smb_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (gtk_rpc_binding_dialog->transport_tcp_ip));
|
||||
|
||||
label1 = gtk_label_new ("Transport");
|
||||
gtk_widget_show (label1);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame_transport), label1);
|
||||
|
||||
frame_host = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame_host);
|
||||
gtk_box_pack_start (GTK_BOX (vbox1), frame_host, TRUE, TRUE, 0);
|
||||
|
||||
hbox1 = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (hbox1);
|
||||
gtk_container_add (GTK_CONTAINER (frame_host), hbox1);
|
||||
|
||||
lbl_name = gtk_label_new ("Name");
|
||||
gtk_widget_show (lbl_name);
|
||||
gtk_box_pack_start (GTK_BOX (hbox1), lbl_name, TRUE, TRUE, 0);
|
||||
|
||||
gtk_rpc_binding_dialog->entry_host = gtk_entry_new ();
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->entry_host);
|
||||
gtk_box_pack_start (GTK_BOX (hbox1), gtk_rpc_binding_dialog->entry_host, TRUE, TRUE, 0);
|
||||
|
||||
label2 = gtk_label_new ("Host");
|
||||
gtk_widget_show (label2);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame_host), label2);
|
||||
|
||||
frame_security = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame_security);
|
||||
gtk_box_pack_start (GTK_BOX (vbox1), frame_security, TRUE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox2);
|
||||
gtk_container_add (GTK_CONTAINER (frame_security), vbox2);
|
||||
|
||||
gtk_rpc_binding_dialog->chk_sign = gtk_check_button_new_with_mnemonic ("S_ign");
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->chk_sign);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), gtk_rpc_binding_dialog->chk_sign, FALSE, FALSE, 0);
|
||||
|
||||
gtk_rpc_binding_dialog->chk_seal = gtk_check_button_new_with_mnemonic ("_Seal");
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->chk_seal);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), gtk_rpc_binding_dialog->chk_seal, FALSE, FALSE, 0);
|
||||
|
||||
label3 = gtk_label_new ("Security");
|
||||
gtk_widget_show (label3);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame_security), label3);
|
||||
|
||||
frame_credentials = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame_credentials);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame_credentials, TRUE, TRUE, 0);
|
||||
|
||||
table1 = gtk_table_new (3, 2, FALSE);
|
||||
gtk_widget_show (table1);
|
||||
gtk_container_add (GTK_CONTAINER (frame_credentials), table1);
|
||||
|
||||
lbl_username = gtk_label_new ("Username:");
|
||||
gtk_widget_show (lbl_username);
|
||||
gtk_table_attach (GTK_TABLE (table1), lbl_username, 0, 1, 0, 1,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (lbl_username), 0, 0.5);
|
||||
|
||||
lbl_password = gtk_label_new ("Password:");
|
||||
gtk_widget_show (lbl_password);
|
||||
gtk_table_attach (GTK_TABLE (table1), lbl_password, 0, 1, 1, 2,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (lbl_password), 0, 0.5);
|
||||
|
||||
label9 = gtk_label_new ("");
|
||||
gtk_widget_show (label9);
|
||||
gtk_table_attach (GTK_TABLE (table1), label9, 0, 1, 2, 3,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5);
|
||||
|
||||
gtk_rpc_binding_dialog->entry_password = gtk_entry_new ();
|
||||
gtk_entry_set_visibility (GTK_ENTRY (gtk_rpc_binding_dialog->entry_password), FALSE);
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->entry_password);
|
||||
gtk_table_attach (GTK_TABLE (table1), gtk_rpc_binding_dialog->entry_password, 1, 2, 1, 2,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
gtk_rpc_binding_dialog->entry_username = gtk_entry_new ();
|
||||
gtk_widget_show (gtk_rpc_binding_dialog->entry_username);
|
||||
gtk_table_attach (GTK_TABLE (table1), gtk_rpc_binding_dialog->entry_username, 1, 2, 0, 1,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
chk_button = gtk_check_button_new_with_mnemonic ("_Use kerberos");
|
||||
gtk_widget_show (chk_button);
|
||||
gtk_table_attach (GTK_TABLE (table1), chk_button, 1, 2, 2, 3,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
lbl_credentials = gtk_label_new ("Credentials");
|
||||
gtk_widget_show (lbl_credentials);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame_credentials), lbl_credentials);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (gtk_rpc_binding_dialog)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
btn_cancel = gtk_button_new_from_stock ("gtk-cancel");
|
||||
gtk_widget_show (btn_cancel);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_cancel, GTK_RESPONSE_CANCEL);
|
||||
GTK_WIDGET_SET_FLAGS (btn_cancel, GTK_CAN_DEFAULT);
|
||||
|
||||
btn_connect = gtk_button_new_with_mnemonic ("_Connect");
|
||||
gtk_widget_show (btn_connect);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (gtk_rpc_binding_dialog), btn_connect, GTK_RESPONSE_ACCEPT);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (btn_connect), 1);
|
||||
GTK_WIDGET_SET_FLAGS (btn_connect, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_widget_grab_focus (btn_connect);
|
||||
gtk_widget_grab_default (btn_connect);
|
||||
}
|
||||
|
||||
GType gtk_rpc_binding_dialog_get_type ()
|
||||
{
|
||||
static GType mytype = 0;
|
||||
|
||||
if (!mytype)
|
||||
{
|
||||
static const GTypeInfo myinfo =
|
||||
{
|
||||
sizeof (GtkRpcBindingDialogClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gtk_rpc_binding_dialog_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GtkRpcBindingDialog),
|
||||
0,
|
||||
(GInstanceInitFunc) gtk_rpc_binding_dialog_init,
|
||||
};
|
||||
|
||||
mytype = g_type_register_static (GTK_TYPE_DIALOG,
|
||||
"GtkRpcBindingDialog", &myinfo, 0);
|
||||
}
|
||||
|
||||
return mytype;
|
||||
}
|
||||
|
||||
GtkWidget *gtk_rpc_binding_dialog_new (BOOL nocredentials)
|
||||
{
|
||||
return GTK_WIDGET ( gtk_type_new (gtk_rpc_binding_dialog_get_type ()));
|
||||
}
|
||||
|
||||
const char *gtk_rpc_binding_dialog_get_username(GtkRpcBindingDialog *d)
|
||||
{
|
||||
return gtk_entry_get_text(GTK_ENTRY(d->entry_username));
|
||||
}
|
||||
|
||||
const char *gtk_rpc_binding_dialog_get_password(GtkRpcBindingDialog *d)
|
||||
{
|
||||
return gtk_entry_get_text(GTK_ENTRY(d->entry_password));
|
||||
}
|
||||
|
||||
const char *gtk_rpc_binding_dialog_get_binding(GtkRpcBindingDialog *d, char *pipe)
|
||||
{
|
||||
const char *transport;
|
||||
const char *host;
|
||||
char *options = NULL;
|
||||
char *binding = NULL;
|
||||
|
||||
host = gtk_entry_get_text(GTK_ENTRY(d->entry_host));
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->transport_tcp_ip)))
|
||||
transport = "ncacn_tcp";
|
||||
else
|
||||
transport = "ncacn_np";
|
||||
// Format: TRANSPORT:host:[\pipe\foo,foo,foo]
|
||||
if(pipe != NULL) {
|
||||
options = talloc_asprintf(d->mem_ctx, "\\pipe\\%s", pipe);
|
||||
}
|
||||
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->chk_seal))) {
|
||||
options = talloc_asprintf_append(d->mem_ctx, options, ",seal");
|
||||
}
|
||||
|
||||
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->chk_sign))) {
|
||||
options = talloc_asprintf_append(d->mem_ctx, options, ",sign");
|
||||
}
|
||||
|
||||
if(options) {
|
||||
return talloc_asprintf(d->mem_ctx, "%s:%s:[%s]", transport, host, options);
|
||||
} else {
|
||||
return talloc_asprintf(d->mem_ctx, "%s:%s", transport, host);
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget* create_gtk_samba_about_dialog (char *appname)
|
||||
{
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *image1;
|
||||
GtkWidget *label1;
|
||||
GtkWidget *label2;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *closebutton1;
|
||||
GtkWidget *aboutwin;
|
||||
|
||||
aboutwin = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (aboutwin), "About");
|
||||
gtk_window_set_resizable (GTK_WINDOW (aboutwin), FALSE);
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (aboutwin)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
/* FIXME: Samba logo ?
|
||||
image1 = create_pixmap (aboutwin, "samba.png");
|
||||
gtk_widget_show (image1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), image1, FALSE, TRUE, 0); */
|
||||
|
||||
label1 = gtk_label_new (appname);
|
||||
gtk_widget_show (label1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), label1, FALSE, FALSE, 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
|
||||
|
||||
label2 = gtk_label_new_with_mnemonic ("(C) 2004 Jelmer Vernooij <jelmer@samba.org>\nPart of Samba\nhttp://www.samba.org/\n");
|
||||
gtk_widget_show (label2);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), label2, TRUE, FALSE, 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label2), TRUE);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (aboutwin)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
closebutton1 = gtk_button_new_from_stock ("gtk-close");
|
||||
gtk_widget_show (closebutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (aboutwin), closebutton1, GTK_RESPONSE_CLOSE);
|
||||
GTK_WIDGET_SET_FLAGS (closebutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
return aboutwin;
|
||||
}
|
53
source/gtk/common/gtk-smb.h
Normal file
53
source/gtk/common/gtk-smb.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
SMB-related GTK+ functions
|
||||
|
||||
Copyright (C) Jelmer Vernooij 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SMB_H__
|
||||
#define __GTK_SMB_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct _GtkRpcBindingDialog GtkRpcBindingDialog;
|
||||
|
||||
struct _GtkRpcBindingDialog
|
||||
{
|
||||
GtkDialog dialog;
|
||||
GtkWidget *chk_sign;
|
||||
GtkWidget *chk_seal;
|
||||
GtkWidget *transport_tcp_ip;
|
||||
GtkWidget *transport_smb;
|
||||
GtkWidget *entry_host;
|
||||
GtkWidget *entry_username;
|
||||
GtkWidget *entry_password;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
};
|
||||
|
||||
typedef struct _GtkRpcBindingDialogClass GtkRpcBindingDialogClass;
|
||||
|
||||
struct _GtkRpcBindingDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
#define GTK_RPC_BINDING_DIALOG(obj) GTK_CHECK_CAST (obj, gtk_rpc_binding_dialog_get_type (), GtkRpcBindingDialog)
|
||||
#define GTK_RPC_BINDING_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_rpc_binding_dialog_class_get_type (), GtkRpcBindingDialogClass)
|
||||
#define IS_GTK_RPC_BINDING_DIALOG(obj) GTK_CHECK_TYPE (obj, gtk_rpc_binding_dialog_get_type ())
|
||||
|
||||
#endif
|
16
source/gtk/config.m4
Normal file
16
source/gtk/config.m4
Normal file
@ -0,0 +1,16 @@
|
||||
dnl # LIB GTK SMB subsystem
|
||||
|
||||
SMB_EXT_LIB_FROM_PKGCONFIG(gtk, [glib-2.0 gtk+-2.0])
|
||||
SMB_SUBSYSTEM_ENABLE(GTKSMB, NO)
|
||||
SMB_BINARY_ENABLE(gregedit, NO)
|
||||
SMB_BINARY_ENABLE(gwcrontab, NO)
|
||||
|
||||
if test t$SMB_EXT_LIB_ENABLE_gtk = tYES; then
|
||||
SMB_SUBSYSTEM_ENABLE(GTKSMB, YES)
|
||||
SMB_BINARY_ENABLE(gregedit, YES)
|
||||
SMB_BINARY_ENABLE(gwcrontab, YES)
|
||||
fi
|
||||
|
||||
SMB_SUBSYSTEM_MK(GTKSMB,gtk/config.mk)
|
||||
SMB_BINARY_MK(gregedit,gtk/config.mk)
|
||||
SMB_BINARY_MK(gwcrontab,gtk/config.mk)
|
27
source/gtk/config.mk
Normal file
27
source/gtk/config.mk
Normal file
@ -0,0 +1,27 @@
|
||||
# LIB GTK SMB subsystem
|
||||
|
||||
##############################
|
||||
# Start SUBSYSTEM GTKSMB
|
||||
[SUBSYSTEM::GTKSMB]
|
||||
INIT_OBJ_FILES = gtk/common/gtk-smb.o
|
||||
REQUIRED_LIBRARIES = gtk
|
||||
REQUIRED_SUBSYSTEMS = \
|
||||
CHARSET LIBBASIC
|
||||
# End SUBSYSTEM GTKSMB
|
||||
##############################
|
||||
|
||||
################################################
|
||||
# Start BINARY gregedit
|
||||
[BINARY::gregedit]
|
||||
OBJ_FILES = gtk/tools/gregedit.o
|
||||
REQUIRED_SUBSYSTEMS = CONFIG LIBCMDLINE REGISTRY GTKSMB
|
||||
# End BINARY gregedit
|
||||
################################################
|
||||
|
||||
################################################
|
||||
# Start BINARY gwcrontab
|
||||
[BINARY::gwcrontab]
|
||||
OBJ_FILES = gtk/tools/gwcrontab.o
|
||||
REQUIRED_SUBSYSTEMS = CONFIG LIBCMDLINE LIBRPC LIBSMB GTKSMB
|
||||
# End BINARY gwcrontab
|
||||
################################################
|
@ -41,28 +41,12 @@ GtkWidget *tree_keys;
|
||||
GtkWidget *aboutwin;
|
||||
GtkWidget *mainwin;
|
||||
|
||||
GtkWidget *rpcwin;
|
||||
GtkWidget *rpcwin_host;
|
||||
GtkWidget *rpcwin_user;
|
||||
GtkWidget *rpcwin_password;
|
||||
GtkWidget *save;
|
||||
GtkWidget *save_as;
|
||||
static GtkWidget* create_openfilewin (void);
|
||||
static GtkWidget* create_savefilewin (void);
|
||||
static GtkWidget* create_aboutwin (void);
|
||||
REG_HANDLE *registry = NULL;
|
||||
|
||||
static void gtk_show_werror(WERROR err)
|
||||
{
|
||||
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(mainwin),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Registry error: %s\n", win_errstr(err));
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *arg2)
|
||||
{
|
||||
GtkTreeIter firstiter, iter, tmpiter;
|
||||
@ -108,7 +92,7 @@ static void expand_key(GtkTreeView *treeview, GtkTreeIter *parent, GtkTreePath *
|
||||
gtk_tree_store_append(store_keys, &tmpiter, &iter);
|
||||
}
|
||||
|
||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) gtk_show_werror(error);
|
||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) gtk_show_werror(mainwin, error);
|
||||
}
|
||||
|
||||
static void registry_load_root()
|
||||
@ -127,7 +111,7 @@ static void registry_load_root()
|
||||
return;
|
||||
}
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,84 +133,6 @@ static void registry_load_root()
|
||||
gtk_widget_set_sensitive( save_as, True );
|
||||
}
|
||||
|
||||
static GtkWidget* create_rpcwin (void)
|
||||
{
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *table1;
|
||||
GtkWidget *label1;
|
||||
GtkWidget *label2;
|
||||
GtkWidget *label3;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *cancelbutton1;
|
||||
GtkWidget *okbutton1;
|
||||
|
||||
rpcwin = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (rpcwin), "Connect to remote server");
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (rpcwin)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
table1 = gtk_table_new (3, 2, FALSE);
|
||||
gtk_widget_show (table1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, TRUE, TRUE, 0);
|
||||
|
||||
label1 = gtk_label_new ("Host:");
|
||||
gtk_widget_show (label1);
|
||||
gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
|
||||
|
||||
label2 = gtk_label_new ("User:");
|
||||
gtk_widget_show (label2);
|
||||
gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
|
||||
|
||||
label3 = gtk_label_new ("Password:");
|
||||
gtk_widget_show (label3);
|
||||
gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 2, 3,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
|
||||
|
||||
rpcwin_host = gtk_entry_new ();
|
||||
gtk_widget_show (rpcwin_host);
|
||||
gtk_table_attach (GTK_TABLE (table1), rpcwin_host, 1, 2, 0, 1,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
rpcwin_user = gtk_entry_new ();
|
||||
gtk_widget_show (rpcwin_user);
|
||||
gtk_table_attach (GTK_TABLE (table1), rpcwin_user, 1, 2, 1, 2,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
rpcwin_password = gtk_entry_new ();
|
||||
gtk_widget_show (rpcwin_password);
|
||||
gtk_table_attach (GTK_TABLE (table1), rpcwin_password, 1, 2, 2, 3,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_entry_set_visibility (GTK_ENTRY (rpcwin_password), FALSE);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (rpcwin)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
|
||||
gtk_widget_show (cancelbutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (rpcwin), cancelbutton1, GTK_RESPONSE_CANCEL);
|
||||
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
okbutton1 = gtk_button_new_from_stock ("gtk-ok");
|
||||
gtk_widget_show (okbutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (rpcwin), okbutton1, GTK_RESPONSE_OK);
|
||||
GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
return rpcwin;
|
||||
}
|
||||
|
||||
static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
|
||||
{
|
||||
gint result = gtk_dialog_run(GTK_DIALOG(create_openfilewin()));
|
||||
@ -237,7 +143,7 @@ static void on_open_file_activate (GtkMenuItem *menuitem, gpointer user_data)
|
||||
filename = strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(openfilewin)));
|
||||
error = reg_open(user_data, filename, NULL, ®istry);
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
break;
|
||||
}
|
||||
registry_load_root();
|
||||
@ -254,29 +160,30 @@ static void on_open_gconf_activate (GtkMenuItem *menui
|
||||
{
|
||||
WERROR error = reg_open("gconf", NULL, NULL, ®istry);
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
return;
|
||||
}
|
||||
|
||||
registry_load_root();
|
||||
}
|
||||
|
||||
static void on_open_remote_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
static void on_open_remote_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||
{
|
||||
char *location, *credentials;
|
||||
gint result = gtk_dialog_run(GTK_DIALOG(create_rpcwin()));
|
||||
char *credentials;
|
||||
const char *location;
|
||||
GtkWidget *rpcwin = GTK_WIDGET(gtk_rpc_binding_dialog_new(TRUE));
|
||||
gint result = gtk_dialog_run(GTK_DIALOG(rpcwin));
|
||||
WERROR error;
|
||||
switch(result) {
|
||||
case GTK_RESPONSE_OK:
|
||||
asprintf(&location, "ncacn_np:%s", gtk_entry_get_text(GTK_ENTRY(rpcwin_host)));
|
||||
asprintf(&credentials, "%s%%%s", gtk_entry_get_text(GTK_ENTRY(rpcwin_user)), gtk_entry_get_text(GTK_ENTRY(rpcwin_password)));
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
location = gtk_rpc_binding_dialog_get_binding(GTK_RPC_BINDING_DIALOG(rpcwin), NULL);
|
||||
asprintf(&credentials, "%s%%%s", gtk_rpc_binding_dialog_get_username(GTK_RPC_BINDING_DIALOG(rpcwin)), gtk_rpc_binding_dialog_get_password(GTK_RPC_BINDING_DIALOG(rpcwin)));
|
||||
error = reg_open("rpc", location, credentials, ®istry);
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
break;
|
||||
}
|
||||
free(location); free(credentials);
|
||||
free(credentials);
|
||||
registry_load_root();
|
||||
break;
|
||||
default:
|
||||
@ -292,7 +199,7 @@ static void on_save_activate (GtkMenuItem *menuitem,
|
||||
{
|
||||
WERROR error = reg_save(registry, NULL);
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +215,7 @@ static void on_save_as_activate (GtkMenuItem *menuitem,
|
||||
case GTK_RESPONSE_OK:
|
||||
error = reg_save(registry, gtk_file_selection_get_filename(GTK_FILE_SELECTION(savefilewin)));
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -358,8 +265,9 @@ static void on_delete_activate (GtkMenuItem *menuitem,
|
||||
static void on_about_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_dialog_run(GTK_DIALOG(create_aboutwin()));
|
||||
gtk_widget_destroy(aboutwin);
|
||||
GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog());
|
||||
gtk_dialog_run(aboutwin);
|
||||
gtk_widget_destroy(GTK_WIDGET(aboutwin));
|
||||
}
|
||||
|
||||
static void on_key_activate (GtkTreeView *treeview,
|
||||
@ -395,7 +303,7 @@ static void on_key_activate (GtkTreeView *treeview,
|
||||
-1);
|
||||
}
|
||||
|
||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) gtk_show_werror(error);
|
||||
if(!W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS)) gtk_show_werror(mainwin, error);
|
||||
}
|
||||
|
||||
static GtkWidget* create_mainwin (void)
|
||||
@ -651,50 +559,6 @@ static GtkWidget* create_mainwin (void)
|
||||
return mainwin;
|
||||
}
|
||||
|
||||
static GtkWidget* create_aboutwin (void)
|
||||
{
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *image1;
|
||||
GtkWidget *label1;
|
||||
GtkWidget *label2;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *closebutton1;
|
||||
|
||||
aboutwin = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (aboutwin), "About GRegEdit");
|
||||
gtk_window_set_resizable (GTK_WINDOW (aboutwin), FALSE);
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (aboutwin)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
/* FIXME: Samba logo ?
|
||||
image1 = create_pixmap (aboutwin, "samba.png");
|
||||
gtk_widget_show (image1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), image1, FALSE, TRUE, 0); */
|
||||
|
||||
label1 = gtk_label_new ("GRegEdit 0.1");
|
||||
gtk_widget_show (label1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), label1, FALSE, FALSE, 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
|
||||
|
||||
label2 = gtk_label_new_with_mnemonic ("(C) 2004 Jelmer Vernooij <jelmer@samba.org>\nPart of Samba\nhttp://www.samba.org/\n");
|
||||
gtk_widget_show (label2);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), label2, TRUE, FALSE, 0);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label2), TRUE);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (aboutwin)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
closebutton1 = gtk_button_new_from_stock ("gtk-close");
|
||||
gtk_widget_show (closebutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (aboutwin), closebutton1, GTK_RESPONSE_CLOSE);
|
||||
GTK_WIDGET_SET_FLAGS (closebutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
return aboutwin;
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget* create_openfilewin (void)
|
||||
{
|
||||
GtkWidget *ok_button;
|
||||
@ -766,7 +630,7 @@ static GtkWidget* create_savefilewin (void)
|
||||
|
||||
error = reg_open(backend, location, credentials, ®istry);
|
||||
if(!W_ERROR_IS_OK(error)) {
|
||||
gtk_show_werror(error);
|
||||
gtk_show_werror(mainwin, error);
|
||||
return -1;
|
||||
}
|
||||
mainwin = create_mainwin ();
|
529
source/gtk/tools/gwcrontab.c
Normal file
529
source/gtk/tools/gwcrontab.c
Normal file
@ -0,0 +1,529 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
GTK+ Windows crontab frontend
|
||||
|
||||
Copyright (C) Jelmer Vernooij 2004
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "includes.h"
|
||||
|
||||
struct dcerpc_pipe *at_pipe = NULL;
|
||||
GtkWidget *mainwin;
|
||||
GtkListStore *store_jobs;
|
||||
GtkWidget *tasks;
|
||||
GtkWidget *entry_cmd;
|
||||
GtkWidget *entry_repeat_weekly;
|
||||
GtkWidget *entry_repeat_monthly;
|
||||
|
||||
void update_joblist()
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = talloc_init("update_joblist");
|
||||
NTSTATUS status;
|
||||
struct atsvc_JobEnum r;
|
||||
struct atsvc_enum_ctr ctr;
|
||||
int i;
|
||||
uint32 resume_handle = 0;
|
||||
|
||||
gtk_list_store_clear(store_jobs);
|
||||
|
||||
ctr.entries_read = 0;
|
||||
ctr.first_entry = NULL;
|
||||
r.in.servername = dcerpc_server_name(at_pipe);
|
||||
r.in.ctr = r.out.ctr = &ctr;
|
||||
r.in.preferred_max_len = 0xffffffff;
|
||||
r.in.resume_handle = r.out.resume_handle = &resume_handle;
|
||||
|
||||
status = dcerpc_atsvc_JobEnum(at_pipe, mem_ctx, &r);
|
||||
if(!NT_STATUS_IS_OK(status)) {
|
||||
gtk_show_ntstatus(mainwin, status);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; r.out.ctr && i < r.out.ctr->entries_read; i++) {
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append(store_jobs, &iter);
|
||||
gtk_list_store_set (store_jobs, &iter,
|
||||
0, r.out.ctr->first_entry[i].flags,
|
||||
1, r.out.ctr->first_entry[i].job_id,
|
||||
2, r.out.ctr->first_entry[i].days_of_week, /*FIXME: Nicer format */
|
||||
3, r.out.ctr->first_entry[i].job_time, /* FIXME: Nicer format */
|
||||
4, r.out.ctr->first_entry[i].command,
|
||||
-1);
|
||||
|
||||
}
|
||||
talloc_destroy(mem_ctx);
|
||||
gtk_widget_set_sensitive(tasks, TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
on_connect_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkRpcBindingDialog *d;
|
||||
NTSTATUS status;
|
||||
gint result;
|
||||
|
||||
d = GTK_RPC_BINDING_DIALOG(gtk_rpc_binding_dialog_new(FALSE));
|
||||
result = gtk_dialog_run(GTK_DIALOG(d));
|
||||
switch(result) {
|
||||
case GTK_RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
gtk_widget_destroy(GTK_WIDGET(d));
|
||||
return;
|
||||
}
|
||||
|
||||
/* If connected, get list of jobs */
|
||||
status = dcerpc_pipe_connect(&at_pipe, (char *)gtk_rpc_binding_dialog_get_binding(d, DCERPC_ATSVC_NAME), DCERPC_ATSVC_UUID, DCERPC_ATSVC_VERSION, lp_workgroup(), (char *)gtk_rpc_binding_dialog_get_username(d), (char *)gtk_rpc_binding_dialog_get_password(d));
|
||||
if(!NT_STATUS_IS_OK(status)) {
|
||||
gtk_show_ntstatus(mainwin, status);
|
||||
at_pipe = NULL;
|
||||
gtk_widget_destroy(GTK_WIDGET(d));
|
||||
return;
|
||||
}
|
||||
gtk_widget_destroy(GTK_WIDGET(d));
|
||||
|
||||
update_joblist();
|
||||
}
|
||||
|
||||
void
|
||||
on_quit_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
if(at_pipe)dcerpc_pipe_close(at_pipe);
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget* create_new_job_dialog (void);
|
||||
|
||||
void
|
||||
on_new_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkWidget *d = create_new_job_dialog();
|
||||
gint result = gtk_dialog_run(GTK_DIALOG(d));
|
||||
struct atsvc_JobAdd r;
|
||||
struct atsvc_JobInfo job;
|
||||
NTSTATUS status;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
switch(result) {
|
||||
case GTK_RESPONSE_OK:
|
||||
break;
|
||||
default:
|
||||
gtk_widget_destroy(d);
|
||||
return;
|
||||
}
|
||||
mem_ctx = talloc_init("add_job");
|
||||
|
||||
job.job_time = 0; /* FIXME */
|
||||
job.days_of_month = 0; /* FIXME */
|
||||
job.days_of_week = 0; /* FIXME */
|
||||
job.flags = 0; /* FIXME */
|
||||
job.command = gtk_entry_get_text(GTK_ENTRY(entry_cmd));
|
||||
r.in.servername = dcerpc_server_name(at_pipe);
|
||||
r.in.job_info = &job;
|
||||
|
||||
status = dcerpc_atsvc_JobAdd(at_pipe, mem_ctx, &r);
|
||||
if(!NT_STATUS_IS_OK(status)) {
|
||||
talloc_destroy(mem_ctx);
|
||||
gtk_show_ntstatus(mainwin, status);
|
||||
return;
|
||||
}
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
gtk_widget_destroy(d);
|
||||
|
||||
d = gtk_message_dialog_new (GTK_WINDOW(mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Job Id: %d", r.out.job_id);
|
||||
gtk_dialog_run(GTK_DIALOG(d));
|
||||
gtk_widget_destroy(d);
|
||||
update_joblist();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_delete_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tasks));
|
||||
GtkTreeModel *model = GTK_TREE_MODEL(store_jobs);
|
||||
GtkTreeIter iter;
|
||||
gint id;
|
||||
|
||||
if (gtk_tree_selection_get_selected (sel, &model, &iter))
|
||||
{
|
||||
struct atsvc_JobDel r;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
NTSTATUS status;
|
||||
gtk_tree_model_get (model, &iter, 1, &id, -1);
|
||||
|
||||
r.in.servername = dcerpc_server_name(at_pipe);
|
||||
r.in.min_job_id = r.in.max_job_id = id;
|
||||
|
||||
mem_ctx = talloc_init("del_job");
|
||||
status = dcerpc_atsvc_JobDel(at_pipe, mem_ctx, &r);
|
||||
talloc_destroy(mem_ctx);
|
||||
if(!NT_STATUS_IS_OK(status)) {
|
||||
gtk_show_ntstatus(mainwin, status);
|
||||
return;
|
||||
}
|
||||
|
||||
update_joblist();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_about_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkDialog *aboutwin = GTK_DIALOG(create_gtk_samba_about_dialog());
|
||||
gtk_dialog_run(aboutwin);
|
||||
gtk_widget_destroy(GTK_WIDGET(aboutwin));
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
create_mainwindow (void)
|
||||
{
|
||||
GtkWidget *mainwindow;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *menubar;
|
||||
GtkWidget *menuitem4;
|
||||
GtkWidget *menuitem4_menu;
|
||||
GtkWidget *connect;
|
||||
GtkWidget *separatormenuitem1;
|
||||
GtkWidget *quit;
|
||||
GtkWidget *task;
|
||||
GtkWidget *task_menu;
|
||||
GtkWidget *new;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *curcol;
|
||||
GtkWidget *delete;
|
||||
GtkWidget *menuitem7;
|
||||
GtkWidget *menuitem7_menu;
|
||||
GtkWidget *about;
|
||||
GtkWidget *scrolledwindow;
|
||||
GtkWidget *statusbar;
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
|
||||
mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (mainwindow), "Task Scheduler");
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
gtk_container_add (GTK_CONTAINER (mainwindow), vbox);
|
||||
|
||||
menubar = gtk_menu_bar_new ();
|
||||
gtk_widget_show (menubar);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
|
||||
|
||||
menuitem4 = gtk_menu_item_new_with_mnemonic ("_File");
|
||||
gtk_widget_show (menuitem4);
|
||||
gtk_container_add (GTK_CONTAINER (menubar), menuitem4);
|
||||
|
||||
menuitem4_menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);
|
||||
|
||||
connect = gtk_menu_item_new_with_mnemonic ("_Connect");
|
||||
gtk_widget_show (connect);
|
||||
gtk_container_add (GTK_CONTAINER (menuitem4_menu), connect);
|
||||
|
||||
separatormenuitem1 = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (separatormenuitem1);
|
||||
gtk_container_add (GTK_CONTAINER (menuitem4_menu), separatormenuitem1);
|
||||
gtk_widget_set_sensitive (separatormenuitem1, FALSE);
|
||||
|
||||
quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
|
||||
gtk_widget_show (quit);
|
||||
gtk_container_add (GTK_CONTAINER (menuitem4_menu), quit);
|
||||
|
||||
task = gtk_menu_item_new_with_mnemonic ("_Task");
|
||||
gtk_widget_show (task);
|
||||
gtk_container_add (GTK_CONTAINER (menubar), task);
|
||||
|
||||
task_menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (task), task_menu);
|
||||
|
||||
new = gtk_menu_item_new_with_mnemonic ("_New");
|
||||
gtk_widget_show (new);
|
||||
gtk_container_add (GTK_CONTAINER (task_menu), new);
|
||||
|
||||
delete = gtk_menu_item_new_with_mnemonic ("_Delete");
|
||||
gtk_widget_show (delete);
|
||||
gtk_container_add (GTK_CONTAINER (task_menu), delete);
|
||||
|
||||
menuitem7 = gtk_menu_item_new_with_mnemonic ("_Help");
|
||||
gtk_widget_show (menuitem7);
|
||||
gtk_container_add (GTK_CONTAINER (menubar), menuitem7);
|
||||
|
||||
menuitem7_menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem7), menuitem7_menu);
|
||||
|
||||
about = gtk_menu_item_new_with_mnemonic ("_About");
|
||||
gtk_widget_show (about);
|
||||
gtk_container_add (GTK_CONTAINER (menuitem7_menu), about);
|
||||
|
||||
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolledwindow);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
|
||||
|
||||
tasks = gtk_tree_view_new ();
|
||||
|
||||
curcol = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title(curcol, "Status");
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(curcol, renderer, True);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol);
|
||||
gtk_tree_view_column_add_attribute(curcol, renderer, "text", 0);
|
||||
|
||||
curcol = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title(curcol, "ID");
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(curcol, renderer, True);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol);
|
||||
gtk_tree_view_column_add_attribute(curcol, renderer, "text", 1);
|
||||
|
||||
curcol = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title(curcol, "Day");
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(curcol, renderer, True);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol);
|
||||
gtk_tree_view_column_add_attribute(curcol, renderer, "text", 2);
|
||||
|
||||
curcol = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title(curcol, "Time");
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(curcol, renderer, True);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol);
|
||||
gtk_tree_view_column_add_attribute(curcol, renderer, "text", 3);
|
||||
|
||||
curcol = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title(curcol, "Command Line");
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(curcol, renderer, True);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tasks), curcol);
|
||||
gtk_tree_view_column_add_attribute(curcol, renderer, "text", 4);
|
||||
|
||||
store_jobs = gtk_list_store_new(5, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(tasks), GTK_TREE_MODEL(store_jobs));
|
||||
g_object_unref(store_jobs);
|
||||
|
||||
gtk_widget_show (tasks);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), tasks);
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_widget_show (statusbar);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
|
||||
|
||||
g_signal_connect ((gpointer) connect, "activate",
|
||||
G_CALLBACK (on_connect_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) quit, "activate",
|
||||
G_CALLBACK (on_quit_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) new, "activate",
|
||||
G_CALLBACK (on_new_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) delete, "activate",
|
||||
G_CALLBACK (on_delete_activate),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) about, "activate",
|
||||
G_CALLBACK (on_about_activate),
|
||||
NULL);
|
||||
|
||||
gtk_window_add_accel_group (GTK_WINDOW (mainwindow), accel_group);
|
||||
gtk_widget_set_sensitive(tasks, FALSE);
|
||||
|
||||
return mainwindow;
|
||||
}
|
||||
|
||||
void
|
||||
on_chk_weekly_toggled (GtkToggleButton *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_widget_set_sensitive(entry_repeat_weekly, gtk_toggle_button_get_active(togglebutton));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
on_chk_monthly_toggled (GtkToggleButton *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_widget_set_sensitive(entry_repeat_monthly, gtk_toggle_button_get_active(togglebutton));
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget*create_new_job_dialog (void)
|
||||
{
|
||||
GtkWidget *new_job_dialog;
|
||||
GtkWidget *dialog_vbox1;
|
||||
GtkWidget *frame1;
|
||||
GtkWidget *table1;
|
||||
GtkWidget *label4;
|
||||
GtkWidget *cal_day;
|
||||
GtkWidget *label3;
|
||||
GtkWidget *entry_time;
|
||||
GtkWidget *chk_weekly;
|
||||
GtkWidget *chk_monthly;
|
||||
GtkWidget *label1;
|
||||
GtkWidget *frame2;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *label5;
|
||||
GtkWidget *label2;
|
||||
GtkWidget *dialog_action_area1;
|
||||
GtkWidget *cancelbutton1;
|
||||
GtkWidget *okbutton1;
|
||||
|
||||
new_job_dialog = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (new_job_dialog), "New job");
|
||||
|
||||
dialog_vbox1 = GTK_DIALOG (new_job_dialog)->vbox;
|
||||
gtk_widget_show (dialog_vbox1);
|
||||
|
||||
frame1 = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame1);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame1, TRUE, TRUE, 0);
|
||||
|
||||
table1 = gtk_table_new (4, 2, FALSE);
|
||||
gtk_widget_show (table1);
|
||||
gtk_container_add (GTK_CONTAINER (frame1), table1);
|
||||
|
||||
label4 = gtk_label_new ("Time:");
|
||||
gtk_widget_show (label4);
|
||||
gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 1, 2,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
|
||||
|
||||
cal_day = gtk_calendar_new ();
|
||||
gtk_widget_show (cal_day);
|
||||
gtk_table_attach (GTK_TABLE (table1), cal_day, 1, 2, 0, 1,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (GTK_FILL), 0, 0);
|
||||
gtk_calendar_display_options (GTK_CALENDAR (cal_day),
|
||||
GTK_CALENDAR_SHOW_HEADING
|
||||
| GTK_CALENDAR_SHOW_DAY_NAMES);
|
||||
|
||||
label3 = gtk_label_new ("Date");
|
||||
gtk_widget_show (label3);
|
||||
gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 0, 1,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
|
||||
|
||||
entry_time = gtk_entry_new ();
|
||||
gtk_widget_show (entry_time);
|
||||
gtk_table_attach (GTK_TABLE (table1), entry_time, 1, 2, 1, 2,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
chk_weekly = gtk_check_button_new_with_mnemonic ("Repeat weekly");
|
||||
gtk_widget_show (chk_weekly);
|
||||
gtk_table_attach (GTK_TABLE (table1), chk_weekly, 0, 1, 2, 3,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
entry_repeat_weekly = gtk_entry_new ();
|
||||
gtk_widget_show (entry_repeat_weekly);
|
||||
gtk_table_attach (GTK_TABLE (table1), entry_repeat_weekly, 1, 2, 2, 3,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
chk_monthly = gtk_check_button_new_with_mnemonic ("Repeat monthly");
|
||||
gtk_widget_show (chk_monthly);
|
||||
gtk_table_attach (GTK_TABLE (table1), chk_monthly, 0, 1, 3, 4,
|
||||
(GtkAttachOptions) (GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
entry_repeat_monthly = gtk_entry_new ();
|
||||
gtk_widget_show (entry_repeat_monthly);
|
||||
gtk_table_attach (GTK_TABLE (table1), entry_repeat_monthly, 1, 2, 3, 4,
|
||||
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
||||
(GtkAttachOptions) (0), 0, 0);
|
||||
|
||||
label1 = gtk_label_new ("Moment");
|
||||
gtk_widget_show (label1);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame1), label1);
|
||||
|
||||
frame2 = gtk_frame_new (NULL);
|
||||
gtk_widget_show (frame2);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox1), frame2, TRUE, TRUE, 0);
|
||||
|
||||
hbox1 = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (hbox1);
|
||||
gtk_container_add (GTK_CONTAINER (frame2), hbox1);
|
||||
|
||||
label5 = gtk_label_new ("Command to execute");
|
||||
gtk_widget_show (label5);
|
||||
gtk_box_pack_start (GTK_BOX (hbox1), label5, TRUE, TRUE, 0);
|
||||
|
||||
entry_cmd = gtk_entry_new ();
|
||||
gtk_widget_show (entry_cmd);
|
||||
gtk_box_pack_start (GTK_BOX (hbox1), entry_cmd, TRUE, TRUE, 0);
|
||||
|
||||
label2 = gtk_label_new ("Command");
|
||||
gtk_widget_show (label2);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame2), label2);
|
||||
|
||||
dialog_action_area1 = GTK_DIALOG (new_job_dialog)->action_area;
|
||||
gtk_widget_show (dialog_action_area1);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
|
||||
|
||||
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
|
||||
gtk_widget_show (cancelbutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (new_job_dialog), cancelbutton1, GTK_RESPONSE_CANCEL);
|
||||
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
okbutton1 = gtk_button_new_from_stock ("gtk-ok");
|
||||
gtk_widget_show (okbutton1);
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (new_job_dialog), okbutton1, GTK_RESPONSE_OK);
|
||||
GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
|
||||
|
||||
g_signal_connect ((gpointer) chk_weekly, "toggled",
|
||||
G_CALLBACK (on_chk_weekly_toggled),
|
||||
NULL);
|
||||
g_signal_connect ((gpointer) chk_monthly, "toggled",
|
||||
G_CALLBACK (on_chk_monthly_toggled),
|
||||
NULL);
|
||||
|
||||
return new_job_dialog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gtk_init(&argc, &argv);
|
||||
mainwin = create_mainwindow();
|
||||
gtk_widget_show(mainwin);
|
||||
gtk_main();
|
||||
}
|
||||
|
@ -673,6 +673,7 @@ extern int errno;
|
||||
#include "ntvfs/ntvfs.h"
|
||||
#include "cli_context.h"
|
||||
#include "registry.h"
|
||||
#include "gtk/common/gtk-smb.h"
|
||||
|
||||
#define malloc_p(type) (type *)malloc(sizeof(type))
|
||||
#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
|
||||
|
@ -7,7 +7,6 @@ LIBWINREG=libwinregistry
|
||||
|
||||
AC_CONFIG_FILES(lib/registry/winregistry.pc)
|
||||
|
||||
SMB_BINARY_ENABLE(gregedit, NO)
|
||||
SMB_MODULE_DEFAULT(registry_gconf, NOT)
|
||||
|
||||
SMB_EXT_LIB_FROM_PKGCONFIG(gconf, gconf-2.0)
|
||||
@ -18,10 +17,6 @@ fi
|
||||
|
||||
SMB_EXT_LIB_FROM_PKGCONFIG(gtk, [glib-2.0 gtk+-2.0])
|
||||
|
||||
if test t$SMB_EXT_LIB_ENABLE_gtk = tYES; then
|
||||
SMB_BINARY_ENABLE(gregedit, YES)
|
||||
fi
|
||||
|
||||
SMB_MODULE_MK(registry_nt4, REGISTRY, STATIC, lib/registry/config.mk)
|
||||
SMB_MODULE_MK(registry_w95, REGISTRY, STATIC, lib/registry/config.mk)
|
||||
SMB_MODULE_MK(registry_dir, REGISTRY, STATIC, lib/registry/config.mk)
|
||||
@ -35,7 +30,6 @@ SMB_BINARY_MK(regdiff, lib/registry/config.mk)
|
||||
SMB_BINARY_MK(regpatch, lib/registry/config.mk)
|
||||
SMB_BINARY_MK(regshell, lib/registry/config.mk)
|
||||
SMB_BINARY_MK(regtree, lib/registry/config.mk)
|
||||
SMB_BINARY_MK(gregedit, lib/registry/config.mk)
|
||||
|
||||
if test x"$experimental" = x"yes"; then
|
||||
SMB_LIBRARY_ENABLE(libwinregistry, YES)
|
||||
|
@ -118,15 +118,3 @@ REQUIRED_SUBSYSTEMS = \
|
||||
CONFIG LIBCMDLINE REGISTRY
|
||||
# End BINARY regtree
|
||||
################################################
|
||||
|
||||
################################################
|
||||
# Start BINARY gregedit
|
||||
[BINARY::gregedit]
|
||||
OBJ_FILES= \
|
||||
lib/registry/tools/gregedit.o
|
||||
REQUIRED_LIBRARIES = \
|
||||
gtk
|
||||
REQUIRED_SUBSYSTEMS = \
|
||||
CONFIG LIBCMDLINE REGISTRY
|
||||
# End BINARY gregedit
|
||||
################################################
|
||||
|
Loading…
Reference in New Issue
Block a user