Finish off commandline parsing for the list dialog. Wow, this is almost
2003-01-06 Glynn Foster <glynn.foster@sun.com> * src/main.c, src/tree.c, src/zenity.h: Finish off commandline parsing for the list dialog. Wow, this is almost approaching usable ;) * TODO: Update accordingly
This commit is contained in:
parent
8924d5c401
commit
d88a32f1f5
@ -1,3 +1,11 @@
|
|||||||
|
2003-01-06 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
* src/main.c, src/tree.c, src/zenity.h: Finish off
|
||||||
|
commandline parsing for the list dialog. Wow, this
|
||||||
|
is almost approaching usable ;)
|
||||||
|
|
||||||
|
* TODO: Update accordingly
|
||||||
|
|
||||||
2003-01-06 Glynn Foster <glynn.foster@sun.com>
|
2003-01-06 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
* src/main.c, src/msg.c, src/zenity.glade,
|
* src/main.c, src/msg.c, src/zenity.glade,
|
||||||
|
1
TODO
1
TODO
@ -1,4 +1,3 @@
|
|||||||
* Finish off commandline support for list dialog
|
|
||||||
* Finish off support for progress dialog
|
* Finish off support for progress dialog
|
||||||
* Implement error/return values for all dialogs
|
* Implement error/return values for all dialogs
|
||||||
* Add some accessibility I guess
|
* Add some accessibility I guess
|
||||||
|
@ -735,6 +735,7 @@ zenity_free_parsing_options (void) {
|
|||||||
|
|
||||||
gint
|
gint
|
||||||
main (gint argc, gchar **argv) {
|
main (gint argc, gchar **argv) {
|
||||||
|
char **args;
|
||||||
poptContext ctx;
|
poptContext ctx;
|
||||||
int nextopt;
|
int nextopt;
|
||||||
ZenityData *general;
|
ZenityData *general;
|
||||||
@ -781,6 +782,7 @@ main (gint argc, gchar **argv) {
|
|||||||
zenity_fileselection (results->data, results->file_data);
|
zenity_fileselection (results->data, results->file_data);
|
||||||
break;
|
break;
|
||||||
case MODE_LIST:
|
case MODE_LIST:
|
||||||
|
results->tree_data->data = poptGetArgs (ctx);
|
||||||
zenity_tree (results->data, results->tree_data);
|
zenity_tree (results->data, results->tree_data);
|
||||||
break;
|
break;
|
||||||
case MODE_PROGRESS:
|
case MODE_PROGRESS:
|
||||||
|
40
src/tree.c
40
src/tree.c
@ -63,21 +63,32 @@ count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, g
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv)
|
zenity_tree_fill_entries (GtkTreeView *tree_view, gchar **args, gint n_columns, gboolean toggles)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
model = gtk_tree_view_get_model (tree_view);
|
model = gtk_tree_view_get_model (tree_view);
|
||||||
gtk_tree_model_foreach (model, count_rows_foreach, &i);
|
/* gtk_tree_model_foreach (model, count_rows_foreach, &i); */
|
||||||
|
|
||||||
|
while (args[i] != NULL) {
|
||||||
|
gint j;
|
||||||
|
|
||||||
while (i<10) {
|
|
||||||
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
|
||||||
0, "TRUE",
|
|
||||||
1, "This is the bar above foobar", -1);
|
|
||||||
|
|
||||||
|
for (j = 0; j < n_columns; j++) {
|
||||||
|
|
||||||
|
if (toggles && j == 0) {
|
||||||
|
if (strcmp (args[i+j], "TRUE") == 0 || strcmp (args[i+j], "true") == 0)
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1);
|
||||||
|
else
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkRequisition rectangle;
|
GtkRequisition rectangle;
|
||||||
@ -88,8 +99,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv)
|
|||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||||
}
|
}
|
||||||
|
i += n_columns;
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +114,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
GType *column_types;
|
GType *column_types;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
gboolean first_column = FALSE;
|
gboolean first_column = FALSE;
|
||||||
gint i, column_index, column_n;
|
gint i, column_index, n_columns;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
|
||||||
|
|
||||||
@ -124,14 +135,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
|
|
||||||
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
||||||
|
|
||||||
column_n = g_slist_length (tree_data->columns);
|
n_columns = g_slist_length (tree_data->columns);
|
||||||
|
|
||||||
/* Create an empty list store */
|
/* Create an empty list store */
|
||||||
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
||||||
|
|
||||||
column_types = g_new (GType, column_n);
|
column_types = g_new (GType, n_columns);
|
||||||
|
|
||||||
for (i = 0; i < column_n; i++) {
|
for (i = 0; i < n_columns; i++) {
|
||||||
/* Have the limitation that the radioboxes and checkboxes are in the first column */
|
/* Have the limitation that the radioboxes and checkboxes are in the first column */
|
||||||
if (i == 0 && (tree_data->checkbox || tree_data->radiobox))
|
if (i == 0 && (tree_data->checkbox || tree_data->radiobox))
|
||||||
column_types[i] = G_TYPE_BOOLEAN;
|
column_types[i] = G_TYPE_BOOLEAN;
|
||||||
@ -139,7 +150,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
column_types[i] = G_TYPE_STRING;
|
column_types[i] = G_TYPE_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_list_store_set_column_types (model, column_n, column_types);
|
gtk_list_store_set_column_types (model, n_columns, column_types);
|
||||||
|
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
||||||
|
|
||||||
@ -188,7 +199,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
|
|
||||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
|
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
|
||||||
|
|
||||||
/* zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL); */
|
if (tree_data->radiobox || tree_data->checkbox)
|
||||||
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE);
|
||||||
|
else
|
||||||
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
@ -73,6 +73,7 @@ typedef struct {
|
|||||||
GSList *columns;
|
GSList *columns;
|
||||||
gboolean checkbox;
|
gboolean checkbox;
|
||||||
gboolean radiobox;
|
gboolean radiobox;
|
||||||
|
gchar **data;
|
||||||
} ZenityTreeData;
|
} ZenityTreeData;
|
||||||
|
|
||||||
int zenity_calendar (ZenityData *data,
|
int zenity_calendar (ZenityData *data,
|
||||||
|
Reference in New Issue
Block a user