summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlynn Foster <glynn.foster@sun.com>2003-01-28 14:58:30 +0000
committerGlynn Foster <gman@src.gnome.org>2003-01-28 14:58:30 +0000
commit22625f8b16e1dc38be50cc2e869780b74e7f6891 (patch)
tree22350d18e411b9f0ce5cb6eadff9f5d2b0af4d3b
parent2c9e227432083a7fbca9538a990de7bc55402934 (diff)
downloadzenity-22625f8b16e1dc38be50cc2e869780b74e7f6891.tar.gz
Don't display the translators tab unless there is stuff to show.
2003-01-28 Glynn Foster <glynn.foster@sun.com> * src/about.c: Don't display the translators tab unless there is stuff to show. * src/entry.c: Add sanity NULL checking. * src/tree.c, src/zenity.h: Add support for a new --editable option. * src/main.c: Add support for new --editable option for the List dialog. Merge in the list of Gtk+ options into the popt table - ripped this from libbonoboui, thanks to James for pointing this out. * src/zenity.glade: Make the translatable strings less arse. * TODO: Update accordingly.
-rw-r--r--ChangeLog19
-rw-r--r--TODO1
-rw-r--r--src/about.c3
-rw-r--r--src/entry.c7
-rw-r--r--src/main.c189
-rw-r--r--src/tree.c102
-rw-r--r--src/zenity.glade4
-rw-r--r--src/zenity.h1
8 files changed, 291 insertions, 35 deletions
diff --git a/ChangeLog b/ChangeLog
index c0939aa..1f6f34b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-01-28 Glynn Foster <glynn.foster@sun.com>
+
+ * src/about.c: Don't display the translators tab
+ unless there is stuff to show.
+
+ * src/entry.c: Add sanity NULL checking.
+
+ * src/tree.c, src/zenity.h: Add support for a new
+ --editable option.
+
+ * src/main.c: Add support for new --editable option for
+ the List dialog. Merge in the list of Gtk+ options into
+ the popt table - ripped this from libbonoboui, thanks to
+ James for pointing this out.
+
+ * src/zenity.glade: Make the translatable strings less arse.
+
+ * TODO: Update accordingly.
+
2003-01-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Update
diff --git a/TODO b/TODO
index 305fe2a..d48f7da 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,2 @@
-* Start being hardass about which options are mandatory
* Add some accessibility I guess
* Remove extraneous cruft from configure.in
diff --git a/src/about.c b/src/about.c
index 67e9e97..5e7003f 100644
--- a/src/about.c
+++ b/src/about.c
@@ -72,7 +72,6 @@ zenity_about (ZenityData *data)
translator_credits = _("translator_credits");
-
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog");
@@ -222,7 +221,7 @@ zenity_about_display_credits_dialog (void)
zenity_about_update_author_label (label);
}
- if (translator_credits != NULL) {
+ if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) {
label = zenity_about_create_label ();
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
diff --git a/src/entry.c b/src/entry.c
index 3578788..893fbf6 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -84,11 +84,16 @@ static void
zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data)
{
ZenityData *zen_data = data;
+ const gchar *text;
switch (response) {
case GTK_RESPONSE_OK:
zen_data->exit_code = 0;
- g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (text != NULL)
+ g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
+
gtk_main_quit ();
break;
diff --git a/src/main.c b/src/main.c
index 4350214..1339923 100644
--- a/src/main.c
+++ b/src/main.c
@@ -88,6 +88,7 @@ enum {
OPTION_FILENAME,
OPTION_COLUMN,
OPTION_SEPERATOR,
+ OPTION_LISTEDIT,
OPTION_CHECKLIST,
OPTION_RADIOLIST,
OPTION_PROGRESSTEXT,
@@ -450,6 +451,15 @@ struct poptOption list_options[] = {
N_("Set output separator character"),
NULL
},
+ {
+ "editable",
+ '\0',
+ POPT_ARG_NONE,
+ NULL,
+ OPTION_LISTEDIT,
+ N_("Allow changes to text"),
+ NULL
+ },
POPT_TABLEEND
};
@@ -559,6 +569,134 @@ struct poptOption warning_options[] = {
POPT_TABLEEND
};
+struct poptOption gtk_options[] = {
+ {
+ "gdk-debug",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Gdk debugging flags to set"),
+ N_("FLAGS")
+ },
+ {
+ "gdk-no-debug",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Gdk debugging flags to unset"),
+ N_("FLAGS")
+ },
+ /* X11 only */
+ {
+ "display",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("X display to use"),
+ N_("DISPLAY")
+ },
+#ifdef HAVE_GTK_MULTIHEAD
+ /* X11 & multi-head only */
+ {
+ "screen",
+ '\0',
+ POPT_ARG_INT,
+ NULL,
+ 0,
+ N_("X screen to use"),
+ N_("SCREEN")
+ },
+#endif
+ /* X11 only */
+ {
+ "sync",
+ '\0',
+ POPT_ARG_NONE,
+ NULL,
+ 0,
+ N_("Make X calls synchronous"),
+ NULL
+ },
+ {
+ "name",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Program name as used by the window manager"),
+ N_("NAME")
+ },
+ {
+ "class",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Program class as used by the window manager"),
+ N_("CLASS")
+ },
+ /* X11 only */
+ {
+ "gxid-host",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ NULL,
+ N_("HOST")
+ },
+ /* X11 only */
+ {
+ "gxid-port",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ NULL,
+ N_("PORT")
+ },
+ {
+ "gtk-debug",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Gtk+ debugging flags to set"),
+ N_("FLAGS")
+ },
+ {
+ "gtk-no-debug",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Gtk+ debugging flags to unset"),
+ N_("FLAGS")
+ },
+ {
+ "g-fatal-warnings",
+ '\0',
+ POPT_ARG_NONE,
+ NULL,
+ 0,
+ N_("Make all warnings fatal"),
+ NULL
+ },
+ {
+ "gtk-module",
+ '\0',
+ POPT_ARG_STRING,
+ NULL,
+ 0,
+ N_("Load an additional Gtk module"),
+ N_("MODULE")
+ },
+ POPT_TABLEEND
+};
+
struct poptOption miscellaneous_options[] = {
{
NULL,
@@ -703,6 +841,15 @@ struct poptOption application_options[] = {
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
+ gtk_options,
+ 0,
+ N_("GTK+ options"),
+ NULL
+ },
+ {
+ NULL,
+ '\0',
+ POPT_ARG_INCLUDE_TABLE,
miscellaneous_options,
0,
N_("Miscellaneous options"),
@@ -751,6 +898,7 @@ zenity_init_parsing_options (void) {
results->entry_data->visible = TRUE;
results->tree_data->checkbox = FALSE;
results->tree_data->radiobox = FALSE;
+ results->tree_data->editable = FALSE;
}
static void
@@ -825,21 +973,17 @@ main (gint argc, gchar **argv) {
ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0);
- poptReadDefaultConfig(ctx, TRUE);
+ poptReadDefaultConfig(ctx, TRUE);
while((nextopt = poptGetNextOpt(ctx)) > 0)
/*nothing*/;
- if (nextopt != -1) {
- /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+
- * commandline options
- */
- g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"),
+ if (nextopt != -1) {
+ g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"),
poptBadOption (ctx, 0));
- zenity_free_parsing_options ();
- exit (-1);
- }
-
- gtk_init (&argc, &argv);
+ zenity_free_parsing_options ();
+ exit (-1);
+ }
+ gtk_init (&argc, &argv);
if (argc < 2) {
g_printerr (_("You must specify more arguments. See zenity --help for more details\n"));
@@ -920,6 +1064,7 @@ zenity_parse_options_callback (poptContext ctx,
static gboolean parse_option_separator = FALSE;
static gint parse_option_text = 0;
static gint parse_option_file = 0;
+ static gint parse_option_editable = 0;
if (reason == POPT_CALLBACK_REASON_POST) {
return;
@@ -1096,14 +1241,28 @@ zenity_parse_options_callback (poptContext ctx,
results->entry_data->visible = FALSE;
break;
+ case OPTION_LISTEDIT:
case OPTION_TEXTEDIT:
- if (results->mode != MODE_TEXTINFO)
- zenity_error ("--editable", ERROR_SUPPORT);
- if (results->text_data->editable == TRUE)
+ /* FIXME: This is an ugly hack because of the way the poptOptions are
+ * ordered above. When you try and use an --option more than once
+ * parse_options_callback gets called for each option. Suckage
+ */
+
+ if (parse_option_file > 2)
zenity_error ("--editable", ERROR_DUPLICATE);
- results->text_data->editable = TRUE;
+ switch (results->mode) {
+ case MODE_TEXTINFO:
+ results->text_data->editable = TRUE;
+ break;
+ case MODE_LIST:
+ results->tree_data->editable = TRUE;
+ break;
+ default:
+ zenity_error ("--editable", ERROR_SUPPORT);
+ }
+ parse_option_editable++;
break;
case OPTION_FILENAME:
case OPTION_TEXTFILE:
diff --git a/src/tree.c b/src/tree.c
index c19b180..e5573ff 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -24,6 +24,7 @@
*/
#include <glade/glade.h>
+#include <string.h>
#include "zenity.h"
#include "util.h"
@@ -56,7 +57,7 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g
}
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, gboolean editable)
{
GtkTreeModel *model;
GtkTreeIter iter;
@@ -80,7 +81,10 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col
else
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1);
}
-
+
+ if (editable)
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1);
+
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
GtkWidget *scrolled_window;
GtkRequisition rectangle;
@@ -96,6 +100,26 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col
}
}
+static void
+zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer data)
+{
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gint column;
+
+ model = GTK_TREE_MODEL (data);
+ path = gtk_tree_path_new_from_string (path_string);
+
+ column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
+ gtk_tree_model_get_iter (model, &iter, path);
+
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ column, new_text, -1);
+
+ gtk_tree_path_free (path);
+}
+
void
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
{
@@ -151,7 +175,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
/* Create an empty list store */
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
- column_types = g_new (GType, n_columns);
+ if (tree_data->editable)
+ column_types = g_new (GType, n_columns + 1);
+ else
+ column_types = g_new (GType, n_columns);
for (i = 0; i < n_columns; i++) {
/* Have the limitation that the radioboxes and checkboxes are in the first column */
@@ -161,10 +188,19 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
column_types[i] = G_TYPE_STRING;
}
- gtk_list_store_set_column_types (model, n_columns, column_types);
+ if (tree_data->editable)
+ column_types[n_columns] = G_TYPE_BOOLEAN;
+
+ if (tree_data->editable)
+ gtk_list_store_set_column_types (model, n_columns + 1, column_types);
+ else
+ 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_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
+ GTK_SELECTION_MULTIPLE);
+
column_index = 0;
for (tmp = tree_data->columns; tmp; tmp = tmp->next) {
@@ -186,9 +222,28 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
}
else {
- column = gtk_tree_view_column_new_with_attributes (tmp->data,
- gtk_cell_renderer_text_new (),
- "text", column_index, NULL);
+ if (tree_data->editable == TRUE) {
+ GtkCellRenderer *cell_renderer;
+
+ cell_renderer = gtk_cell_renderer_text_new ();
+ g_signal_connect (G_OBJECT (cell_renderer), "edited",
+ G_CALLBACK (zenity_cell_edited_callback),
+ gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
+ g_object_set_data (G_OBJECT (cell_renderer), "column",
+ (gint *) column_index);
+
+ column = gtk_tree_view_column_new_with_attributes (tmp->data,
+ cell_renderer,
+ "text", column_index,
+ "editable", n_columns,
+ NULL);
+ }
+ else {
+ column = gtk_tree_view_column_new_with_attributes (tmp->data,
+ gtk_cell_renderer_text_new (),
+ "text", column_index, NULL);
+ }
+
gtk_tree_view_column_set_sort_column_id (column, column_index);
gtk_tree_view_column_set_resizable (column, TRUE);
}
@@ -196,9 +251,28 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
first_column = TRUE;
}
else {
- column = gtk_tree_view_column_new_with_attributes (tmp->data,
- gtk_cell_renderer_text_new (),
- "text", column_index, NULL);
+ if (tree_data->editable == TRUE) {
+ GtkCellRenderer *cell_renderer;
+
+ cell_renderer = gtk_cell_renderer_text_new ();
+ g_signal_connect (G_OBJECT (cell_renderer), "edited",
+ G_CALLBACK (zenity_cell_edited_callback),
+ gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
+ g_object_set_data (G_OBJECT (cell_renderer), "column",
+ (gint *) column_index);
+
+ column = gtk_tree_view_column_new_with_attributes (tmp->data,
+ cell_renderer,
+ "text", column_index,
+ "editable", n_columns,
+ NULL);
+ }
+ else {
+ column = gtk_tree_view_column_new_with_attributes (tmp->data,
+ gtk_cell_renderer_text_new (),
+ "text", column_index, NULL);
+ }
+
gtk_tree_view_column_set_sort_column_id (column, column_index);
gtk_tree_view_column_set_resizable (column, TRUE);
@@ -211,9 +285,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
if (tree_data->radiobox || tree_data->checkbox)
- zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE);
+ zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable);
else
- zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE);
+ zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable);
gtk_widget_show (dialog);
gtk_main ();
@@ -258,9 +332,9 @@ zenity_tree_dialog_output (void)
for (tmp = selected; tmp; tmp = tmp->next) {
if (tmp->next != NULL) {
/* FIXME: There must be a nicer way to do this. This is just arse */
- if (strstr (separator, "\\n") != NULL)
+ if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL)
g_printerr ("%s\n", tmp->data);
- else if (strstr (separator, "\\t") != NULL)
+ else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL)
g_printerr ("%s\t", tmp->data);
else
g_printerr ("%s%s", tmp->data, separator);
diff --git a/src/zenity.glade b/src/zenity.glade
index 3141c85..46eda5a 100644
--- a/src/zenity.glade
+++ b/src/zenity.glade
@@ -819,7 +819,7 @@
<child>
<widget class="GtkLabel" id="zenity_error_text">
<property name="visible">True</property>
- <property name="label" translatable="yes">You have not done the right thing, clearly.</property>
+ <property name="label" translatable="yes">An error has occurred.</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1064,7 +1064,7 @@
<child>
<widget class="GtkLabel" id="zenity_info_text">
<property name="visible">True</property>
- <property name="label" translatable="yes">You have done the right thing, hurrah.</property>
+ <property name="label" translatable="yes">All updates are complete.</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
diff --git a/src/zenity.h b/src/zenity.h
index de833f0..2894416 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -78,6 +78,7 @@ typedef struct {
gboolean checkbox;
gboolean radiobox;
gchar *separator;
+ gboolean editable;
const gchar **data;
} ZenityTreeData;