Implementing plugins in the GTK frontend
Hi
as the GTK frontend still contains a couple of hardcoded special
question handlers, i tought it was time to move them into appropriate
plugins.
I've red doc/plugin.txt and did everything as explained, but still can't
make the plugins work in the d-i: could someone help me in understanding
why the plugins are not dtected (actually, i placed plugin-xxx.so inside
/usr/lib/cdebconf/frontend/gtk) ?
If you have troubles with the attached patch, you can also get it from
https://debian.polito.it/downloads/gtk_plugins_difflog.txt .
thanks
Attilio
ps DEBCONF_DEBUG=5 no longer works: has anything changed?
Index: plugin-choose-partition.c
===================================================================
--- plugin-choose-partition.c (revisione 0)
+++ plugin-choose-partition.c (revisione 0)
@@ -0,0 +1,179 @@
+/***********************************************************************
+ *
+ * cdebconf - An implementation of the Debian Configuration Management
+ * System
+ *
+ * File: plugin-choose-partition.c
+ *
+ * Description: gtk plugin for cdebconf
+ *
+ * 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 "cdebconf_gtk.h"
+
+bool gtk_handler_choose_partition_callback (GtkTreeSelection
*selection, GtkTreeModel *model, GtkTreePath *path, gboolean
path_currently_selected, struct frontend_question_data *data)
+{
+ struct question *q = data->q;
+ char **choices, **choices_translated;
+ int i, count;
+ int *tindex = NULL;
+ const gchar *indices = q_get_indices(q);
+ gchar *name;
+ GtkTreeIter iter;
+
+ /* INFO(INFO_DEBUG, "GTK_DI -
gtk_handler_choose_partition_callback() called"); */
+
+ count = strgetargc(q_get_choices_vals(q));
+ if (count <= 0)
+ return FALSE; /* DC_NOTOK */;
+ choices = malloc(sizeof(char *) * count);
+ choices_translated = malloc(sizeof(char *) * count);
+ tindex = malloc(sizeof(int) * count);
+
+ if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q),
indices, choices, choices_translated, tindex, count) != count)
+ return FALSE;/* DC_NOTOK */;
+
+ if (gtk_tree_model_get_iter(model, &iter, path))
+ {
+ gtk_tree_model_get(model, &iter, SELECT_COL_NAME, &name, -1);
+ if (!path_currently_selected)
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (strcmp(name, choices_translated[i]) == 0)
+ {
+ /* INFO(INFO_DEBUG, "GTK_DI -
gtk_handler_choose_partition_callback(): %s is going to be selected
called", name); */
+ question_setvalue(q, choices[tindex[i]]);
+ }
+ free(choices[tindex[i]]);
+ free(choices_translated[i]);
+ }
+ }
+ }
+
+ g_free(name);
+ free(choices);
+ free(choices_translated);
+ free(tindex);
+
+return TRUE;
+}
+
+static int gtk_handler_choose_partition(struct frontend *obj, struct
question *q, GtkWidget *qbox)
+{
+ char **choices, **choices_translated;
+ int i, count;
+ struct frontend_question_data *data;
+ const char *defval = question_getvalue(q, "");
+ int *tindex = NULL;
+ const gchar *indices = q_get_indices(q);
+ GtkWidget *hpadbox, *vpadbox, *description_box;
+
+ GtkTreeModel *model;
+ GtkTreeStore *store;
+ GtkTreeIter iter, child;
+ GtkWidget *view, *scroll, *frame;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ INFO(INFO_DEBUG, "GTK_DI - gtk_handler_choose_partition() called");
+
+ data = NEW(struct frontend_question_data);
+ data->obj = obj;
+ data->q = q;
+
+ count = strgetargc(q_get_choices_vals(q));
+ if (count <= 0)
+ return DC_NOTOK;
+ choices = malloc(sizeof(char *) * count);
+ choices_translated = malloc(sizeof(char *) * count);
+ tindex = malloc(sizeof(int) * count);
+ if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q),
indices, choices, choices_translated, tindex, count) != count)
+ return DC_NOTOK;
+
+ view = gtk_tree_view_new ();
+ gtk_tree_view_set_headers_visible ( GTK_TREE_VIEW (view), FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-1, q_get_description(q), renderer, "text", SELECT_COL_NAME, NULL);
+ store = gtk_tree_store_new (SELECT_NUM_COLS, G_TYPE_STRING,
G_TYPE_UINT);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ gtk_tree_selection_set_select_function(selection,
(GtkTreeSelectionFunc) gtk_handler_choose_partition_callback, data, NULL);
+ g_signal_connect (G_OBJECT(view), "destroy", G_CALLBACK
(free_description_data), data);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW(view), TRUE);
+ model = GTK_TREE_MODEL( store );
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
+ g_object_unref (model);
+
+ for (i = 0; i < count; i++)
+ {
+ if( strstr(choices_translated[i]," ")!=NULL )
+ { /* child */
+ gtk_tree_store_append (store, &child, &iter);
+ gtk_tree_store_set (store, &child, SELECT_COL_NAME,
choices_translated[i], -1);
+
+ path = gtk_tree_model_get_path(model, &iter);
+ if (defval && strcmp(choices[tindex[i]], defval) == 0)
+ {
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view),
path, NULL, FALSE, 0.5, 0);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW(view), path,
NULL, FALSE);
+ }
+ path = gtk_tree_model_get_path(model, &iter);
+ gtk_tree_view_expand_row (GTK_TREE_VIEW(view), path, TRUE);
+ gtk_tree_path_free (path);
+ }
+ free(choices[tindex[i]]);
+ }
+
+ free(choices);
+ free(choices_translated);
+ free(tindex);
+
+ scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(scroll), view);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ description_box = display_descriptions(q, obj);
+
+ vpadbox = gtk_vbox_new (FALSE, DEFAULT_PADDING);
+ gtk_box_pack_start (GTK_BOX(vpadbox), description_box, FALSE,
FALSE, 0);
+ frame = gtk_frame_new(NULL);
+ gtk_container_add(GTK_CONTAINER(frame), scroll);
+ gtk_box_pack_start (GTK_BOX(vpadbox), frame, TRUE, TRUE, 0);
+ hpadbox = gtk_hbox_new (FALSE, DEFAULT_PADDING);
+ gtk_box_pack_start (GTK_BOX(hpadbox), vpadbox, TRUE, TRUE,
QUESTIONBOX_HPADDING);
+ gtk_box_pack_start(GTK_BOX(qbox), hpadbox, TRUE, TRUE,
QUESTIONBOX_VPADDING);
+
+ gtk_widget_grab_focus(view);
+
+ return DC_OK;
+}
Index: gtk.c
===================================================================
--- gtk.c (revisione 34589)
+++ gtk.c (copia locale)
@@ -1044,141 +1044,6 @@
return DC_OK;
}
-/* some SELECT questions like "countrychooser/country-name" are
- * better displayed with a tree rather than a list and this question
- * handler is meant for this purpose
- */
-static int gtkhandler_select_treeview_store(struct frontend *obj,
struct question *q, GtkWidget *qbox)
-{
- char **choices, **choices_translated;
- int i, count;
- struct frontend_question_data *data;
- const char *defval = question_getvalue(q, "");
- int *tindex = NULL;
- const gchar *indices = q_get_indices(q);
- GtkWidget *hpadbox, *vpadbox, *description_box;
-
- GtkTreeModel *model;
- GtkTreeStore *store;
- GtkTreeIter iter, child;
- GtkWidget *view, *scroll, *frame;
- GtkCellRenderer *renderer;
- GtkTreeSelection *selection;
- GtkTreePath *path;
-
- /* INFO(INFO_DEBUG, "GTK_DI - gtkhandler_select_treeview_store()
called"); */
-
- data = NEW(struct frontend_question_data);
- data->obj = obj;
- data->q = q;
-
- count = strgetargc(q_get_choices_vals(q));
- if (count <= 0)
- return DC_NOTOK;
- choices = malloc(sizeof(char *) * count);
- choices_translated = malloc(sizeof(char *) * count);
- tindex = malloc(sizeof(int) * count);
- if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q),
indices, choices, choices_translated, tindex, count) != count)
- return DC_NOTOK;
-
- view = gtk_tree_view_new ();
- gtk_tree_view_set_headers_visible ( GTK_TREE_VIEW (view), FALSE);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-1, q_get_description(q), renderer, "text", SELECT_COL_NAME, NULL);
- store = gtk_tree_store_new (SELECT_NUM_COLS, G_TYPE_STRING,
G_TYPE_UINT);
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- gtk_tree_selection_set_select_function(selection,
(GtkTreeSelectionFunc) select_treeview_callback, data, NULL);
- g_signal_connect (G_OBJECT(view), "destroy", G_CALLBACK
(free_description_data), data);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW(view), TRUE);
- model = GTK_TREE_MODEL( store );
- gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
- g_object_unref (model);
-
- for (i = 0; i < count; i++)
- {
-
- if(strcmp(q->tag, "countrychooser/country-name") == 0 )
- {
- if( ((choices_translated[i][0]=='-') &&
(choices_translated[i][1]=='-')) )
- { /* father */
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set (store, &iter, SELECT_COL_NAME,
choices_translated[i], -1);
- }
- else
- { /* child */
- gtk_tree_store_append (store, &child, &iter);
- gtk_tree_store_set (store, &child, SELECT_COL_NAME,
choices_translated[i], -1);
-
- if (defval && strcmp(choices[tindex[i]], defval) == 0)
- {
- path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view),
path, NULL, FALSE, 0.5, 0);
- gtk_tree_view_expand_row (GTK_TREE_VIEW(view),
path, TRUE);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW(view),
path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
- }
- }
- else if(strcmp(q->tag, "partman/choose_partition") == 0 )
- {
- if( strstr(choices_translated[i]," ")!=NULL )
- { /* child */
- gtk_tree_store_append (store, &child, &iter);
- gtk_tree_store_set (store, &child, SELECT_COL_NAME,
choices_translated[i], -1);
-
- path = gtk_tree_model_get_path(model, &iter);
- if (defval && strcmp(choices[tindex[i]], defval) == 0)
- {
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view),
path, NULL, FALSE, 0.5, 0);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW(view),
path, NULL, FALSE);
- }
- path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_view_expand_row (GTK_TREE_VIEW(view), path, TRUE);
- gtk_tree_path_free (path);
- }
- else
- { /* father */
- gtk_tree_store_append (store, &iter,NULL);
- gtk_tree_store_set (store, &iter, SELECT_COL_NAME,
choices_translated[i], -1);
- if (defval && strcmp(choices[tindex[i]], defval) == 0)
- {
- path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view),
path, NULL, FALSE, 0.5, 0);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW(view),
path, NULL, FALSE);
- gtk_tree_path_free (path);
- }
- }
- }
- free(choices[tindex[i]]);
- }
-
- free(choices);
- free(choices_translated);
- free(tindex);
-
- scroll = gtk_scrolled_window_new(NULL, NULL);
- gtk_container_add(GTK_CONTAINER(scroll), view);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
- description_box = display_descriptions(q, obj);
-
- vpadbox = gtk_vbox_new (FALSE, DEFAULT_PADDING);
- gtk_box_pack_start (GTK_BOX(vpadbox), description_box, FALSE,
FALSE, 0);
- frame = gtk_frame_new(NULL);
- gtk_container_add(GTK_CONTAINER(frame), scroll);
- gtk_box_pack_start (GTK_BOX(vpadbox), frame, TRUE, TRUE, 0);
- hpadbox = gtk_hbox_new (FALSE, DEFAULT_PADDING);
- gtk_box_pack_start (GTK_BOX(hpadbox), vpadbox, TRUE, TRUE,
QUESTIONBOX_HPADDING);
- gtk_box_pack_start(GTK_BOX(qbox), hpadbox, TRUE, TRUE,
QUESTIONBOX_VPADDING);
-
- gtk_widget_grab_focus(view);
-
- return DC_OK;
-}
-
static int gtkhandler_select_multiple(struct frontend *obj, struct
question *q, GtkWidget *qbox)
{
GtkWidget *description_box, *combo, *hpadbox, *vpadbox;
@@ -1247,14 +1112,8 @@
static int gtkhandler_select(struct frontend *obj, struct question *q,
GtkWidget *qbox)
{
-
if (q->prev == NULL && q->next == NULL)
- {
- if ( (strcmp(q->tag, "countrychooser/country-name") == 0) ||
(strcmp(q->tag, "partman/choose_partition") == 0) )
- return gtkhandler_select_treeview_store(obj, q, qbox);
- else
- return gtkhandler_select_treeview_list(obj, q, qbox);
- }
+ return gtkhandler_select_treeview_list(obj, q, qbox);
else
return gtkhandler_select_multiple(obj, q, qbox);
}
Index: Makefile
===================================================================
--- Makefile (revisione 34589)
+++ Makefile (copia locale)
@@ -1,8 +1,8 @@
MODULE=gtk
-SOBJ=gtk.so
-OBJS=gtk.opic
+SOBJ=gtk.so plugin-country-name.so plugin-choose-partition.so
+OBJS=gtk.opic plugin-choose-partition.opic
+
MODCFLAGS=`pkg-config --cflags gtk+-directfb-2.0`
-
MODLDFLAGS=`pkg-config --libs gtk+-directfb-2.0`
include ../modules.mak
Index: cdebconf_gtk.h
===================================================================
--- cdebconf_gtk.h (revisione 34589)
+++ cdebconf_gtk.h (copia locale)
@@ -98,3 +98,5 @@
via callbacks. Can be used as a callback for the destroy signal of
a widget associated
to the question.*/
void free_description_data( GtkObject *obj, struct
frontend_question_data* data );
+
+GtkWidget* display_descriptions(struct question *q, struct frontend *obj);
Index: plugin-country-name.c
===================================================================
--- plugin-country-name.c (revisione 0)
+++ plugin-country-name.c (revisione 0)
@@ -0,0 +1,183 @@
+/***********************************************************************
+ *
+ * cdebconf - An implementation of the Debian Configuration Management
+ * System
+ *
+ * File: plugin-country-name.c
+ *
+ * Description: gtk plugin for cdebconf
+ *
+ * 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 "cdebconf_gtk.h"
+
+bool gtk_handler_country_name_callback (GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreePath *path, gboolean
path_currently_selected, struct frontend_question_data *data)
+{
+ struct question *q = data->q;
+ char **choices, **choices_translated;
+ int i, count;
+ int *tindex = NULL;
+ const gchar *indices = q_get_indices(q);
+ gchar *name;
+ GtkTreeIter iter;
+
+ /* INFO(INFO_DEBUG, "GTK_DI - gtk_handler_country_name_callback()
called"); */
+
+ count = strgetargc(q_get_choices_vals(q));
+ if (count <= 0)
+ return FALSE; /* DC_NOTOK */;
+ choices = malloc(sizeof(char *) * count);
+ choices_translated = malloc(sizeof(char *) * count);
+ tindex = malloc(sizeof(int) * count);
+
+ if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q),
indices, choices, choices_translated, tindex, count) != count)
+ return FALSE;/* DC_NOTOK */;
+
+ if (gtk_tree_model_get_iter(model, &iter, path))
+ {
+ gtk_tree_model_get(model, &iter, SELECT_COL_NAME, &name, -1);
+ if (!path_currently_selected)
+ {
+ for (i = 0; i < count; i++)
+ {
+ if (strcmp(name, choices_translated[i]) == 0)
+ {
+ /* INFO(INFO_DEBUG, "GTK_DI -
gtk_handler_country_name_callback(): %s is going to be selected
called", name); */
+ question_setvalue(q, choices[tindex[i]]);
+ }
+ free(choices[tindex[i]]);
+ free(choices_translated[i]);
+ }
+ }
+ }
+
+ g_free(name);
+ free(choices);
+ free(choices_translated);
+ free(tindex);
+
+return TRUE;
+}
+
+static int gtk_handler_country_name(struct frontend *obj, struct
question *q, GtkWidget *qbox)
+{
+ char **choices, **choices_translated;
+ int i, count;
+ struct frontend_question_data *data;
+ const char *defval = question_getvalue(q, "");
+ int *tindex = NULL;
+ const gchar *indices = q_get_indices(q);
+ GtkWidget *hpadbox, *vpadbox, *description_box;
+
+ GtkTreeModel *model;
+ GtkTreeStore *store;
+ GtkTreeIter iter, child;
+ GtkWidget *view, *scroll, *frame;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+ GtkTreePath *path;
+
+ INFO(INFO_DEBUG, "GTK_DI - gtk_handler_country_name() called");
+
+ data = NEW(struct frontend_question_data);
+ data->obj = obj;
+ data->q = q;
+
+ count = strgetargc(q_get_choices_vals(q));
+ if (count <= 0)
+ return DC_NOTOK;
+ choices = malloc(sizeof(char *) * count);
+ choices_translated = malloc(sizeof(char *) * count);
+ tindex = malloc(sizeof(int) * count);
+ if (strchoicesplitsort(q_get_choices_vals(q), q_get_choices(q),
indices, choices, choices_translated, tindex, count) != count)
+ return DC_NOTOK;
+
+ view = gtk_tree_view_new ();
+ gtk_tree_view_set_headers_visible ( GTK_TREE_VIEW (view), FALSE);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-1, q_get_description(q), renderer, "text", SELECT_COL_NAME, NULL);
+ store = gtk_tree_store_new (SELECT_NUM_COLS, G_TYPE_STRING,
G_TYPE_UINT);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ gtk_tree_selection_set_select_function(selection,
(GtkTreeSelectionFunc) gtk_handler_country_name_callback, data, NULL);
+ g_signal_connect (G_OBJECT(view), "destroy", G_CALLBACK
(free_description_data), data);
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW(view), TRUE);
+ model = GTK_TREE_MODEL( store );
+ gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
+ g_object_unref (model);
+
+ for (i = 0; i < count; i++)
+ {
+ if( ((choices_translated[i][0]=='-') &&
(choices_translated[i][1]=='-')) )
+ { /* father */
+ gtk_tree_store_append (store, &iter,NULL);
+ gtk_tree_store_set (store, &iter, SELECT_COL_NAME,
choices_translated[i], -1);
+ }
+ else
+ { /* child */
+ gtk_tree_store_append (store, &child, &iter);
+ gtk_tree_store_set (store, &child, SELECT_COL_NAME,
choices_translated[i], -1);
+
+ if (defval && strcmp(choices[tindex[i]], defval) == 0)
+ {
+ path = gtk_tree_model_get_path(model, &iter);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view),
path, NULL, FALSE, 0.5, 0);
+ gtk_tree_view_expand_row (GTK_TREE_VIEW(view), path, TRUE);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW(view), path,
NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+ }
+ free(choices[tindex[i]]);
+ }
+
+ free(choices);
+ free(choices_translated);
+ free(tindex);
+
+ scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(scroll), view);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ description_box = display_descriptions(q, obj);
+
+ vpadbox = gtk_vbox_new (FALSE, DEFAULT_PADDING);
+ gtk_box_pack_start (GTK_BOX(vpadbox), description_box, FALSE,
FALSE, 0);
+ frame = gtk_frame_new(NULL);
+ gtk_container_add(GTK_CONTAINER(frame), scroll);
+ gtk_box_pack_start (GTK_BOX(vpadbox), frame, TRUE, TRUE, 0);
+ hpadbox = gtk_hbox_new (FALSE, DEFAULT_PADDING);
+ gtk_box_pack_start (GTK_BOX(hpadbox), vpadbox, TRUE, TRUE,
QUESTIONBOX_HPADDING);
+ gtk_box_pack_start(GTK_BOX(qbox), hpadbox, TRUE, TRUE,
QUESTIONBOX_VPADDING);
+
+ gtk_widget_grab_focus(view);
+
+ return DC_OK;
+}
Reply to: