Improve error handling. Make --list actually return something useful,
2003-01-13 Glynn Foster <glynn.foster@sun.com> * src/main.c: Improve error handling. * src/tree.c: Make --list actually return something useful, although I still need to actually seperate things out so it's actually decipherable. * TODO: Update accordingly.
This commit is contained in:
parent
cd4e438bfb
commit
69636459e1
@ -1,3 +1,12 @@
|
|||||||
|
2003-01-13 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
* src/main.c: Improve error handling.
|
||||||
|
* src/tree.c: Make --list actually return something
|
||||||
|
useful, although I still need to actually seperate
|
||||||
|
things out so it's actually decipherable.
|
||||||
|
|
||||||
|
* TODO: Update accordingly.
|
||||||
|
|
||||||
2003-01-09 Glynn Foster <glynn.foster@sun.com>
|
2003-01-09 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
* src/calendar.c: Fix up the date string, although I guess
|
* src/calendar.c: Fix up the date string, although I guess
|
||||||
|
2
TODO
2
TODO
@ -1,5 +1,3 @@
|
|||||||
* Implement return values for all dialogs
|
|
||||||
* All done, except for list view
|
|
||||||
* Add some accessibility I guess
|
* Add some accessibility I guess
|
||||||
* Find some nice default window icons
|
* Find some nice default window icons
|
||||||
* Implement about box
|
* Implement about box
|
||||||
|
17
src/main.c
17
src/main.c
@ -842,6 +842,9 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
const char *arg,
|
const char *arg,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
|
static gboolean parse_option_text = FALSE;
|
||||||
|
static gboolean parse_option_file = FALSE;
|
||||||
|
|
||||||
if (reason == POPT_CALLBACK_REASON_POST) {
|
if (reason == POPT_CALLBACK_REASON_POST) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -956,6 +959,12 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
case OPTION_QUESTIONTEXT:
|
case OPTION_QUESTIONTEXT:
|
||||||
case OPTION_PROGRESSTEXT:
|
case OPTION_PROGRESSTEXT:
|
||||||
case OPTION_WARNINGTEXT:
|
case OPTION_WARNINGTEXT:
|
||||||
|
if (parse_option_text == TRUE) {
|
||||||
|
g_printerr (_("--text given twice for the same dialog\n"));
|
||||||
|
zenity_free_parsing_options ();
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
|
||||||
switch (results->mode) {
|
switch (results->mode) {
|
||||||
case MODE_CALENDAR:
|
case MODE_CALENDAR:
|
||||||
results->calendar_data->dialog_text = g_strdup (arg);
|
results->calendar_data->dialog_text = g_strdup (arg);
|
||||||
@ -977,6 +986,7 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
zenity_free_parsing_options ();
|
zenity_free_parsing_options ();
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
parse_option_text = TRUE;
|
||||||
break;
|
break;
|
||||||
case OPTION_DAY:
|
case OPTION_DAY:
|
||||||
if (results->mode != MODE_CALENDAR) {
|
if (results->mode != MODE_CALENDAR) {
|
||||||
@ -1045,6 +1055,12 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
break;
|
break;
|
||||||
case OPTION_FILENAME:
|
case OPTION_FILENAME:
|
||||||
case OPTION_TEXTFILE:
|
case OPTION_TEXTFILE:
|
||||||
|
if (parse_option_file == TRUE) {
|
||||||
|
g_printerr (_("--filename given twice for the same dialog\n"));
|
||||||
|
zenity_free_parsing_options ();
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
|
||||||
switch (results->mode) {
|
switch (results->mode) {
|
||||||
case MODE_FILE:
|
case MODE_FILE:
|
||||||
results->file_data->uri = g_strdup (arg);
|
results->file_data->uri = g_strdup (arg);
|
||||||
@ -1057,6 +1073,7 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
zenity_free_parsing_options ();
|
zenity_free_parsing_options ();
|
||||||
exit (-1);
|
exit (-1);
|
||||||
}
|
}
|
||||||
|
parse_option_file = TRUE;
|
||||||
break;
|
break;
|
||||||
case OPTION_COLUMN:
|
case OPTION_COLUMN:
|
||||||
if (results->mode != MODE_LIST) {
|
if (results->mode != MODE_LIST) {
|
||||||
|
65
src/tree.c
65
src/tree.c
@ -53,15 +53,6 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g
|
|||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
|
||||||
{
|
|
||||||
gint *rows = data;
|
|
||||||
|
|
||||||
(*rows)++;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles)
|
zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles)
|
||||||
{
|
{
|
||||||
@ -70,7 +61,6 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col
|
|||||||
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); */
|
|
||||||
|
|
||||||
while (args[i] != NULL) {
|
while (args[i] != NULL) {
|
||||||
gint j;
|
gint j;
|
||||||
@ -123,6 +113,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n_columns = g_slist_length (tree_data->columns);
|
||||||
|
|
||||||
|
if (n_columns == 0) {
|
||||||
|
g_printerr (_("No column titles specified for --list\n"));
|
||||||
|
data->exit_code = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
|
||||||
@ -140,8 +138,6 @@ 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");
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
@ -216,13 +212,58 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|||||||
g_object_unref (glade_dialog);
|
g_object_unref (glade_dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
zenity_tree_dialog_output (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view)
|
||||||
|
{
|
||||||
|
GValue value = {0, };
|
||||||
|
|
||||||
|
gtk_tree_model_get_value (model, iter, 0, &value);
|
||||||
|
|
||||||
|
g_printerr ("%s", g_value_get_string (&value));
|
||||||
|
g_value_unset (&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
zenity_tree_dialog_toggle_output (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||||
|
{
|
||||||
|
GValue toggle_value = {0, };
|
||||||
|
|
||||||
|
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
||||||
|
|
||||||
|
if (g_value_get_boolean (&toggle_value) == TRUE) {
|
||||||
|
GValue value = {0, };
|
||||||
|
gtk_tree_model_get_value (model, iter, 1, &value);
|
||||||
|
g_printerr ("%s", g_value_get_string (&value));
|
||||||
|
g_value_unset (&value);
|
||||||
|
}
|
||||||
|
g_value_unset (&toggle_value);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
||||||
{
|
{
|
||||||
ZenityData *zen_data = data;
|
ZenityData *zen_data = data;
|
||||||
|
GtkWidget *tree_view;
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
|
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
||||||
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
||||||
|
|
||||||
|
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) {
|
||||||
|
gtk_tree_model_foreach (model,
|
||||||
|
(GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_output,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||||
|
gtk_tree_selection_selected_foreach (selection,
|
||||||
|
(GtkTreeSelectionForeachFunc) zenity_tree_dialog_output,
|
||||||
|
GTK_TREE_VIEW (tree_view));
|
||||||
|
}
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user