From 2251186b5bd164f1ad7707a428d0b6c91297f573 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Feb 2005 11:57:43 +0000 Subject: r5409: - add a gtk events plugin - this is used in our gtk apps - make the main() functions of the gtk apps look more simular (we need to get rid of the globals in gregedit!) metze (This used to be commit 1051f9b32f4a5c69a1a6928e6849c8ada047032e) --- source4/gtk/tools/gepdump.c | 11 +++++----- source4/gtk/tools/gregedit.c | 48 +++++++++++++++++++++---------------------- source4/gtk/tools/gwcrontab.c | 4 ++-- source4/gtk/tools/gwsam.c | 5 ++--- 4 files changed, 33 insertions(+), 35 deletions(-) (limited to 'source4/gtk/tools') diff --git a/source4/gtk/tools/gepdump.c b/source4/gtk/tools/gepdump.c index 88cd9ff8b7..d445dd63cb 100644 --- a/source4/gtk/tools/gepdump.c +++ b/source4/gtk/tools/gepdump.c @@ -417,15 +417,16 @@ static GtkWidget* create_mainwindow (void) } -int main(int argc, char **argv) + int main(int argc, char **argv) { - gtk_init(&argc, &argv); gepdump_init_subsystems; lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - setup_logging("gepdump", True); + setup_logging(argv[0], DEBUG_STDERR); + + gtk_init(&argc, &argv); mainwin = create_mainwindow(); gtk_widget_show_all(mainwin); - gtk_main(); - return 0; + + return gtk_event_loop(); } diff --git a/source4/gtk/tools/gregedit.c b/source4/gtk/tools/gregedit.c index 918ebd6945..9d0a87f2a7 100644 --- a/source4/gtk/tools/gregedit.c +++ b/source4/gtk/tools/gregedit.c @@ -660,7 +660,7 @@ gboolean on_key_activate(GtkTreeSelection *selection, return TRUE; } -static GtkWidget* create_mainwin (void) +static GtkWidget* create_mainwindow(void) { GtkWidget *vbox1; GtkWidget *menubar; @@ -955,43 +955,41 @@ static GtkWidget* create_savefilewin (void) return savefilewin; } +static int gregedit_load_defaults(void) +{ + WERROR error = reg_open_local(®istry); + if(!W_ERROR_IS_OK(error)) { + gtk_show_werror(mainwin, error); + return -1; + } + registry_load_root(); + + return 0; +} + int main(int argc, char *argv[]) { - poptContext pc; - WERROR error; - int opt; - struct poptOption long_options[] = { - POPT_AUTOHELP - POPT_TABLEEND - }; + int ret; gregedit_init_subsystems; - lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); + setup_logging(argv[0], DEBUG_STDERR); - gtk_init (&argc, &argv); mem_ctx = talloc_init("gregedit"); - pc = poptGetContext(argv[0], argc, (const char **) argv, long_options,0); + gtk_init(&argc, &argv); + mainwin = create_mainwindow(); + gtk_widget_show_all(mainwin); - while((opt = poptGetNextOpt(pc)) != -1) { - } + ret = gregedit_load_defaults(); + if (ret != 0) goto failed; - error = reg_open_local(®istry); - if(!W_ERROR_IS_OK(error)) { - gtk_show_werror(mainwin, error); - return -1; - } - mainwin = create_mainwin (); - registry_load_root(); - - gtk_widget_show_all (mainwin); - - gtk_main (); + ret = gtk_event_loop(); +failed: talloc_free(mem_ctx); - return 0; + return ret; } diff --git a/source4/gtk/tools/gwcrontab.c b/source4/gtk/tools/gwcrontab.c index 580bbc2ae3..69ef2d7965 100644 --- a/source4/gtk/tools/gwcrontab.c +++ b/source4/gtk/tools/gwcrontab.c @@ -501,11 +501,11 @@ static GtkWidget*create_new_job_dialog (void) gwcrontab_init_subsystems; lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); + setup_logging(argv[0], DEBUG_STDERR); gtk_init(&argc, &argv); mainwin = create_mainwindow(); gtk_widget_show_all(mainwin); - gtk_main(); - return 0; + return gtk_event_loop(); } diff --git a/source4/gtk/tools/gwsam.c b/source4/gtk/tools/gwsam.c index 7d9abde3d3..878440527e 100644 --- a/source4/gtk/tools/gwsam.c +++ b/source4/gtk/tools/gwsam.c @@ -420,13 +420,12 @@ create_mainwindow (void) gwsam_init_subsystems; lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - setup_logging("gwsam", True); + setup_logging(argv[0], DEBUG_STDERR); gtk_init(&argc, &argv); mainwin = create_mainwindow(); connect_sam(); gtk_widget_show_all(mainwin); - gtk_main(); - return 0; + return gtk_event_loop(); } -- cgit