Re: GTK FE, hack to partman's main screen
Colin Watson wrote:
On Sat, Oct 29, 2005 at 09:30:29PM +0200, Attilio Fiandrotti wrote:
One thing in the wishlist for the GTK frontend was make it able to
display partitions as childs to disk drives in partman's main screen
("partman/choose_partition") using a GtkTreeView.
This should be done whitout having to touch partman or translated templates.
partman definitely *should* be touched for this; please implement this
there using a plugin, not in the generic cdebconf gtk frontend.
I've noticed there are a lot of questions inside the debian-installer
where a "Tree" display system is/would be useful, some examples
-countrychooser/country-name (type SELECT) : nations are displayed as
childs to continents.
Actually, continents are identified as fathers because they begin with
"---" and end with "---"
-"partman/choose_partition" (type SELECT): partitions are displayed as
childs to disks.
Partitions are identified as childs because they do contain a " " set
of characters
-localechooser/supported-locales (type MULTISELECT): xx_xx_abc coud be
displayed as child to a xx_yy to make the list shorter (it's now very long).
Note that i plan to write soon a new GtkTreeView-based question handler
for single MULTISELECT questions since the current one is very slow is
screen redrawing and hasn't native scrolling capabilities.
As you can see father/child parsing in SELECT questions is now done in a
non uniform way: i would propose to adopt an uniform syntax in SELECT or
MULTISELECT options writing to make child identification easier.
Every option that has to be displayed as child to another option should
end with a number of " " (SPACE) chars that indicated the level of
indentation it should be displayed with.
example: ("*" means "SPACE")
"World" <-root
"Europe*" <-1st level child
"Italy**" <-2nd level child
"France**" <-2nd level child
"USA*" <-1st level child
"Washington DC**" <-2nd level child
"California**" <-2nd level child
This would allow for multiple depth trees without having to create a new
TREE type of questions.
This way questions could be correctly diplayed also by the NEWT frontend
since having some more " " chars displayed at the end of the row
shouldn't bother the user.
Also this would require little modifications to translated options or no
mdifications at all.
This special handler for SELECT questions, capable of displaying them as
tree if needed, could be implemented as a plugin in order to keep the
gtk.so unhacked itself.
could this be a good idea?
attilio@attilaptop:~/svn_gtk/cdebconf/src/modules/frontend/gtk$ diff
gtk.c ~/cdebconf/cdebconf/src/modules/frontend/gtk/gtk.c10c10
Please use either 'diff -u' or 'svn diff'; the normal diff format is
hopeless for most purposes.
ok, here it is
ciao
attilio
attilio@attilaptop:~/svn_gtk/cdebconf/src/modules/frontend/gtk$ diff -u
gtk.c ~/cdebconf/cdebconf/src/modules/frontend/gtk/gtk.c
--- gtk.c 2005-10-28 09:56:32.000000000 +0200
+++ /home/attilio/cdebconf/cdebconf/src/modules/frontend/gtk/gtk.c
2005-10-29 20:58:15.000000000 +0200
@@ -7,7 +7,7 @@
*
* Description: gtk UI for cdebconf
*
- * $Id: gtk.c 31733 2005-10-28 07:50:07Z fiandro-guest $
+ * $Id: gtk.c 31569 2005-10-21 06:12:27Z fiandro-guest $
*
* cdebconf is (c) 2000-2001 Randolph Chung and others under the following
* license.
@@ -559,7 +559,7 @@
GtkWidget* display_descriptions(struct question *q)
{
GtkWidget *description_view, *ext_description_view;
- GtkWidget *returned_box;
+ GtkWidget *returned_box, *description_box, *icon_box, *icon_button;
GtkTextBuffer *description_buffer, *ext_description_buffer;
GdkColor color;
GtkTextIter start, end;
@@ -568,7 +568,9 @@
color.green = BACKGROUND_GREEN;
color.blue = BACKGROUND_BLUE;
- returned_box = gtk_vbox_new (FALSE, 0);
+ description_box = gtk_vbox_new (FALSE, 0);
+ icon_box = gtk_vbox_new (FALSE, 0);
+ returned_box = gtk_hbox_new (FALSE, 0);
/* here is created the question's extended description, but only
* if the question's extended description actually exists
@@ -593,7 +595,7 @@
*/
gtk_widget_modify_base(GTK_WIDGET(ext_description_view),
GTK_STATE_NORMAL, &color);
- gtk_box_pack_start(GTK_BOX (returned_box),
ext_description_view, FALSE, FALSE, 2);
+ gtk_box_pack_start(GTK_BOX (description_box),
ext_description_view, FALSE, FALSE, 2);
}
/* here is created the question's description */
@@ -610,8 +612,22 @@
gtk_text_buffer_apply_tag_by_name (description_buffer,
"italic", &start, &end);
gtk_widget_modify_base(GTK_WIDGET(description_view),
GTK_STATE_NORMAL, &color);
- gtk_box_pack_start(GTK_BOX (returned_box), description_view,
FALSE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX (description_box), description_view,
FALSE, FALSE, 3);
+ if( strcmp(q->template->type,"note") == 0 )
+ {
+ icon_button =
gtk_image_new_from_file("/usr/share/graphics/note_icon.png");
+ gtk_box_pack_start(GTK_BOX (icon_box), icon_button,
FALSE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX (returned_box), icon_box,
FALSE, FALSE, 3);
+ }
+ else if( strcmp(q->template->type,"error") == 0 )
+ {
+ icon_button =
gtk_image_new_from_file("/usr/share/graphics/warning_icon.png");
+ gtk_box_pack_start(GTK_BOX (icon_box), icon_button,
FALSE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX (returned_box), icon_box,
FALSE, FALSE, 3);
+ }
+
+ gtk_box_pack_start(GTK_BOX (returned_box), description_box,
TRUE, TRUE, 3);
return returned_box;
}
@@ -1003,24 +1019,52 @@
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, COL_NAME,
choices_translated[i], -1);
- }
- else
- { /* child */
- gtk_tree_store_append (store, &child, &iter);
- gtk_tree_store_set (store, &child, COL_NAME,
choices_translated[i], -1);
-
- if (defval && strcmp(choices[tindex[i]], defval) == 0)
- {
- gtk_tree_view_scroll_to_cell
(GTK_TREE_VIEW(view), gtk_tree_model_get_path(model,&child), NULL,
FALSE, 0.5, 0);
- gtk_tree_view_expand_row (GTK_TREE_VIEW(view),
gtk_tree_model_get_path(model,&iter), TRUE);
- gtk_tree_selection_select_iter
(selection, &child );
- }
+
+ 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,
COL_NAME, choices_translated[i], -1);
+ }
+ else
+ { /* child */
+ gtk_tree_store_append (store, &child,
&iter);
+ gtk_tree_store_set (store, &child,
COL_NAME, choices_translated[i], -1);
+
+ if (defval && strcmp(choices[tindex[i]], defval)
== 0)
+ {
+ gtk_tree_view_scroll_to_cell
(GTK_TREE_VIEW(view), gtk_tree_model_get_path(model,&child), NULL,
FALSE, 0.5, 0);
+ gtk_tree_view_expand_row
(GTK_TREE_VIEW(view), gtk_tree_model_get_path(model,&iter), TRUE);
+ gtk_tree_selection_select_iter
(selection, &child );
+ }
+ }
}
-
+ 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,
COL_NAME, choices_translated[i], -1);
+
+ if (defval && strcmp(choices[tindex[i]], defval)
== 0)
+ {
+ gtk_tree_view_scroll_to_cell
(GTK_TREE_VIEW(view), gtk_tree_model_get_path(model,&child), NULL,
FALSE, 0.5, 0);
+ gtk_tree_selection_select_iter
(selection, &child );
+ }
+ gtk_tree_view_expand_row (GTK_TREE_VIEW(view),
gtk_tree_model_get_path(model,&iter), TRUE);
+ }
+ else
+ { /* father */
+ gtk_tree_store_append (store, &iter,NULL);
+ gtk_tree_store_set (store, &iter,
COL_NAME, choices_translated[i], -1);
+ if (defval && strcmp(choices[tindex[i]],
defval) == 0)
+ {
+ gtk_tree_view_scroll_to_cell
(GTK_TREE_VIEW(view), gtk_tree_model_get_path(model,&iter), NULL, FALSE,
0.5, 0);
+ gtk_tree_selection_select_iter
(selection, &iter );
+ }
+ }
+ }
free(choices[tindex[i]]);
}
@@ -1121,7 +1165,7 @@
if (q->prev == NULL && q->next == NULL)
{
- if (strcmp(q->tag, "countrychooser/country-name") == 0)
+ 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);
Reply to: