aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/misc/ChangeLog27
-rw-r--r--widgets/misc/Makefile.am1
-rw-r--r--widgets/misc/e-calendar-item.c58
-rw-r--r--widgets/misc/e-cell-date-edit.c9
-rw-r--r--widgets/misc/e-charset-picker.c170
-rw-r--r--widgets/misc/e-dateedit.c9
-rw-r--r--widgets/misc/e-filter-bar.c5
-rw-r--r--widgets/misc/e-search-bar.c47
-rw-r--r--widgets/misc/test-calendar.c12
9 files changed, 223 insertions, 115 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog
index b104a7e170..4117d4ea32 100644
--- a/widgets/misc/ChangeLog
+++ b/widgets/misc/ChangeLog
@@ -1,3 +1,30 @@
+2003-02-25 Jeffrey Stedfast <fejj@ximian.com>
+
+ * e-dateedit.c (on_date_popup_date_selected): Same as below.
+
+ * e-cell-date-edit.c (e_cell_date_edit_on_ok_clicked): Also
+ updated to use the new GDate API from glib 2.0
+
+ * test-calendar.c (on_selection_changed): Fixed to use glib 2.0's
+ GDate API.
+
+ * e-calendar-item.c (e_calendar_item_get_week_number): Port to
+ glib 2.0's GDate API.
+ (e_calendar_item_set_selection): Same.
+
+ * e-search-bar.c (append_xml_menu_item): Use
+ g_string_append_printf instead of g_string_sprintfa since the
+ latter is now deprecated.
+ (setup_bonobo_menus): Same.
+
+ * e-filter-bar.c (do_advanced): Use gtk_window_set_resizable()
+
+ * e-charset-picker.c: Fixes to make it build cleanly with
+ -DG_DISABLE_DEPRECATED
+ (add_charset): Escape _'s so we don't get underline weirdness due
+ to GtkLabel thinking the _ means to underline the next char.
+ (e_charset_picker_bonobo_ui_populate): Same here.
+
2003-02-20 Dan Winship <danw@ximian.com>
* Makefile.am: Make libemiscwidgets and libefilterbar dynamic
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 7e2ecbd3dc..3f1be05c58 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -6,6 +6,7 @@ INCLUDES = \
-I$(top_srcdir)/widgets/shortcut-bar \
-DMAP_DIR=\""$(imagesdir)"\" \
-DG_LOG_DOMAIN=__FILE__ \
+ -DG_DISABLE_DEPRECATED \
$(GNOME_FULL_CFLAGS)
privlib_LTLIBRARIES = \
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 8d3bd80853..3e781a9d3e 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -25,7 +25,10 @@
* ECalendarItem - canvas item displaying a calendar.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include "e-calendar-item.h"
@@ -1498,37 +1501,38 @@ e_calendar_item_get_week_number (ECalendarItem *calitem,
gint month,
gint year)
{
- GDate tmp_date;
- gint weekday, yearday, offset, week_num;
-
+ GDate date;
+ guint weekday, yearday;
+ int offset, week_num;
+
/* FIXME: check what happens at year boundaries. */
-
- g_date_clear (&tmp_date, 1);
- g_date_set_dmy (&tmp_date, day, month + 1, year);
-
- /* This results in a value of 0 (Monday) - 6 (Sunday). */
- weekday = g_date_weekday (&tmp_date) - 1;
-
+
+ g_date_clear (&date, 1);
+ g_date_set_dmy (&date, day, month + 1, year);
+
+ /* This results in a value of 0 (Monday) - 6 (Sunday). (or -1 on error - oops!!) */
+ weekday = g_date_get_weekday (&date) - 1;
+
/* Calculate the offset from the start of the week. */
offset = (calitem->week_start_day + 7 - weekday) % 7;
-
+
/* Calculate the day of the year, from 0 to 365. */
- yearday = g_date_day_of_year (&tmp_date) - 1;
-
+ yearday = g_date_get_day_of_year (&date) - 1;
+
/* If the week starts on or after 29th December, it is week 1 of the
next year, since there are 4 days in the next year. */
- g_date_subtract_days (&tmp_date, offset);
- if (g_date_month (&tmp_date) == 12 && g_date_day (&tmp_date) >= 29)
+ g_date_subtract_days (&date, offset);
+ if (g_date_get_month (&date) == 12 && g_date_get_day (&date) >= 29)
return 1;
-
+
/* Calculate the week number, from 0. */
week_num = (yearday - offset) / 7;
-
+
/* If the first week starts on or after Jan 5th, then we need to add
1 since the previous week will really be the first week. */
if ((yearday - offset) % 7 >= 4)
week_num++;
-
+
/* Add 1 so week numbers are from 1 to 53. */
return week_num + 1;
}
@@ -2683,16 +2687,16 @@ e_calendar_item_set_selection (ECalendarItem *calitem,
if (end_date == NULL)
end_date = start_date;
-
+
g_return_if_fail (g_date_compare (start_date, end_date) <= 0);
-
- start_year = g_date_year (start_date);
- start_month = g_date_month (start_date) - 1;
- start_day = g_date_day (start_date);
- end_year = g_date_year (end_date);
- end_month = g_date_month (end_date) - 1;
- end_day = g_date_day (end_date);
-
+
+ start_year = g_date_get_year (start_date);
+ start_month = g_date_get_month (start_date) - 1;
+ start_day = g_date_get_day (start_date);
+ end_year = g_date_get_year (end_date);
+ end_month = g_date_get_month (end_date) - 1;
+ end_day = g_date_get_day (end_date);
+
need_update = e_calendar_item_ensure_days_visible (calitem,
start_year,
start_month,
diff --git a/widgets/misc/e-cell-date-edit.c b/widgets/misc/e-cell-date-edit.c
index 4e2dfe8831..d37def6140 100644
--- a/widgets/misc/e-cell-date-edit.c
+++ b/widgets/misc/e-cell-date-edit.c
@@ -26,7 +26,10 @@
* window to edit it.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include "e-cell-date-edit.h"
@@ -763,9 +766,9 @@ e_cell_date_edit_on_ok_clicked (GtkWidget *button,
}
if (day_selected) {
- date_tm.tm_year = g_date_year (&start_date) - 1900;
- date_tm.tm_mon = g_date_month (&start_date) - 1;
- date_tm.tm_mday = g_date_day (&start_date);
+ date_tm.tm_year = g_date_get_year (&start_date) - 1900;
+ date_tm.tm_mon = g_date_get_month (&start_date) - 1;
+ date_tm.tm_mday = g_date_get_day (&start_date);
/* We need to call this to set the weekday. */
mktime (&date_tm);
e_time_format_date_and_time (&date_tm,
diff --git a/widgets/misc/e-charset-picker.c b/widgets/misc/e-charset-picker.c
index 0199da5bfc..dcc3589367 100644
--- a/widgets/misc/e-charset-picker.c
+++ b/widgets/misc/e-charset-picker.c
@@ -25,6 +25,7 @@
#include "e-charset-picker.h"
#include <gal/widgets/e-gui-utils.h>
+#include <string.h>
#include <iconv.h>
#include <gtk/gtkvbox.h>
@@ -116,38 +117,57 @@ select_item (GtkMenuShell *menu_shell, GtkWidget *item)
static void
activate (GtkWidget *item, gpointer menu)
{
- g_object_set_data(G_OBJECT(menu), "activated_item", item);
+ g_object_set_data ((GObject *) menu, "activated_item", item);
}
static GtkWidget *
add_charset (GtkWidget *menu, ECharset *charset, gboolean free_name)
{
+ char *charset_name, *label, *u;
GtkWidget *item;
- char *label;
+
+ /* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */
+ if ((u = strchr (charset->name, '_'))) {
+ int extra = 1;
+ char *s, *d;
+
+ while ((u = strchr (u + 1, '_')))
+ extra++;
+
+ d = charset_name = g_alloca (strlen (charset->name) + extra + 1);
+ s = charset->name;
+ while (*s != '\0') {
+ if (*s == '_')
+ *d++ = '_';
+ *d++ = *s++;
+ }
+ *d = '\0';
+ } else {
+ charset_name = charset->name;
+ }
if (charset->subclass) {
label = g_strdup_printf ("%s, %s (%s)",
_(classnames[charset->class]),
_(charset->subclass),
- charset->name);
+ charset_name);
} else if (charset->class) {
label = g_strdup_printf ("%s (%s)",
_(classnames[charset->class]),
- charset->name);
+ charset_name);
} else {
- label = g_strdup (charset->name);
+ label = g_strdup (charset_name);
}
item = gtk_menu_item_new_with_label (label);
- g_object_set_data_full(G_OBJECT(item), "charset",
- charset->name, free_name ? g_free : NULL);
+ g_object_set_data_full ((GObject *) item, "charset",
+ charset->name, free_name ? g_free : NULL);
g_free (label);
-
+
gtk_widget_show (item);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- g_signal_connect((item), "activate",
- G_CALLBACK (activate), menu);
-
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ g_signal_connect (item, "activate", G_CALLBACK (activate), menu);
+
return item;
}
@@ -157,7 +177,7 @@ add_other_charset (GtkWidget *menu, GtkWidget *other, char *new_charset)
ECharset charset = { NULL, E_CHARSET_UNKNOWN, NULL };
GtkWidget *item;
iconv_t ic;
-
+
ic = iconv_open ("UTF-8", new_charset);
if (ic == (iconv_t)-1) {
GtkWidget *window = gtk_widget_get_ancestor (other, GTK_TYPE_WINDOW);
@@ -166,24 +186,25 @@ add_other_charset (GtkWidget *menu, GtkWidget *other, char *new_charset)
return FALSE;
}
iconv_close (ic);
-
+
/* Temporarily remove the "Other..." item */
- g_object_ref((other));
+ g_object_ref (other);
gtk_container_remove (GTK_CONTAINER (menu), other);
-
+
/* Create new menu item */
charset.name = new_charset;
item = add_charset (menu, &charset, TRUE);
-
+
/* And re-add "Other..." */
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), other);
- g_object_unref((other));
-
- g_object_set_data_full(G_OBJECT(menu), "other_charset",
- g_strdup (new_charset), g_free);
-
- g_object_set_data(G_OBJECT(menu), "activated_item", item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), other);
+ g_object_unref (other);
+
+ g_object_set_data_full ((GObject *) menu, "other_charset",
+ g_strdup (new_charset), g_free);
+
+ g_object_set_data ((GObject *) menu, "activated_item", item);
select_item (GTK_MENU_SHELL (menu), item);
+
return TRUE;
}
@@ -242,18 +263,18 @@ e_charset_picker_new (const char *default_charset)
GtkWidget *menu, *item;
int def, i;
const char *locale_charset;
-
+
g_get_charset (&locale_charset);
- if (!g_strcasecmp (locale_charset, "US-ASCII"))
+ if (!strcasecmp (locale_charset, "US-ASCII"))
locale_charset = "iso-8859-1";
-
+
if (!default_charset)
default_charset = locale_charset;
for (def = 0; def < num_charsets; def++) {
- if (!g_strcasecmp (charsets[def].name, default_charset))
+ if (!strcasecmp (charsets[def].name, default_charset))
break;
}
-
+
menu = gtk_menu_new ();
for (i = 0; i < num_charsets; i++) {
item = add_charset (menu, &charsets[i], FALSE);
@@ -262,29 +283,29 @@ e_charset_picker_new (const char *default_charset)
select_item (GTK_MENU_SHELL (menu), item);
}
}
-
+
/* do the Unknown/Other section */
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_menu_item_new ());
-
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_menu_item_new ());
+
if (def == num_charsets) {
ECharset other = { NULL, E_CHARSET_UNKNOWN, NULL };
-
+
/* Add an entry for @default_charset */
other.name = g_strdup (default_charset);
item = add_charset (menu, &other, TRUE);
activate (item, menu);
select_item (GTK_MENU_SHELL (menu), item);
- g_object_set_data_full(G_OBJECT(menu), "other_charset",
- g_strdup (default_charset), g_free);
+ g_object_set_data_full ((GObject *) menu, "other_charset",
+ g_strdup (default_charset), g_free);
def++;
}
-
+
item = gtk_menu_item_new_with_label (_("Other..."));
- g_signal_connect((item), "activate",
- G_CALLBACK (activate_other), menu);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-
+ g_signal_connect (item, "activate", G_CALLBACK (activate_other), menu);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
gtk_widget_show_all (menu);
+
return menu;
}
@@ -302,10 +323,10 @@ e_charset_picker_get_charset (GtkWidget *menu)
char *charset;
g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
-
+
item = gtk_menu_get_active (GTK_MENU (menu));
- charset = g_object_get_data(G_OBJECT(item), "charset");
-
+ charset = g_object_get_data ((GObject *) item, "charset");
+
return g_strdup (charset);
}
@@ -389,35 +410,57 @@ e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path,
int def, i;
g_get_charset (&locale_charset);
- if (!g_strcasecmp (locale_charset, "US-ASCII"))
+ if (!strcasecmp (locale_charset, "US-ASCII"))
locale_charset = "iso-8859-1";
if (!default_charset)
default_charset = locale_charset;
for (def = 0; def < num_charsets; def++) {
- if (!g_strcasecmp (charsets[def].name, default_charset))
+ if (!strcasecmp (charsets[def].name, default_charset))
break;
}
label = g_strdup (_("Character Encoding"));
encoded_label = bonobo_ui_util_encode_str (label);
menuitems = g_string_new ("");
- g_string_sprintf (menuitems, "<submenu name=\"ECharsetPicker\" label=\"%s\">\n", encoded_label);
+ g_string_append_printf (menuitems, "<submenu name=\"ECharsetPicker\" label=\"%s\">\n",
+ encoded_label);
g_free (encoded_label);
g_free (label);
for (i = 0; i < num_charsets; i++) {
char *command, *label, *encoded_label;
+ char *charset_name, *u;
+
+ /* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */
+ if ((u = strchr (charsets[i].name, '_'))) {
+ int extra = 1;
+ char *s, *d;
+
+ while ((u = strchr (u + 1, '_')))
+ extra++;
+
+ d = charset_name = g_alloca (strlen (charsets[i].name) + extra + 1);
+ s = charsets[i].name;
+ while (*s != '\0') {
+ if (*s == '_')
+ *d++ = '_';
+ *d++ = *s++;
+ }
+ *d = '\0';
+ } else {
+ charset_name = charsets[i].name;
+ }
if (charsets[i].subclass) {
label = g_strdup_printf ("%s, %s (%s)",
_(classnames[charsets[i].class]),
_(charsets[i].subclass),
- charsets[i].name);
+ charset_name);
} else {
label = g_strdup_printf ("%s (%s)",
_(classnames[charsets[i].class]),
- charsets[i].name);
+ charset_name);
}
encoded_label = bonobo_ui_util_encode_str (label);
@@ -430,8 +473,8 @@ e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path,
bonobo_ui_component_set (uic, "/commands", command, NULL);
g_free (command);
- g_string_sprintfa (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n",
- charsets[i].name);
+ g_string_append_printf (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n",
+ charsets[i].name);
g_free (encoded_label);
@@ -442,8 +485,29 @@ e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path,
if (def == num_charsets) {
char *command, *label, *encoded_label;
+ char *charset_name, *u;
+
+ /* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */
+ if ((u = strchr (default_charset, '_'))) {
+ int extra = 1;
+ char *s, *d;
+
+ while ((u = strchr (u + 1, '_')))
+ extra++;
+
+ d = charset_name = g_alloca (strlen (default_charset) + extra + 1);
+ s = (char *) default_charset;
+ while (*s != '\0') {
+ if (*s == '_')
+ *d++ = '_';
+ *d++ = *s++;
+ }
+ *d = '\0';
+ } else {
+ charset_name = (char *) default_charset;
+ }
- label = g_strdup_printf ("%s (%s)", _("Unknown"), default_charset);
+ label = g_strdup_printf ("%s (%s)", _("Unknown"), charset_name);
encoded_label = bonobo_ui_util_encode_str (label);
g_free (label);
@@ -455,8 +519,8 @@ e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path,
g_free (command);
g_string_append (menuitems, " <separator/>\n");
- g_string_sprintfa (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n",
- default_charset);
+ g_string_append_printf (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n",
+ default_charset);
g_free (encoded_label);
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
index 79982be307..a812c9d332 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -29,7 +29,10 @@
* time field with popups for entering a date.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include "e-dateedit.h"
#include "e-util-marshal.h"
@@ -1257,9 +1260,9 @@ on_date_popup_date_selected (ECalendarItem *calitem,
if (!e_calendar_item_get_selection (calitem, &start_date, &end_date))
return;
- e_date_edit_set_date (dedit, g_date_year (&start_date),
- g_date_month (&start_date),
- g_date_day (&start_date));
+ e_date_edit_set_date (dedit, g_date_get_year (&start_date),
+ g_date_get_month (&start_date),
+ g_date_get_day (&start_date));
}
diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c
index 28ac335273..673a22f297 100644
--- a/widgets/misc/e-filter-bar.c
+++ b/widgets/misc/e-filter-bar.c
@@ -22,7 +22,10 @@
* Boston, MA 02111-1307, USA.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <glib.h>
#include <gtk/gtksignal.h>
@@ -155,7 +158,7 @@ do_advanced (ESearchBar *esb)
efb->save_dialogue = gd;
gnome_dialog_set_default (GNOME_DIALOG (gd), 0);
- gtk_window_set_policy (GTK_WINDOW (gd), FALSE, TRUE, FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (gd), TRUE);
gtk_window_set_default_size (GTK_WINDOW (gd), 600, 300);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (gd)->vbox), w, TRUE, TRUE, 0);
gtk_widget_show (gd);
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index 2b58d98421..9845f76320 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -25,7 +25,10 @@
* Boston, MA 02111-1307, USA.
*/
+
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtkeventbox.h>
@@ -490,16 +493,16 @@ append_xml_menu_item (GString *xml,
const char *accelerator)
{
char *encoded_label;
-
+
encoded_label = bonobo_ui_util_encode_str (label);
- g_string_sprintfa (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"",
- name, verb, encoded_label);
+ g_string_append_printf (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"",
+ name, verb, encoded_label);
g_free (encoded_label);
-
+
if (accelerator != NULL)
- g_string_sprintfa (xml, " accel=\"%s\"", accelerator);
-
- g_string_sprintfa (xml, "/>");
+ g_string_append_printf (xml, " accel=\"%s\"", accelerator);
+
+ g_string_append (xml, "/>");
}
static void
@@ -509,37 +512,37 @@ setup_bonobo_menus (ESearchBar *esb)
GSList *p;
char *verb_name;
char *encoded_title;
-
+
xml = g_string_new ("");
-
+
encoded_title = bonobo_ui_util_encode_str (_("_Search"));
- g_string_sprintfa (xml, "<submenu name=\"Search\" label=\"%s\">", encoded_title);
+ g_string_append_printf (xml, "<submenu name=\"Search\" label=\"%s\">", encoded_title);
g_free (encoded_title);
-
- g_string_sprintfa (xml, "<placeholder name=\"SearchBar\">");
-
+
+ g_string_append (xml, "<placeholder name=\"SearchBar\">");
+
append_xml_menu_item (xml, "FindNow", _("_Find Now"), "ESearchBar:FindNow", NULL);
append_xml_menu_item (xml, "Clear", _("_Clear"), "ESearchBar:Clear", "*Control**Shift*b");
-
+
for (p = esb->menu_items; p != NULL; p = p->next) {
const ESearchBarItem *item;
-
+
item = (const ESearchBarItem *) p->data;
-
+
verb_name = verb_name_from_id (item->id);
bonobo_ui_component_add_verb (esb->ui_component, verb_name, search_verb_cb, esb);
-
+
if (item->text == NULL)
g_string_append (xml, "<separator/>");
else
append_xml_menu_item (xml, verb_name, item->text, verb_name, NULL);
-
+
g_free (verb_name);
}
-
- g_string_sprintfa (xml, "</placeholder>");
- g_string_sprintfa (xml, "</submenu>");
-
+
+ g_string_append (xml, "</placeholder>");
+ g_string_append (xml, "</submenu>");
+
bonobo_ui_component_set (esb->ui_component, "/menu/SearchPlaceholder", xml->str, NULL);
g_string_free (xml, TRUE);
diff --git a/widgets/misc/test-calendar.c b/widgets/misc/test-calendar.c
index f6e4efe3ab..f156e66599 100644
--- a/widgets/misc/test-calendar.c
+++ b/widgets/misc/test-calendar.c
@@ -154,12 +154,12 @@ on_selection_changed (ECalendarItem *calitem)
e_calendar_item_get_selection (calitem, &start_date, &end_date);
g_print ("Selection changed (D/M/Y): %i/%i/%i - %i/%i/%i\n",
- g_date_day (&start_date),
- g_date_month (&start_date),
- g_date_year (&start_date),
- g_date_day (&end_date),
- g_date_month (&end_date),
- g_date_year (&end_date));
+ g_date_get_day (&start_date),
+ g_date_get_month (&start_date),
+ g_date_get_year (&start_date),
+ g_date_get_day (&end_date),
+ g_date_get_month (&end_date),
+ g_date_get_year (&end_date));
}