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.
This commit is contained in:
parent
2c9e227432
commit
22625f8b16
19
ChangeLog
19
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
|
||||
|
1
TODO
1
TODO
@ -1,3 +1,2 @@
|
||||
* Start being hardass about which options are mandatory
|
||||
* Add some accessibility I guess
|
||||
* Remove extraneous cruft from configure.in
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
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;
|
||||
|
||||
|
173
src/main.c
173
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,
|
||||
@ -699,6 +837,15 @@ struct poptOption application_options[] = {
|
||||
N_("Warning options"),
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
'\0',
|
||||
POPT_ARG_INCLUDE_TABLE,
|
||||
gtk_options,
|
||||
0,
|
||||
N_("GTK+ options"),
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
'\0',
|
||||
@ -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
|
||||
@ -830,15 +978,11 @@ main (gint argc, gchar **argv) {
|
||||
/*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"),
|
||||
poptBadOption (ctx, 0));
|
||||
zenity_free_parsing_options ();
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
if (argc < 2) {
|
||||
@ -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,15 +1241,29 @@ 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);
|
||||
|
||||
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:
|
||||
|
||||
|
84
src/tree.c
84
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;
|
||||
@ -81,6 +82,9 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col
|
||||
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,6 +175,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
/* Create an empty list store */
|
||||
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
||||
|
||||
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++) {
|
||||
@ -161,10 +188,19 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
column_types[i] = G_TYPE_STRING;
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -185,20 +221,58 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
"active", column_index, NULL);
|
||||
}
|
||||
|
||||
else {
|
||||
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);
|
||||
}
|
||||
|
||||
first_column = TRUE;
|
||||
}
|
||||
else {
|
||||
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);
|
||||
|
@ -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>
|
||||
|
@ -78,6 +78,7 @@ typedef struct {
|
||||
gboolean checkbox;
|
||||
gboolean radiobox;
|
||||
gchar *separator;
|
||||
gboolean editable;
|
||||
const gchar **data;
|
||||
} ZenityTreeData;
|
||||
|
||||
|
Reference in New Issue
Block a user