Mass indentation cleanup. Make sure the glade dialogs aren't initially

2003-03-10  Glynn Foster  <glynn.foster@sun.com>

	* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
	src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
	src/util.c, src/util.h, src/zenity.glade, src/zenity.h:

	Mass indentation cleanup. Make sure the glade dialogs aren't initially
	visible because this avoids a visibility jump. Apparently == TRUE is
	bad mojo. Fix up.
This commit is contained in:
Glynn Foster 2003-03-10 17:11:18 +00:00 committed by Glynn Foster
parent aaf773626e
commit 49f8979534
14 changed files with 2280 additions and 2283 deletions

View File

@ -1,3 +1,13 @@
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-08 Evandro Fernandes Giovanini <evandrofg@ig.com.br>
* configure.in(ALL_LINGUAS): Added "pt_BR" (Brazilian Portuguese).

View File

@ -66,14 +66,19 @@ static const gchar *author_credits[] = {
gchar *translator_credits;
static gint
zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
zenity_move_clothes_event (GnomeCanvasItem *item,
GdkEvent *event,
gpointer data)
{
static double x, y;
double new_x, new_y;
static int dragging;
double item_x, item_y;
/* set item_[xy] to the event x,y position in the parent's item-relative coordinates */
/* set item_[xy] to the event x,y position in the parent's
* item-relative coordinates
*/
item_x = event->button.x;
item_y = event->button.y;
gnome_canvas_item_w2i (item->parent, &item_x, &item_y);
@ -446,6 +451,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data)
case GTK_RESPONSE_CREDITS:
zenity_about_display_credits_dialog ();
break;
default:
/* Esc dialog */
zen_data->exit_code = 1;

View File

@ -100,8 +100,10 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
g_date_strftime (time_string, 127,
zen_cal_data->date_format, date);
g_printerr ("%s\n", time_string);
if (date != NULL)
g_date_free (date);
zen_data->exit_code = 0;
gtk_main_quit ();
break;

View File

@ -47,6 +47,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog");
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_entry_dialog_response), data);
@ -71,7 +72,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
if (entry_data->entry_text)
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
if (entry_data->visible == FALSE)
if (!entry_data->visible)
g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL);
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);

View File

@ -82,6 +82,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer
break;
default:
/* Esc dialog */
zen_data->exit_code = 1;
break;
}

View File

@ -1221,7 +1221,7 @@ zenity_parse_options_callback (poptContext ctx,
if (results->mode != MODE_CALENDAR)
zenity_error ("--date-format", ERROR_SUPPORT);
if (parse_option_dateformat == TRUE)
if (parse_option_dateformat)
zenity_error ("--date-format", ERROR_DUPLICATE);
results->calendar_data->date_format = g_strdup (arg);
@ -1240,7 +1240,7 @@ zenity_parse_options_callback (poptContext ctx,
if (results->mode != MODE_ENTRY)
zenity_error ("--hide-text", ERROR_SUPPORT);
if (results->entry_data->visible == FALSE)
if (!results->entry_data->visible)
zenity_error ("--hide-text", ERROR_DUPLICATE);
results->entry_data->visible = FALSE;
@ -1301,7 +1301,7 @@ zenity_parse_options_callback (poptContext ctx,
if (results->mode != MODE_LIST)
zenity_error ("--checkbox", ERROR_SUPPORT);
if (results->tree_data->checkbox == TRUE)
if (results->tree_data->checkbox)
zenity_error ("--checkbox", ERROR_DUPLICATE);
results->tree_data->checkbox = TRUE;
@ -1310,7 +1310,7 @@ zenity_parse_options_callback (poptContext ctx,
if (results->mode != MODE_LIST)
zenity_error ("--radiobox", ERROR_SUPPORT);
if (results->tree_data->radiobox == TRUE)
if (results->tree_data->radiobox)
zenity_error ("--radiobox", ERROR_DUPLICATE);
results->tree_data->radiobox = TRUE;
@ -1319,7 +1319,7 @@ zenity_parse_options_callback (poptContext ctx,
if (results->mode != MODE_LIST)
zenity_error ("--separator", ERROR_SUPPORT);
if (parse_option_separator == TRUE)
if (parse_option_separator)
zenity_error ("--separator", ERROR_DUPLICATE);
results->tree_data->separator = g_strdup (arg);

View File

@ -35,7 +35,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
GtkWidget *text;
switch (msg_data->mode) {
case ZENITY_MSG_WARNING:
glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog");
@ -85,20 +84,24 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
zenity_util_set_window_icon (dialog, data->window_icon);
else {
GdkPixbuf *pixbuf = NULL;
switch (msg_data->mode) {
switch (msg_data->mode) {
case ZENITY_MSG_WARNING:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING);
break;
case ZENITY_MSG_QUESTION:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION);
break;
case ZENITY_MSG_ERROR:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR);
break;
case ZENITY_MSG_INFO:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO);
break;
default:
break;
}

View File

@ -75,7 +75,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
progress_data->percentage/100.0);
gtk_widget_show (dialog);
if (progress_data->pulsate != TRUE)
if (!progress_data->pulsate)
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
else
timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar);
@ -135,7 +135,6 @@ zenity_progress_pulsate_timeout (gpointer data)
if (feof (stdin)) {
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
return FALSE;
} else {
GtkWidget *button;
@ -172,6 +171,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
/* Esc dialog */
zen_data->exit_code = 1;
break;
}

View File

@ -66,13 +66,13 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
if (text_data->uri) {
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
}
if (text_data->editable) {
if (text_data->uri)
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
if (text_data->editable)
zen_text_data->buffer = text_buffer;
}
gtk_widget_show (dialog);
if (glade_dialog)
@ -99,6 +99,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
/* Esc dialog */
zen_data->exit_code = 1;
break;
}

View File

@ -57,7 +57,11 @@ 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, gboolean editable)
zenity_tree_fill_entries (GtkTreeView *tree_view,
const gchar **args,
gint n_columns,
gboolean toggles,
gboolean editable)
{
GtkTreeModel *model;
GtkTreeIter iter;
@ -101,7 +105,10 @@ 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)
zenity_cell_edited_callback (GtkCellRendererText *cell,
const gchar *path_string,
const gchar *new_text,
gpointer data)
{
GtkTreeModel *model;
GtkTreePath *path;
@ -114,8 +121,7 @@ zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *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_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
gtk_tree_path_free (path);
}
@ -204,7 +210,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
column_index = 0;
for (tmp = tree_data->columns; tmp; tmp = tmp->next) {
if (first_column == FALSE) {
if (!first_column) {
if (tree_data->checkbox || tree_data->radiobox) {
GtkCellRenderer *cell_renderer;
@ -220,17 +226,15 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
cell_renderer,
"active", column_index, NULL);
}
else {
if (tree_data->editable == TRUE) {
if (tree_data->editable) {
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);
g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index);
column = gtk_tree_view_column_new_with_attributes (tmp->data,
cell_renderer,
@ -241,7 +245,8 @@ 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);
"text", column_index,
NULL);
}
gtk_tree_view_column_set_sort_column_id (column, column_index);
@ -251,15 +256,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
first_column = TRUE;
}
else {
if (tree_data->editable == TRUE) {
if (tree_data->editable) {
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);
g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index);
column = gtk_tree_view_column_new_with_attributes (tmp->data,
cell_renderer,
@ -275,7 +279,6 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
gtk_tree_view_column_set_sort_column_id (column, column_index);
gtk_tree_view_column_set_resizable (column, TRUE);
}
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
@ -314,7 +317,7 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path,
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
if (g_value_get_boolean (&toggle_value) == TRUE) {
if (g_value_get_boolean (&toggle_value)) {
GValue value = {0, };
gtk_tree_model_get_value (model, iter, 1, &value);
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
@ -361,11 +364,8 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
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_get_selected,
NULL);
}
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN)
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, NULL);
else {
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
gtk_tree_selection_selected_foreach (selection,
@ -383,6 +383,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
break;
default:
/* Esc dialog */
zen_data->exit_code = 1;
break;
}

View File

@ -43,8 +43,7 @@ zenity_util_load_glade_file (const gchar *widget_root)
{
GladeXML *xml = NULL;
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH,
G_FILE_TEST_EXISTS)) {
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
/* Try current dir, for debugging */
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
}
@ -108,6 +107,7 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename)
/* We had a newline in the buffer to begin with. (The buffer always contains
* a newline, so we delete to the end of the buffer to clean up.
*/
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_delete (buffer, &iter, &end);
@ -275,7 +275,8 @@ zenity_explode_locale (const gchar *locale,
if (at_pos) {
mask |= COMPONENT_MODIFIER;
*modifier = g_strdup (at_pos);
} else
}
else
at_pos = locale + strlen (locale);
if (dot_pos) {
@ -283,7 +284,8 @@ zenity_explode_locale (const gchar *locale,
*codeset = g_new (gchar, 1 + at_pos - dot_pos);
strncpy (*codeset, dot_pos, at_pos - dot_pos);
(*codeset) [at_pos - dot_pos] = '\0';
} else
}
else
dot_pos = at_pos;
if (uscore_pos) {
@ -291,7 +293,8 @@ zenity_explode_locale (const gchar *locale,
*territory = g_new (gchar, 1 + dot_pos - uscore_pos);
strncpy (*territory, uscore_pos, dot_pos - uscore_pos);
(*territory)[dot_pos - uscore_pos] = '\0';
} else
}
else
uscore_pos = dot_pos;
*language = g_new (gchar, 1 + uscore_pos - locale);
@ -323,8 +326,7 @@ zenity_compute_locale_variants (const gchar *locale)
for (i = 0; i <= mask; i++)
if ((i & ~mask) == 0) {
gchar *val = g_strconcat (language,
(i & COMPONENT_TERRITORY) ? territory : "",
gchar *val = g_strconcat (language, (i & COMPONENT_TERRITORY) ? territory : "",
(i & COMPONENT_CODESET) ? codeset : "",
(i & COMPONENT_MODIFIER) ? modifier : "", NULL);
retval = g_list_prepend (retval, val);
@ -524,9 +526,7 @@ zenity_util_show_help (const gchar *path, const gchar *document, GError **error)
if (template == NULL) {
gchar* template_temp;
template_temp = gconf_client_get_string (client,
DEFAULT_HANDLER_PATH,
NULL);
template_temp = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL);
/* Retry to get the right url handler */
template = gconf_client_get_string (client, path, NULL);
@ -543,17 +543,12 @@ zenity_util_show_help (const gchar *path, const gchar *document, GError **error)
} else {
/* no ':' ? this shouldn't happen. Use default handler */
template = gconf_client_get_string (client,
DEFAULT_HANDLER_PATH,
NULL);
template = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL);
}
g_object_unref (G_OBJECT (client));
if (!g_shell_parse_argv (template,
&argc,
&argv,
error)) {
if (!g_shell_parse_argv (template, &argc, &argv, error)) {
g_free (template);
return FALSE;
}
@ -572,15 +567,7 @@ zenity_util_show_help (const gchar *path, const gchar *document, GError **error)
}
/* This can return some errors */
ret = g_spawn_async (NULL /* working directory */,
argv,
NULL,
G_SPAWN_SEARCH_PATH /* flags */,
NULL /* child_setup */,
NULL /* data */,
NULL /* child_pid */,
error);
ret = g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error);
g_strfreev (argv);
return ret;

View File

@ -11,16 +11,12 @@ G_BEGIN_DECLS
#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL))
GladeXML* zenity_util_load_glade_file (const gchar *widget_root);
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
const gchar *filename);
void zenity_util_set_window_icon (GtkWidget *widget,
const gchar *filename);
void zenity_util_set_window_icon_from_stock (GtkWidget *widget,
const gchar *stock_id);
gboolean zenity_util_show_help (const gchar *path,
const gchar *document,
GError **error);

View File

@ -4,7 +4,6 @@
<glade-interface>
<widget class="GtkDialog" id="zenity_calendar_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Calendar selection</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -148,7 +147,6 @@
</widget>
<widget class="GtkDialog" id="zenity_warning_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Warning</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -259,7 +257,6 @@
<widget class="GtkFileSelection" id="zenity_fileselection_dialog">
<property name="border_width">10</property>
<property name="visible">True</property>
<property name="title" translatable="yes">Select a file</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -290,7 +287,6 @@
</widget>
<widget class="GtkDialog" id="zenity_question_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Question</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -400,7 +396,6 @@
</widget>
<widget class="GtkDialog" id="zenity_entry_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Add a new entry</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -528,7 +523,6 @@
</widget>
<widget class="GtkDialog" id="zenity_text_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Text View</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -623,7 +617,6 @@
</widget>
<widget class="GtkDialog" id="zenity_progress_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Progress</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -745,7 +738,6 @@
</widget>
<widget class="GtkDialog" id="zenity_error_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Error</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -855,7 +847,6 @@
</widget>
<widget class="GtkDialog" id="zenity_tree_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Select items from the list</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -990,7 +981,6 @@
</widget>
<widget class="GtkDialog" id="zenity_info_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Information</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
@ -1100,7 +1090,6 @@
</widget>
<widget class="GtkDialog" id="zenity_about_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">About Zenity</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
@ -1192,7 +1181,7 @@
<widget class="GtkLabel" id="zenity_about_version">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="no">zenity_about_version</property>
<property name="label" translatable="yes">zenity_about_version</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
@ -1214,7 +1203,7 @@
<widget class="GtkLabel" id="zenity_about_description">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="no">zenity_about_description</property>
<property name="label" translatable="yes">zenity_about_description</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
@ -1236,7 +1225,7 @@
<widget class="GtkLabel" id="zenity_about_copyright">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="no">zenity_about_copyright</property>
<property name="label" translatable="yes">zenity_about_copyright</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>