Hello. Talking with moshez and walters on #debian-boot last night, I
discovered that the cdebconf gtk frontend is still on the todo list.

I'll be out of town this weekend, away from net access, and I'm
looking for a project to work on.

So, I began a gtk frontend for cdebconf. The beginning is attached. It
sort of compiles with this line:

gcc -Wall -g gtk.c -o gtk.so `pkg-config --cflags gtk+-2.0`
\`pkg-config --libs gtk+-2.0`
-I../../.. -I../../../../debian/build/src

well, it compiles but doesn't link with the debconf stuff. I'll work on that.

Anyway, I just wanted to get some feedback on this and see if it's
feasible, if this is a decent beginning, if anyone else is working on
it.

If this is a bad idea, I'll go back to the partitioning stuff, but
there seems to be a lot of stuff done already there.

Anyway, all this frontend has so far is a boolean handler, the rest is
a copy of the text handler. I'll poke around the cdebconf tests dir
tomorrow, its late.

Also, what are people's thoughts on using complete debs, not udebs for
X and gtk? it seems like an X based installer on a cd doesn''t have the
same space requirements, and d-i should be able to use debs as well as
udebs...

thanks
 
  michael

-- 
michael cardenas | lead software engineer | lindows.com | hyperpoem.net

"When making your choice in life, do not neglect to live."
- Samuel Johnson
diff -ruNP frontend/gtk/CVS/Entries frontend.orig/gtk/CVS/Entries
--- frontend/gtk/CVS/Entries    Wed Aug 28 23:24:55 2002
+++ frontend.orig/gtk/CVS/Entries       Wed Dec 31 16:00:00 1969
@@ -1,3 +0,0 @@
-/Makefile/1.4/Tue Jul  9 05:25:05 2002//
-/text.c/1.13/Wed Aug  7 16:19:51 2002//
-D
diff -ruNP frontend/gtk/CVS/Repository frontend.orig/gtk/CVS/Repository
--- frontend/gtk/CVS/Repository Wed Aug 28 23:24:55 2002
+++ frontend.orig/gtk/CVS/Repository    Wed Dec 31 16:00:00 1969
@@ -1 +0,0 @@
-debian-installer/tools/cdebconf/src/modules/frontend/text
diff -ruNP frontend/gtk/CVS/Root frontend.orig/gtk/CVS/Root
--- frontend/gtk/CVS/Root       Wed Aug 28 23:24:55 2002
+++ frontend.orig/gtk/CVS/Root  Wed Dec 31 16:00:00 1969
@@ -1 +0,0 @@
-:pserver:[EMAIL PROTECTED]:/cvs/debian-boot
diff -ruNP frontend/gtk/Makefile frontend.orig/gtk/Makefile
--- frontend/gtk/Makefile       Wed Aug 28 23:26:16 2002
+++ frontend.orig/gtk/Makefile  Wed Dec 31 16:00:00 1969
@@ -1,5 +0,0 @@
-MODULE=gtk
-SOBJ=gtk.so
-OBJS=gtk.opic
-
-include ../modules.mak
diff -ruNP frontend/gtk/gtk.c frontend.orig/gtk/gtk.c
--- frontend/gtk/gtk.c  Thu Aug 29 00:45:06 2002
+++ frontend.orig/gtk/gtk.c     Wed Dec 31 16:00:00 1969
@@ -1,599 +0,0 @@
-/***********************************************************************
- *
- * cdebconf - An implementation of the Debian Configuration Management
- *            System
- *
- * File: gtk.c
- *
- * Description: gtk UI for cdebconf
- * Some notes on the implementation - optimistic at best. 
- *
- * $Id: text.c,v 1.13 2002/08/07 16:19:51 tfheen Exp $
- *
- * cdebconf is (c) 2000-2001 Randolph Chung and others under the following
- * license.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- ***********************************************************************/
-#include "common.h"
-#include "template.h"
-#include "question.h"
-#include "frontend.h"
-#include "database.h"
-#include "strutl.h"
-
-#include <ctype.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <gtk/gtk.h>
-
-#ifndef _
-#define _(x) x
-#endif
-
-int gBool;
-
-/*
- * Function: check_callback
- * Input: none
- * Output: none
- * Description: continue to next question 
- * Assumptions: 
- */
-void check_callback( GtkWidget *widget,
-            gpointer   data )
-{
-    {
-      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) 
-       {
-         /* If control reaches here, the toggle button is down */
-         gBool = 1;
-    
-       } else {
-    
-         /* If control reaches here, the toggle button is up */
-         gBool = 0;
-       }
-    }
-}
-
-
-/*
- * Function: next
- * Input: none
- * Output: none
- * Description: continue to next question 
- * Assumptions: 
- */
-void next( GtkWidget *widget,
-            gpointer   data )
-{
-  g_print ("next\n");
-}
-
-/*
- * Function: back
- * Input: none
- * Output: none
- * Description: go back to previous question
- * Assumptions: 
- */
-void back( GtkWidget *widget,
-            gpointer   data )
-{
-  g_print ("back\n");
-}
-
-/*
- * Function: delete_event
- * Input: none
- * Output: none
- * Description: callback function for delete event
- * Assumptions: 
- */
-
-gint delete_event( GtkWidget *widget,
-                   GdkEvent  *event,
-                  gpointer   data )
-{
-  /* If you return FALSE in the "delete_event" signal handler,
-   * GTK will emit the "destroy" signal. Returning TRUE means
-   * you don't want the window to be destroyed.
-   * This is useful for popping up 'are you sure you want to quit?'
-   * type dialogs. */
-
-  g_print ("delete event occurred\n");
-
-  /* Change TRUE to FALSE and the main window will be destroyed with
-   * a "delete_event". */
-
-  return TRUE;
-}
-
-/*
- * Function: destroy
- * Input: none
- * Output: none
- * Description: callback function for close button
- * Assumptions: 
- */
-void destroy( GtkWidget *widget,
-              gpointer   data )
-{
-  gtk_main_quit ();
-}
-
-/*
- * Function: getwidth
- * Input: none
- * Output: int - width of screen
- * Description: get the width of the current terminal
- * Assumptions: doesn't handle resizing; caches value on first call
- */
-static const int getwidth(void)
-{
-       static int res = 80;
-       static int inited = 0;
-       int fd;
-       struct winsize ws;
-
-       if (inited == 0)
-       {
-               inited = 1;
-               if ((fd = open("/dev/tty", O_RDONLY)) > 0)
-               {
-                       if (ioctl(fd, TIOCGWINSZ, &ws) == 0)
-                               res = ws.ws_col;
-                       close(fd);
-               }
-       }
-       return res;
-}
-
-/*
- * Function: wrap_print
- * Input: const char *str - string to display
- * Output: none
- * Description: prints a string to the screen with word wrapping 
- * Assumptions: string fits in <500 lines
- */
-static void wrap_print(const char *str)
-{
-       /* Simple greedy line-wrapper */
-       int i, lc;
-       char *lines[500];
-
-       lc = strwrap(str, getwidth() - 1, lines, DIM(lines));
-
-       for (i = 0; i < lc; i++)
-       {
-               printf("%s\n", lines[i]);
-               DELETE(lines[i]);
-       }
-}
-
-/*
- * Function: texthandler_displaydesc
- * Input: struct frontend *obj - UI object
- *        struct question *q - question for which to display the description
- * Output: none
- * Description: displays the description for a given question 
- * Assumptions: none
- *
-static void texthandler_displaydesc(struct frontend *obj, struct question *q) 
-{
-       wrap_print(question_description(q));
-       wrap_print(question_extended_description(q));
-}*/
-
-/*
- * Function: gtkhandler_boolean
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the boolean question type
- * Assumptions: none
- */
-static int gtkhandler_boolean(struct frontend *obj, struct question *q)
-{
-       char buf[30];
-       int ans = -1;
-       int def = -1;
-       const char *defval;
-       GtkWidget *window;
-       GtkWidget *nextButton, *backButton, *boolButton;
-
-       defval = question_defaultval(q);
-       if (defval)
-       {
-               if (strcmp(defval, "true") == 0)
-                       def = 1;
-               else 
-                       def = 0;
-       }
-
-       //create the window for the question
-       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
-       //setup the window with the appropriate buttons for this question
-       g_signal_connect (G_OBJECT (window), "delete_event",
-                         G_CALLBACK (delete_event), NULL);
-       g_signal_connect (G_OBJECT (window), "destroy",
-                         G_CALLBACK (destroy), NULL);
-       gtk_container_set_border_width (GTK_CONTAINER (window), 10);
-       nextButton = gtk_button_new_with_label ("Next");
-       backButton = gtk_button_new_with_label ("Back");
-       g_signal_connect (G_OBJECT (nextButton), "clicked",
-                         G_CALLBACK (next), NULL);
-       g_signal_connect (G_OBJECT (backButton), "clicked",
-                         G_CALLBACK (back), NULL);
-       gtk_container_add (GTK_CONTAINER (window), nextButton);
-       gtk_container_add (GTK_CONTAINER (window), backButton);
-
-       //add a checkbox for the boolean, we wouldn't really want a whole dialog for 
one boolean,
-       // but this is a start
-
-       boolButton = gtk_check_button_new_with_label ( (gchar *)obj->title );
-       g_signal_connect (G_OBJECT (boolButton), "clicked",
-                         G_CALLBACK (check_callback), NULL);
-       gtk_container_add (GTK_CONTAINER (window), boolButton);
-
-       //show the dialog containing the question
-       gtk_widget_show (nextButton);
-       gtk_widget_show (backButton);
-       gtk_widget_show (boolButton);
-       gtk_widget_show (window);
-       gtk_main ();
-
-       if(gBool)
-         {
-           ans = 1;
-         }
-       else
-         {
-           ans = 0;
-         }
-
-       question_setvalue(q, (ans ? "true" : "false"));
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_multiselect
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the multiselect question type
- * Assumptions: none
- *
- * TODO: factor common code with select
- */
-static int texthandler_multiselect(struct frontend *obj, struct question *q)
-{
-       char *choices[100] = {0};
-       char *defaults[100] = {0};
-       char selected[100] = {0};
-       char answer[1024];
-       int i, j, count, dcount, choice;
-
-       count = strchoicesplit(question_choices(q), choices, DIM(choices));
-       dcount = strchoicesplit(question_defaultval(q), defaults, DIM(defaults));
-
-       if (dcount > 0)
-               for (i = 0; i < count; i++)
-                       for (j = 0; j < dcount; j++)
-                               if (strcmp(choices[i], defaults[j]) == 0)
-                                       selected[i] = 1;
-
-       while(1)
-       {
-               for (i = 0; i < count; i++)
-               {
-                       printf("%3d. %s%s\n", i+1, choices[i], 
-                               (selected[i] ? _(" (selected)") : ""));
-                       
-               }
-
-               printf(_("Prompt: 1 - %d, q to end> "), count);
-               fgets(answer, sizeof(answer), stdin);
-               if (answer[0] == 'q') break;
-
-               choice = atoi(answer);
-               if (choice > 0 && choice <= count)
-               {
-                       if (selected[choice-1] == 0) 
-                               selected[choice-1] = 1;
-                       else
-                               selected[choice-1] = 0;
-               }
-       }
-
-       answer[0] = 0;
-       for (i = 0; i < count; i++)
-       {
-               if (selected[i])
-               {
-                       if (answer[0] != 0)
-                               strvacat(answer, sizeof(answer), ", ");
-                       strvacat(answer, sizeof(answer), choices[i], NULL);
-               }
-               free(choices[i]);
-       }
-       for (i = 0; i < dcount; i++)
-               free(defaults[i]);
-       question_setvalue(q, answer);
-       
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_note
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the note question type
- * Assumptions: none
- */
-static int texthandler_note(struct frontend *obj, struct question *q)
-{
-       int c;
-       printf("[Press enter to continue]\n");
-       do { c = fgetc(stdin); } while (c != '\r' && c != '\n');
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_password
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the password question type
- * Assumptions: none
- *
- * TODO: this can be *MUCH* improved. no editing is possible right now
- */
-static int texthandler_password(struct frontend *obj, struct question *q)
-{
-       struct termios oldt, newt;
-       char passwd[256] = {0};
-       int i = 0, c;
-
-       tcgetattr(0, &oldt);
-       memcpy(&newt, &oldt, sizeof(struct termios));
-       cfmakeraw(&newt);
-       tcsetattr(0, TCSANOW, &newt);
-       while ((c = fgetc(stdin)) != EOF)
-       {
-               fputc('*', stdout);
-               passwd[i++] = (char)c;
-               if (c == '\r' || c == '\n') break;
-
-       }
-       printf("\n");
-       passwd[i] = 0;
-       tcsetattr(0, TCSANOW, &oldt);
-       question_setvalue(q, passwd);
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_select
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the select question type
- * Assumptions: none
- *
- * TODO: factor common code with multiselect
- */
-static int texthandler_select(struct frontend *obj, struct question *q)
-{
-       char *choices[100] = {0};
-       char *choices_translated[100] = {0};
-       char answer[10];
-       int i, count, choice = 1, def = -1;
-       const char *defval = question_defaultval(q);
-
-       count = strchoicesplit(question_choices(q), choices, DIM(choices));
-       strchoicesplit(question_choices_translated(q), choices_translated, 
DIM(choices_translated));
-        /* fprintf(stderr,"In texthandler_select, count is: %d\n", count);*/
-       if (count > 1)
-       {
-               if (defval != NULL)
-               {
-                       for (i = 0; i < count; i++)
-                               if (strcmp(choices[i], defval) == 0)
-                                       def = i + 1;
-               }
-
-               do
-               {
-                       for (i = 0; i < count; i++)
-                               printf("%3d. %s%s\n", i+1, choices_translated[i],
-                                       (def == i + 1 ? _(" (default)") : ""));
-
-                       printf(_("Prompt: 1 - %d> "), count);
-                       fgets(answer, sizeof(answer), stdin);
-                       if (answer[0] == '\n')
-                               choice = def;
-                       else
-                               choice = atoi(answer);
-               } while (choice <= 0 || choice > count);
-       }
-       /*      fprintf(stderr,"In %s, line: %d\n\tanswer: %s, choice[choice]: %s\n",
-               __FILE__,__LINE__,answer, choices[choice - 1]);*/
-       question_setvalue(q, choices[choice - 1]);
-       for (i = 0; i < count; i++) 
-       {
-               free(choices[i]);
-               free(choices_translated[i]);
-       }
-       
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_string
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the string question type
- * Assumptions: none
- */
-static int texthandler_string(struct frontend *obj, struct question *q)
-{
-       char buf[1024] = {0};
-       const char *defval = question_defaultval(q);
-       if (defval)
-               printf(_("[default = %s]"), defval);
-       printf("> "); fflush(stdout);
-       fgets(buf, sizeof(buf), stdin);
-       CHOMP(buf);
-       if (buf[0] == 0 && defval != 0)
-               question_setvalue(q, defval);
-       else
-               question_setvalue(q, buf);
-       return DC_OK;
-}
-
-/*
- * Function: texthandler_text
- * Input: struct frontend *obj - frontend object
- *        struct question *q - question to ask
- * Output: int - DC_OK, DC_NOTOK
- * Description: handler for the text question type
- * Assumptions: none
- */
-static int texthandler_text(struct frontend *obj, struct question *q)
-{
-       char *out = 0;
-       char buf[1024];
-       int sz = 1;
-
-       printf(_("Enter . on a line by itself when you are done\n"));
-       while (fgets(buf, sizeof(buf), stdin))
-       {
-               if (strcmp(buf, ".\n") == 0) break;
-               sz += strlen(buf);
-               out = realloc(out, sz);
-               memcpy(out + sz - strlen(buf) - 1, buf, strlen(buf));
-       }
-       out[sz-1] = 0;
-       question_setvalue(q, out);
-       free(out);
-       return DC_OK;
-}
-
-/* ----------------------------------------------------------------------- */
-struct question_handlers {
-       const char *type;
-       int (*handler)(struct frontend *obj, struct question *q);
-} question_handlers[] = {
-       { "boolean",    gtkhandler_boolean }
-       /*      { "multiselect", gtkhandler_multiselect },
-       { "note",       gtkhandler_note },
-       { "password",   gtkhandler_password },
-       { "select",     gtkhandler_select },
-       { "string",     gtkhandler_string },
-       { "text",       gtkhandler_text }*/
-};
-
-/*
- * Function: gtk_intitialize
- * Input: struct frontend *obj - frontend UI object
- *        struct configuration *cfg - configuration parameters
- * Output: int - DC_OK, DC_NOTOK
- * Description: initializes the gtk UI
- * Assumptions: none
- *
- */
-static int gtk_initialize(struct frontend *obj, struct configuration *conf)
-{
-       obj->interactive = 1;
-       //signal(SIGINT, SIG_IGN);
-
-       gtk_init (0, "cdebconf");
-
-       return DC_OK;
-}
-
-/*
- * Function: gtk_go
- * Input: struct frontend *obj - frontend object
- * Output: int - DC_OK, DC_NOTOK
- * Description: asks all pending questions
- * Assumptions: none
- */
-static int gtk_go(struct frontend *obj)
-{
-       struct question *q = obj->questions;
-       int i;
-       int ret;
-       /*      char *window_title;
-       int len;
-
-       //printf("%s\n\n", obj->title);
-
-       len = strlen(obj->title);
-       window_title = (char *)malloc(len+1);
-       strcpy(window_title, obj->title);
-       */
-
-       for (; q != 0; q = q->next)
-       {
-                struct template *t = obj->tdb->methods.get(obj->tdb, q->tag);
-                template_deref(q->template);
-                q->template = t;
-
-               for (i = 0; i < DIM(question_handlers); i++)
-                       if (strcmp(q->template->type, question_handlers[i].type) == 0)
-                       {
-
-                               //gtkhandler_displaydesc(obj, q);
-                               
-                               ret = question_handlers[i].handler(obj, q);
-                               if (ret == DC_OK)
-                                       obj->qdb->methods.set(obj->qdb, q);
-                               else
-                                       return ret;
-                               break;
-                       }
-       }
-
-       return DC_OK;
-}
-
-struct frontend_module debconf_frontend_module =
-{
-       initialize: gtk_initialize,
-       go: gtk_go,
-};

Attachment: msg21677/pgp00000.pgp
Description: PGP signature

Reply via email to