Re-structure the code to pass in the ZenityData structure into the

2003-01-13  Glynn Foster  <glynn.foster@sun.com>

	* src/calendar.c: Re-structure the code to pass in the
	ZenityData structure into the response_callback instead.

	* src/main.c: Fix the screwups in the commandline parser
	due to popt being teh suck.

	* src/msg.c: Don't unref the GladeXML before you use it.

	* THANKS: New file.
This commit is contained in:
Glynn Foster 2003-01-13 18:16:50 +00:00 committed by Glynn Foster
parent 9a77e41fec
commit 1e0ff80be4
5 changed files with 53 additions and 16 deletions

View File

@ -1,3 +1,15 @@
2003-01-13 Glynn Foster <glynn.foster@sun.com>
* src/calendar.c: Re-structure the code to pass in the
ZenityData structure into the response_callback instead.
* src/main.c: Fix the screwups in the commandline parser
due to popt being teh suck.
* src/msg.c: Don't unref the GladeXML before you use it.
* THANKS: New file.
2003-01-13 Mike Newman <mike@gtnorthern.demon.co.uk>
* src/calendar.c, src/main.c, src/zenity.h: Make the calendar

1
THANKS Normal file
View File

@ -0,0 +1 @@
Mike Newman <mike@gtnorthern.demon.co.uk>

View File

@ -28,6 +28,7 @@
static GtkWidget *calendar;
static ZenityCalendarData *zen_cal_data;
static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data);
@ -38,6 +39,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
GtkWidget *dialog;
GtkWidget *text;
zen_cal_data = cal_data;
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog");
if (glade_dialog == NULL) {
@ -50,7 +53,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog");
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_calendar_dialog_response), cal_data);
G_CALLBACK (zenity_calendar_dialog_response), data);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
@ -81,19 +84,21 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
static void
zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
{
ZenityCalendarData *cal_data = data;
ZenityData *zen_data;
gint day, month, year;
gchar time_string[128];
GDate *date = NULL;
zen_data = data;
switch (response) {
case GTK_RESPONSE_OK:
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
date = g_date_new_dmy (year, month + 1, day);
g_date_strftime (time_string, 127,
cal_data->date_format, date);
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 ();

View File

@ -855,8 +855,9 @@ void zenity_parse_options_callback (poptContext ctx,
const char *arg,
void *data)
{
static gboolean parse_option_text = FALSE;
static gboolean parse_option_file = FALSE;
static gboolean parse_option_dateformat = FALSE;
static gint parse_option_text = 0;
static gint parse_option_file = 0;
if (reason == POPT_CALLBACK_REASON_POST) {
return;
@ -972,7 +973,13 @@ void zenity_parse_options_callback (poptContext ctx,
case OPTION_QUESTIONTEXT:
case OPTION_PROGRESSTEXT:
case OPTION_WARNINGTEXT:
if (parse_option_text == 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_text > 6) {
g_printerr (_("--text given twice for the same dialog\n"));
zenity_free_parsing_options ();
exit (-1);
@ -999,7 +1006,7 @@ void zenity_parse_options_callback (poptContext ctx,
zenity_free_parsing_options ();
exit (-1);
}
parse_option_text = TRUE;
parse_option_text++;
break;
case OPTION_DAY:
if (results->mode != MODE_CALENDAR) {
@ -1046,7 +1053,13 @@ void zenity_parse_options_callback (poptContext ctx,
zenity_free_parsing_options ();
exit (-1);
}
if (parse_option_dateformat == TRUE) {
g_printerr (_("--date-format given twice for the same dialog\n"));
zenity_free_parsing_options ();
exit (-1);
}
results->calendar_data->date_format = g_strdup (arg);
parse_option_dateformat = TRUE;
break;
case OPTION_INPUTTEXT:
if (results->mode != MODE_ENTRY) {
@ -1076,7 +1089,13 @@ void zenity_parse_options_callback (poptContext ctx,
break;
case OPTION_FILENAME:
case OPTION_TEXTFILE:
if (parse_option_file == 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) {
g_printerr (_("--filename given twice for the same dialog\n"));
zenity_free_parsing_options ();
exit (-1);
@ -1094,7 +1113,7 @@ void zenity_parse_options_callback (poptContext ctx,
zenity_free_parsing_options ();
exit (-1);
}
parse_option_file = TRUE;
parse_option_file++;
break;
case OPTION_COLUMN:
if (results->mode != MODE_LIST) {

View File

@ -65,9 +65,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
break;
}
if (glade_dialog)
g_object_unref (glade_dialog);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (zenity_msg_dialog_response), data);
@ -78,6 +75,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
glade_xml_signal_autoconnect (glade_dialog);
if (glade_dialog)
g_object_unref (glade_dialog);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);