[balsa] Gtk3 and glib deprecation cleanup
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Gtk3 and glib deprecation cleanup
- Date: Sun, 7 Nov 2010 14:25:47 +0000 (UTC)
commit 14607dbfd4cf53ab58637cbc2e7c2692e950fc89
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Nov 7 09:23:38 2010 -0500
Gtk3 and glib deprecation cleanup
ChangeLog | 45 ++++++
libbalsa/Makefile.am | 2 +
libbalsa/abook-completion.c | 6 +-
libbalsa/address-book-extern.c | 10 +-
libbalsa/address-book-gpe.c | 11 +--
libbalsa/address-book-ldap.c | 9 +-
libbalsa/address-book-rubrica.c | 30 ++--
libbalsa/address-book-text.c | 22 ++--
libbalsa/address-book-text.h | 3 +-
libbalsa/address-book.c | 6 +-
libbalsa/address-book.h | 6 +-
libbalsa/address-view.c | 3 +-
libbalsa/address.c | 10 +-
libbalsa/completion.c | 304 +++++++++++++++++++++++++++++++++++++++
libbalsa/completion.h | 98 +++++++++++++
libbalsa/imap/imap-handle.c | 8 +-
libbalsa/mailbox_imap.c | 10 +-
src/ab-window.c | 2 +
src/balsa-cite-bar.c | 11 +-
src/balsa-icons.c | 9 --
src/balsa-icons.h | 2 -
src/balsa-mblist.c | 12 ++
src/main-window.c | 16 ++-
src/main.c | 4 +-
src/sendmsg-window.c | 4 +
25 files changed, 549 insertions(+), 94 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f871d57..ac94747 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+2010-10-16 Peter Bloomfield
+
+ Implement LibBalsaCompletion as a copy of (deprecated)
+ GCompletion
+
+ * libbalsa/completion.c: new file.
+ * libbalsa/completion.h: new file.
+ * libbalsa/Makefile.am: build them.
+ * libbalsa/abook-completion.c: use LibBalsaCompletion.
+ * libbalsa/address-book-extern.c
+ (libbalsa_address_book_externq_alias_complete): ditto.
+ * libbalsa/address-book-gpe.c: ditto.
+ * libbalsa/address-book-ldap.c
+ (libbalsa_address_book_ldap_alias_complete): ditto.
+ * libbalsa/address-book-rubrica.c
+ (libbalsa_address_book_rubrica_init),
+ (libbalsa_address_book_rubrica_alias_complete),
+ (lbab_rubrica_load_xml): ditto.
+ * libbalsa/address-book-text.c (libbalsa_address_book_text_init),
+ (libbalsa_address_book_text_finalize), (lbab_text_load_file),
+ (libbalsa_address_book_text_alias_complete): ditto.
+ * libbalsa/address-book-text.h: ditto.
+ * libbalsa/address-book.c
+ (libbalsa_address_book_alias_complete): ditto.
+ * libbalsa/address-book.h: ditto.
+ * libbalsa/address-view.c (lbav_get_matching_addresses): ditto.
+
+2010-10-16 Albrecht DreÃ?
+
+ Gtk3 deprecation cleanup
+
+ * libbalsa/address.c (addrlist_drag_drop_cb):
+ * libbalsa/imap/imap-handle.c (imap_get_flag), (imap_cmd_get_tag):
+ * libbalsa/mailbox_imap.c (libbalsa_mailbox_imap_message_match),
+ (libbalsa_mailbox_imap_get_matchings),
+ (libbalsa_mailbox_imap_subscribe),
+ (libbalsa_imap_rename_subfolder), (libbalsa_imap_new_subfolder):
+ * src/ab-window.c (balsa_ab_window_init):
+ * src/balsa-cite-bar.c (balsa_cite_bar_expose):
+ * src/balsa-icons.c:
+ * src/balsa-icons.h:
+ * src/balsa-mblist.c (bmbl_drag_motion), (bmbl_drag_cb):
+ * src/main-window.c:
+ * src/sendmsg-window.c (drag_data_quote), (subject_not_empty):
+
2010-10-14 Peter Bloomfield
* libbalsa/mailbox_imap.c (imap_expunge_cb): do not remove
diff --git a/libbalsa/Makefile.am b/libbalsa/Makefile.am
index 35e1982..525b04a 100644
--- a/libbalsa/Makefile.am
+++ b/libbalsa/Makefile.am
@@ -62,6 +62,8 @@ libbalsa_a_SOURCES = \
body.h \
cell-renderer-button.c \
cell-renderer-button.h \
+ completion.c \
+ completion.h \
files.c \
files.h \
filter-error.c \
diff --git a/libbalsa/abook-completion.c b/libbalsa/abook-completion.c
index 22313c5..73472db 100644
--- a/libbalsa/abook-completion.c
+++ b/libbalsa/abook-completion.c
@@ -86,7 +86,7 @@ completion_data_free(CompletionData * data)
}
/*
- * The GCompletionFunc
+ * The LibBalsaCompletionFunc
*/
gchar *
completion_data_extract(CompletionData * data)
@@ -104,8 +104,8 @@ address_compare(LibBalsaAddress *a, LibBalsaAddress *b)
}
/*
- * A GCompletionStrncmpFunc for matching words instead of the whole
- * string.
+ * A LibBalsaCompletionStrncmpFunc for matching words instead of the
+ * whole string.
*
* s1 is the user input, s2 is the target.
*/
diff --git a/libbalsa/address-book-extern.c b/libbalsa/address-book-extern.c
index 0f43d53..2123678 100644
--- a/libbalsa/address-book-extern.c
+++ b/libbalsa/address-book-extern.c
@@ -88,8 +88,7 @@ static gboolean parse_externq_file(LibBalsaAddressBookExtern *addr_externq,
void *data);
static GList *libbalsa_address_book_externq_alias_complete(LibBalsaAddressBook *ab,
- const gchar * prefix,
- gchar ** new_prefix);
+ const gchar * prefix);
GType libbalsa_address_book_externq_get_type(void)
{
@@ -376,12 +375,10 @@ lbe_expand_cb(const gchar *email, const gchar *name, void *d)
static GList*
libbalsa_address_book_externq_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix)
+ const gchar * prefix)
{
LibBalsaAddressBookExtern *ex;
GList *res = NULL;
- if(new_prefix) *new_prefix = NULL;
g_return_val_if_fail(LIBBALSA_IS_ADDRESS_BOOK_EXTERN(ab), NULL);
@@ -395,8 +392,5 @@ libbalsa_address_book_externq_alias_complete(LibBalsaAddressBook * ab,
res = g_list_reverse(res);
- if(res != NULL && new_prefix)
- *new_prefix = internet_address_to_string(res->data, FALSE);
-
return res;
}
diff --git a/libbalsa/address-book-gpe.c b/libbalsa/address-book-gpe.c
index 16b6f14..79710c2 100644
--- a/libbalsa/address-book-gpe.c
+++ b/libbalsa/address-book-gpe.c
@@ -77,8 +77,7 @@ libbalsa_address_book_gpe_modify_address(LibBalsaAddressBook *ab,
static GList *libbalsa_address_book_gpe_alias_complete(LibBalsaAddressBook *ab,
- const gchar *prefix,
- gchar **new_prefix);
+ const gchar *prefix);
GType libbalsa_address_book_gpe_get_type(void)
{
@@ -710,7 +709,6 @@ struct gpe_completion_closure {
sqlite *db;
#endif /* HAVE_SQLITE3 */
const gchar *prefix;
- gchar **new_prefix;
GList *res;
};
@@ -747,16 +745,13 @@ gpe_read_completion(void *arg, int argc, char **argv, char **names)
ia = internet_address_mailbox_new(a->full_name, l->data);
gc->res = g_list_prepend(gc->res, ia);
}
- if(gc->new_prefix && !*gc->new_prefix)
- *gc->new_prefix = libbalsa_address_to_gchar(a, 0);
g_object_unref(G_OBJECT(a));
return 0;
}
static GList *
libbalsa_address_book_gpe_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix)
+ const gchar * prefix)
{
static const char *query =
"select distinct urn from contacts where "
@@ -779,10 +774,8 @@ libbalsa_address_book_gpe_alias_complete(LibBalsaAddressBook * ab,
return NULL;
}
- if(new_prefix) *new_prefix = NULL;
gcc.db = gpe_ab->db;
gcc.prefix = prefix;
- gcc.new_prefix = new_prefix;
gcc.res = NULL;
#ifdef HAVE_SQLITE3
if (prefix) {
diff --git a/libbalsa/address-book-ldap.c b/libbalsa/address-book-ldap.c
index 8d0add6..4b44e84 100644
--- a/libbalsa/address-book-ldap.c
+++ b/libbalsa/address-book-ldap.c
@@ -114,8 +114,7 @@ static void libbalsa_address_book_ldap_load_config(LibBalsaAddressBook *ab,
const gchar * prefix);
static GList *libbalsa_address_book_ldap_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix);
+ const gchar * prefix);
static LibBalsaAddress*
libbalsa_address_book_ldap_get_address(LibBalsaAddressBook * ab,
@@ -951,8 +950,7 @@ rfc_2254_escape(const gchar *raw)
static GList *
libbalsa_address_book_ldap_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix)
+ const gchar * prefix)
{
static struct timeval timeout = { 15, 0 }; /* 15 sec timeout */
LibBalsaAddressBookLdap *ldap_ab;
@@ -978,7 +976,6 @@ libbalsa_address_book_ldap_alias_complete(LibBalsaAddressBook * ab,
* Attempt to search for e-mail addresses. It returns success
* or failure, but not all the matches.
*/
- if(new_prefix) *new_prefix = NULL;
ldap = rfc_2254_escape(prefix);
filter = g_strdup_printf("(&(objectClass=organizationalPerson)(mail=*)"
@@ -1001,8 +998,6 @@ libbalsa_address_book_ldap_alias_complete(LibBalsaAddressBook * ab,
for(e = ldap_first_entry(ldap_ab->directory, result);
e != NULL; e = ldap_next_entry(ldap_ab->directory, e)) {
addr = lbabl_get_internet_address(ldap_ab->directory, e);
- if(new_prefix && !*new_prefix)
- *new_prefix = internet_address_to_string(addr, FALSE);
res = g_list_prepend(res, addr);
}
case LDAP_SIZELIMIT_EXCEEDED:
diff --git a/libbalsa/address-book-rubrica.c b/libbalsa/address-book-rubrica.c
index 8ec2997..f80e050 100644
--- a/libbalsa/address-book-rubrica.c
+++ b/libbalsa/address-book-rubrica.c
@@ -63,8 +63,7 @@ static LibBalsaABErr libbalsa_address_book_rubrica_load(LibBalsaAddressBook
gpointer data);
static GList
*libbalsa_address_book_rubrica_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- char **new_prefix);
+ const gchar * prefix);
static LibBalsaABErr
libbalsa_address_book_rubrica_add_address(LibBalsaAddressBook * ab,
LibBalsaAddress * new_address);
@@ -131,8 +130,9 @@ libbalsa_address_book_rubrica_init(LibBalsaAddressBookRubrica * ab_rubrica)
ab_text->mtime = 0;
ab_text->name_complete =
- g_completion_new((GCompletionFunc) completion_data_extract);
- g_completion_set_compare(ab_text->name_complete, strncmp_word);
+ libbalsa_completion_new((LibBalsaCompletionFunc)
+ completion_data_extract);
+ libbalsa_completion_set_compare(ab_text->name_complete, strncmp_word);
}
static void
@@ -220,26 +220,26 @@ libbalsa_address_book_rubrica_load(LibBalsaAddressBook * ab,
/* Alias complete method */
static GList *
libbalsa_address_book_rubrica_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- char **new_prefix)
+ const gchar * prefix)
{
LibBalsaAddressBookRubrica *ab_rubrica =
- LIBBALSA_ADDRESS_BOOK_RUBRICA(ab);
+ LIBBALSA_ADDRESS_BOOK_RUBRICA(ab);
LibBalsaAddressBookText *ab_text = LIBBALSA_ADDRESS_BOOK_TEXT(ab);
GList *list;
GList *res = NULL;
if (ab->expand_aliases == FALSE)
- return NULL;
+ return NULL;
if (lbab_rubrica_load_xml(ab_rubrica, NULL) != LBABERR_OK)
- return NULL;
+ return NULL;
for (list =
- g_completion_complete(ab_text->name_complete, (gchar *) prefix,
- new_prefix); list; list = list->next) {
- InternetAddress *ia = ((CompletionData *) list->data)->ia;
- res = g_list_prepend(res, g_object_ref(ia));
+ libbalsa_completion_complete(ab_text->name_complete,
+ (gchar *) prefix);
+ list; list = list->next) {
+ InternetAddress *ia = ((CompletionData *) list->data)->ia;
+ res = g_list_prepend(res, g_object_ref(ia));
}
return g_list_reverse(res);
@@ -429,7 +429,7 @@ lbab_rubrica_load_xml(LibBalsaAddressBookRubrica * ab_rubrica,
g_list_foreach(ab_text->name_complete->items,
(GFunc) completion_data_free, NULL);
- g_completion_clear_items(ab_text->name_complete);
+ libbalsa_completion_clear_items(ab_text->name_complete);
/* try to read the address book */
@@ -499,7 +499,7 @@ lbab_rubrica_load_xml(LibBalsaAddressBookRubrica * ab_rubrica,
}
completion_list = g_list_reverse(completion_list);
- g_completion_add_items(ab_text->name_complete, completion_list);
+ libbalsa_completion_add_items(ab_text->name_complete, completion_list);
g_list_free(completion_list);
return LBABERR_OK;
diff --git a/libbalsa/address-book-text.c b/libbalsa/address-book-text.c
index 9592180..a81f87b 100644
--- a/libbalsa/address-book-text.c
+++ b/libbalsa/address-book-text.c
@@ -80,8 +80,7 @@ libbalsa_address_book_text_load_config(LibBalsaAddressBook * ab,
const gchar * prefix);
static GList *
libbalsa_address_book_text_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix);
+ const gchar * prefix);
/* GObject class stuff */
@@ -150,8 +149,9 @@ libbalsa_address_book_text_init(LibBalsaAddressBookText * ab_text)
ab_text->mtime = 0;
ab_text->name_complete =
- g_completion_new((GCompletionFunc) completion_data_extract);
- g_completion_set_compare(ab_text->name_complete, strncmp_word);
+ libbalsa_completion_new((LibBalsaCompletionFunc)
+ completion_data_extract);
+ libbalsa_completion_set_compare(ab_text->name_complete, strncmp_word);
}
typedef struct {
@@ -192,7 +192,7 @@ libbalsa_address_book_text_finalize(GObject * object)
g_list_foreach(ab_text->name_complete->items,
(GFunc) completion_data_free, NULL);
- g_completion_free(ab_text->name_complete);
+ libbalsa_completion_free(ab_text->name_complete);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
@@ -312,7 +312,7 @@ lbab_text_load_file(LibBalsaAddressBookText * ab_text, FILE * stream)
g_list_foreach(ab_text->name_complete->items,
(GFunc) completion_data_free, NULL);
- g_completion_clear_items(ab_text->name_complete);
+ libbalsa_completion_clear_items(ab_text->name_complete);
parse_address =
LIBBALSA_ADDRESS_BOOK_TEXT_GET_CLASS(ab_text)->parse_address;
@@ -409,7 +409,7 @@ lbab_text_load_file(LibBalsaAddressBookText * ab_text, FILE * stream)
#endif /* MAKE_GROUP_BY_ORGANIZATION */
completion_list = g_list_reverse(completion_list);
- g_completion_add_items(ab_text->name_complete, completion_list);
+ libbalsa_completion_add_items(ab_text->name_complete, completion_list);
g_list_free(completion_list);
return TRUE;
@@ -702,8 +702,7 @@ libbalsa_address_book_text_load_config(LibBalsaAddressBook * ab,
/* Alias complete method */
static GList *
libbalsa_address_book_text_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- char **new_prefix)
+ const gchar * prefix)
{
LibBalsaAddressBookText *ab_text = LIBBALSA_ADDRESS_BOOK_TEXT(ab);
FILE *stream;
@@ -728,8 +727,9 @@ libbalsa_address_book_text_alias_complete(LibBalsaAddressBook * ab,
fclose(stream);
for (list =
- g_completion_complete(ab_text->name_complete, (gchar *) prefix,
- new_prefix); list; list = list->next) {
+ libbalsa_completion_complete(ab_text->name_complete,
+ (gchar *) prefix);
+ list; list = list->next) {
InternetAddress *ia = ((CompletionData *) list->data)->ia;
g_object_ref(ia);
res = g_list_prepend(res, ia);
diff --git a/libbalsa/address-book-text.h b/libbalsa/address-book-text.h
index 5121de0..70ee1fb 100644
--- a/libbalsa/address-book-text.h
+++ b/libbalsa/address-book-text.h
@@ -33,6 +33,7 @@
#include <time.h>
#include <stdio.h>
#include "address-book.h"
+#include "completion.h"
#define LIBBALSA_TYPE_ADDRESS_BOOK_TEXT \
(libbalsa_address_book_text_get_type())
@@ -59,7 +60,7 @@ struct _LibBalsaAddressBookText {
time_t mtime;
- GCompletion *name_complete;
+ LibBalsaCompletion *name_complete;
};
struct _LibBalsaAddressBookTextClass {
diff --git a/libbalsa/address-book.c b/libbalsa/address-book.c
index 8bb1139..a673b75 100644
--- a/libbalsa/address-book.c
+++ b/libbalsa/address-book.c
@@ -244,13 +244,11 @@ libbalsa_address_book_load_config(LibBalsaAddressBook * ab,
GList *
libbalsa_address_book_alias_complete(LibBalsaAddressBook * ab,
- const gchar * prefix,
- gchar ** new_prefix)
+ const gchar * prefix)
{
g_return_val_if_fail(LIBBALSA_IS_ADDRESS_BOOK(ab), NULL);
- return LIBBALSA_ADDRESS_BOOK_GET_CLASS(ab)->alias_complete(ab, prefix,
- new_prefix);
+ return LIBBALSA_ADDRESS_BOOK_GET_CLASS(ab)->alias_complete(ab, prefix);
}
diff --git a/libbalsa/address-book.h b/libbalsa/address-book.h
index f61abee..ee73527 100644
--- a/libbalsa/address-book.h
+++ b/libbalsa/address-book.h
@@ -92,8 +92,7 @@ struct _LibBalsaAddressBookClass {
void (*save_config) (LibBalsaAddressBook * ab, const gchar * prefix);
void (*load_config) (LibBalsaAddressBook * ab, const gchar * prefix);
- GList* (*alias_complete) (LibBalsaAddressBook * ab, const gchar *prefix,
- gchar ** new_prefix);
+ GList* (*alias_complete) (LibBalsaAddressBook * ab, const gchar *prefix);
};
GType libbalsa_address_book_get_type(void);
@@ -141,8 +140,7 @@ const gchar* libbalsa_address_book_strerror(LibBalsaAddressBook * ab,
*/
GList *libbalsa_address_book_alias_complete(LibBalsaAddressBook * ab,
- const gchar *prefix,
- gchar **new_prefix);
+ const gchar *prefix);
gboolean libbalsa_address_is_dist_list(const LibBalsaAddressBook *ab,
const LibBalsaAddress *address);
diff --git a/libbalsa/address-view.c b/libbalsa/address-view.c
index 307f49c..1054147 100644
--- a/libbalsa/address-view.c
+++ b/libbalsa/address-view.c
@@ -167,8 +167,7 @@ lbav_get_matching_addresses(LibBalsaAddressView * address_view,
match =
g_list_concat(match,
libbalsa_address_book_alias_complete(ab,
- prefix_f,
- NULL));
+ prefix_f));
}
g_free(prefix_f);
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 08402a6..6dcf138 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -913,15 +913,21 @@ addrlist_drag_drop_cb(GtkWidget *widget, GdkDragContext *context,
{
gboolean is_valid_drop_site;
GdkAtom target_type;
+ GList *targets;
/* Check to see if (x,y) is a valid drop site within widget */
is_valid_drop_site = TRUE;
/* If the source offers a target */
- if (context-> targets) {
+#if GTK_CHECK_VERSION(2,22,0)
+ targets = gdk_drag_context_list_targets(context);
+#else
+ targets = context->targets;
+#endif
+ if (targets) {
/* Choose the best target type */
target_type = GDK_POINTER_TO_ATOM
- (g_list_nth_data (context-> targets, LIBBALSA_ADDRESS_TRG_ADDRESS));
+ (g_list_nth_data (targets, LIBBALSA_ADDRESS_TRG_ADDRESS));
/* Request the data from the source. */
printf("drag_drop requests target=%p\n", target_type);
diff --git a/libbalsa/completion.c b/libbalsa/completion.c
new file mode 100644
index 0000000..9596a54
--- /dev/null
+++ b/libbalsa/completion.c
@@ -0,0 +1,304 @@
+/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* Balsa E-Mail Client
+ *
+ * Copyright (C) 1997-2010 Stuart Parmenter and others,
+ * See the file AUTHORS for a list.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+/*
+ * MT safe
+ */
+
+/*
+ * Borrowed for libbalsa on the deprecation of GCompletion (2010-10-16).
+ *
+ * Adapted to the LibBalsa namespace to avoid conflicts with the
+ * deprecated code.
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include "completion.h"
+
+/**
+ * SECTION: completion
+ * @title: Automatic String Completion
+ * @short_description: support for automatic completion using a group
+ * of target strings
+ *
+ * #LibBalsaCompletion provides support for automatic completion of a
+ * string using any group of target strings. It is typically used for
+ * file name completion as is common in many UNIX shells.
+ *
+ * A #LibBalsaCompletion is created using libbalsa_completion_new().
+ * Target items are added with * libbalsa_completion_add_items(),
+ * and libbalsa_completion_clear_items(). A completion attempt is
+ * requested with libbalsa_completion_complete() or
+ * libbalsa_completion_complete_utf8(). When no longer needed, the
+ * #LibBalsaCompletion is freed with libbalsa_completion_free().
+ *
+ * Items in the completion can be simple strings (e.g. filenames), or
+ * pointers to arbitrary data structures. If data structures are used
+ * you must provide a #LibBalsaCompletionFunc in
+ * libbalsa_completion_new(), which retrieves the item's string from the
+ * data structure. You can change the way in which strings are compared
+ * by setting a different #LibBalsaCompletionStrncmpFunc in
+ * libbalsa_completion_set_compare().
+ **/
+
+/**
+ * LibBalsaCompletion:
+ * @items: list of target items (strings or data structures).
+ * @func: function which is called to get the string associated with a
+ * target item. It is %NULL if the target items are strings.
+ * @prefix: the last prefix passed to libbalsa_completion_complete() or
+ * libbalsa_completion_complete_utf8().
+ * @cache: the list of items which begin with @prefix.
+ * @strncmp_func: The function to use when comparing strings. Use
+ * libbalsa_completion_set_compare() to modify this
+ * function.
+ *
+ * The data structure used for automatic completion.
+ **/
+
+/**
+ * LibBalsaCompletionFunc:
+ * @Param1: the completion item.
+ * @Returns: the string corresponding to the item.
+ *
+ * Specifies the type of the function passed to
+ * libbalsa_completion_new(). Itshould return the string corresponding
+ * to the given target item. This is used when you use data structures
+ * as #LibBalsaCompletion items.
+ **/
+
+/**
+ * LibBalsaCompletionStrncmpFunc:
+ * @s1: string to compare with @s2.
+ * @s2: string to compare with @s1.
+ * @n: maximal number of bytes to compare.
+ * @Returns: an integer less than, equal to, or greater than zero if
+ * the first @n bytes of @s1 is found, respectively, to be
+ * less than, to match, or to be greater than the first @n
+ * bytes of @s2.
+ *
+ * Specifies the type of the function passed to
+ * libbalsa_completion_set_compare(). This is used when you use strings as
+ * #LibBalsaCompletion items.
+ **/
+
+/**
+ * libbalsa_completion_new:
+ * @func: the function to be called to return the string representing
+ * an item in the #LibBalsaCompletion, or %NULL if strings are
+ * going to be used as the #LibBalsaCompletion items.
+ * @Returns: the new #LibBalsaCompletion.
+ *
+ * Creates a new #LibBalsaCompletion.
+ **/
+LibBalsaCompletion *
+libbalsa_completion_new(LibBalsaCompletionFunc func)
+{
+ LibBalsaCompletion *gcomp;
+
+ gcomp = g_new(LibBalsaCompletion, 1);
+ gcomp->items = NULL;
+ gcomp->cache = NULL;
+ gcomp->prefix = NULL;
+ gcomp->func = func;
+ gcomp->strncmp_func = strncmp;
+
+ return gcomp;
+}
+
+/**
+ * libbalsa_completion_add_items:
+ * @cmp: the #LibBalsaCompletion.
+ * @items: the list of items to add.
+ *
+ * Adds items to the #LibBalsaCompletion.
+ **/
+void
+libbalsa_completion_add_items(LibBalsaCompletion * cmp,
+ GList * items)
+{
+ GList *it;
+
+ g_return_if_fail(cmp != NULL);
+
+ /* optimize adding to cache? */
+ if (cmp->cache) {
+ g_list_free(cmp->cache);
+ cmp->cache = NULL;
+ }
+
+ if (cmp->prefix) {
+ g_free(cmp->prefix);
+ cmp->prefix = NULL;
+ }
+
+ it = items;
+ while (it) {
+ cmp->items = g_list_prepend(cmp->items, it->data);
+ it = it->next;
+ }
+}
+
+/**
+ * libbalsa_completion_clear_items:
+ * @cmp: the #LibBalsaCompletion.
+ *
+ * Removes all items from the #LibBalsaCompletion.
+ **/
+void
+libbalsa_completion_clear_items(LibBalsaCompletion * cmp)
+{
+ g_return_if_fail(cmp != NULL);
+
+ g_list_free(cmp->items);
+ cmp->items = NULL;
+ g_list_free(cmp->cache);
+ cmp->cache = NULL;
+ g_free(cmp->prefix);
+ cmp->prefix = NULL;
+}
+
+/**
+ * libbalsa_completion_complete:
+ * @cmp: the #LibBalsaCompletion.
+ * @prefix: the prefix string, typically typed by the user, which is
+ * compared with each of the items.
+ * @Returns: the list of items whose strings begin with @prefix. This
+ * should not be changed.
+ *
+ * Attempts to complete the string @prefix using the #LibBalsaCompletion
+ * target items.
+ **/
+GList *
+libbalsa_completion_complete(LibBalsaCompletion * cmp,
+ const gchar * prefix)
+{
+ gsize plen, len;
+ gboolean done = FALSE;
+ GList *list;
+
+ g_return_val_if_fail(cmp != NULL, NULL);
+ g_return_val_if_fail(prefix != NULL, NULL);
+
+ len = strlen(prefix);
+ if (cmp->prefix && cmp->cache) {
+ plen = strlen(cmp->prefix);
+ if (plen <= len && !cmp->strncmp_func(prefix, cmp->prefix, plen)) {
+ /* use the cache */
+ list = cmp->cache;
+ while (list) {
+ GList *next = list->next;
+
+ if (cmp->strncmp_func(prefix,
+ cmp->func ? cmp->func(list->
+ data) : (gchar
+ *)
+ list->data, len))
+ cmp->cache = g_list_delete_link(cmp->cache, list);
+
+ list = next;
+ }
+ done = TRUE;
+ }
+ }
+
+ if (!done) {
+ /* normal code */
+ g_list_free(cmp->cache);
+ cmp->cache = NULL;
+ list = cmp->items;
+ while (*prefix && list) {
+ if (!cmp->strncmp_func(prefix,
+ cmp->func ? cmp->func(list->
+ data) : (gchar *)
+ list->data, len))
+ cmp->cache = g_list_prepend(cmp->cache, list->data);
+ list = list->next;
+ }
+ }
+ if (cmp->prefix) {
+ g_free(cmp->prefix);
+ cmp->prefix = NULL;
+ }
+ if (cmp->cache)
+ cmp->prefix = g_strdup(prefix);
+
+ return *prefix ? cmp->cache : cmp->items;
+}
+
+/**
+ * libbalsa_completion_free:
+ * @cmp: the #LibBalsaCompletion.
+ *
+ * Frees all memory used by the #LibBalsaCompletion.
+ **/
+void
+libbalsa_completion_free(LibBalsaCompletion * cmp)
+{
+ g_return_if_fail(cmp != NULL);
+
+ libbalsa_completion_clear_items(cmp);
+ g_free(cmp);
+}
+
+/**
+ * libbalsa_completion_set_compare:
+ * @cmp: a #LibBalsaCompletion.
+ * @strncmp_func: the string comparison function.
+ *
+ * Sets the function to use for string comparisons. The default string
+ * comparison function is strncmp().
+ **/
+void
+libbalsa_completion_set_compare(LibBalsaCompletion * cmp,
+ LibBalsaCompletionStrncmpFunc strncmp_func)
+{
+ cmp->strncmp_func = strncmp_func;
+}
+
+#define __G_COMPLETION_C__
diff --git a/libbalsa/completion.h b/libbalsa/completion.h
new file mode 100644
index 0000000..95dce80
--- /dev/null
+++ b/libbalsa/completion.h
@@ -0,0 +1,98 @@
+/* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
+/* Balsa E-Mail Client
+ *
+ * Copyright (C) 1997-2010 Stuart Parmenter and others,
+ * See the file AUTHORS for a list.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* GLIB - Library of useful routines for C programming
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GLib Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GLib Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GLib at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+/*
+ * Borrowed for libbalsa on the deprecation of GCompletion (2010-10-16).
+ *
+ * Adapted to the LibBalsa namespace to avoid conflicts with the
+ * deprecated code.
+ */
+
+G_BEGIN_DECLS
+
+typedef struct _LibBalsaCompletion LibBalsaCompletion;
+
+typedef gchar *(*LibBalsaCompletionFunc) (gpointer);
+
+/* LibBalsaCompletion
+ */
+
+typedef gint (*LibBalsaCompletionStrncmpFunc) (const gchar * s1,
+ const gchar * s2,
+ gsize n);
+
+struct _LibBalsaCompletion {
+ GList *items;
+ LibBalsaCompletionFunc func;
+
+ gchar *prefix;
+ GList *cache;
+ LibBalsaCompletionStrncmpFunc strncmp_func;
+};
+
+LibBalsaCompletion *
+libbalsa_completion_new (LibBalsaCompletionFunc func);
+
+void
+libbalsa_completion_add_items (LibBalsaCompletion * cmp,
+ GList * items);
+
+void
+libbalsa_completion_clear_items (LibBalsaCompletion * cmp);
+
+GList *
+libbalsa_completion_complete (LibBalsaCompletion * cmp,
+ const gchar * prefix);
+
+void
+libbalsa_completion_set_compare (LibBalsaCompletion * cmp,
+ LibBalsaCompletionStrncmpFunc
+ strncmp_func);
+
+void
+libbalsa_completion_free (LibBalsaCompletion * cmp);
+
+G_END_DECLS
diff --git a/libbalsa/imap/imap-handle.c b/libbalsa/imap/imap-handle.c
index 05d8a71..1253697 100644
--- a/libbalsa/imap/imap-handle.c
+++ b/libbalsa/imap/imap-handle.c
@@ -892,8 +892,8 @@ imap_get_flag(struct siobuf *sio, char* flag, size_t len)
if(i<len-1) {
if (c < 0)
return c;
- flag[i] = '\0';
- } else flag[i+1] = '\0'; /* too long tag? */
+ }
+ flag[i] = '\0';
return c;
}
@@ -912,8 +912,8 @@ imap_cmd_get_tag(struct siobuf *sio, char* tag, size_t len)
if(i<len-1) {
if (c < 0)
return c;
- tag[i] = '\0';
- } else tag[i+1] = '\0'; /* too long tag? */
+ }
+ tag[i] = '\0';
return c;
}
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 6cce6cc..c31b39e 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -1391,7 +1391,7 @@ libbalsa_mailbox_imap_message_match(LibBalsaMailbox* mailbox, guint msgno,
matchings = search_iter->user_data;
if (!matchings) {
ImapSearchKey* query;
- ImapResult rc;
+ ImapResponse rc;
matchings = g_hash_table_new(NULL, NULL);
query = lbmi_build_imap_query(search_iter->condition, NULL);
@@ -1576,7 +1576,7 @@ GHashTable * libbalsa_mailbox_imap_get_matchings(LibBalsaMailboxImap* mbox,
gboolean * err)
{
ImapSearchKey* query;
- ImapResult rc = IMR_NO;
+ ImapResponse rc = IMR_NO;
ImapSearchData * cbdata;
*err = FALSE;
@@ -1699,7 +1699,7 @@ gboolean
libbalsa_mailbox_imap_subscribe(LibBalsaMailboxImap * mailbox,
gboolean subscribe)
{
- ImapResult rc;
+ ImapResponse rc;
ImapMboxHandle* handle;
g_return_val_if_fail(LIBBALSA_IS_MAILBOX_IMAP(mailbox), FALSE);
@@ -1792,7 +1792,7 @@ libbalsa_imap_rename_subfolder(LibBalsaMailboxImap* imap,
gboolean subscribe,
GError **err)
{
- ImapResult rc;
+ ImapResponse rc;
ImapMboxHandle* handle;
gchar *new_path;
char delim[2];
@@ -1831,7 +1831,7 @@ libbalsa_imap_new_subfolder(const gchar *parent, const gchar *folder,
gboolean subscribe, LibBalsaServer *server,
GError **err)
{
- ImapResult rc;
+ ImapResponse rc;
ImapMboxHandle* handle;
gchar *new_path;
diff --git a/src/ab-window.c b/src/ab-window.c
index 272ff25..77ad125 100644
--- a/src/ab-window.c
+++ b/src/ab-window.c
@@ -239,7 +239,9 @@ balsa_ab_window_init(BalsaAbWindow *ab)
/* hig defaults */
gtk_container_set_border_width(GTK_CONTAINER(ab), 6);
+#if !GTK_CHECK_VERSION(2,22,0)
gtk_dialog_set_has_separator(GTK_DIALOG(ab), FALSE);
+#endif
gtk_box_set_spacing(GTK_BOX(vbox), 12);
diff --git a/src/balsa-cite-bar.c b/src/balsa-cite-bar.c
index 7401784..35476e9 100644
--- a/src/balsa-cite-bar.c
+++ b/src/balsa-cite-bar.c
@@ -118,7 +118,8 @@ balsa_cite_bar_expose(GtkWidget * widget, GdkEventExpose * event)
if (!event->count) {
BalsaCiteBar *cite_bar = BALSA_CITE_BAR(widget);
GdkWindow *window = gtk_widget_get_window(widget);
- GdkGC *gc = gtk_widget_get_style(widget)->fg_gc[GTK_STATE_NORMAL];
+ cairo_t *cr = gdk_cairo_create(window);
+ GtkStyle *style = gtk_widget_get_style(widget);
GtkAllocation allocation;
int n;
@@ -128,12 +129,14 @@ balsa_cite_bar_expose(GtkWidget * widget, GdkEventExpose * event)
allocation.x = widget->allocation.x;
allocation.y = widget->allocation.y;
#endif /* GTK_CHECK_VERSION(2, 18, 0) */
+ gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
for (n = 0; n < cite_bar->bars; n++) {
- gdk_draw_rectangle(window, gc, TRUE,
- allocation.x, allocation.y,
- cite_bar->width, cite_bar->height);
+ cairo_rectangle(cr, allocation.x, allocation.y,
+ cite_bar->width, cite_bar->height);
+ cairo_fill(cr);
allocation.x += cite_bar->width + cite_bar->space;
}
+ cairo_destroy(cr);
}
return FALSE;
diff --git a/src/balsa-icons.c b/src/balsa-icons.c
index 553bd6d..136d823 100644
--- a/src/balsa-icons.c
+++ b/src/balsa-icons.c
@@ -55,15 +55,6 @@ typedef struct {
const gchar * def_id;
const gchar * fb_id;
} pixmap_fallback_t;
-
-
-void
-balsa_icon_create(const gchar ** data, GdkPixmap ** pmap, GdkBitmap ** bmap)
-{
- /* Is there any reason to use gdkpixbuf here? */
- *pmap = gdk_pixmap_create_from_xpm_d(gdk_get_default_root_window(),
- bmap, 0, (gchar **) data);
-}
static GHashTable *balsa_icon_table;
diff --git a/src/balsa-icons.h b/src/balsa-icons.h
index ab5f48c..84e55f5 100644
--- a/src/balsa-icons.h
+++ b/src/balsa-icons.h
@@ -96,7 +96,5 @@
void balsa_register_pixmaps(void);
void balsa_unregister_pixmaps(void);
void balsa_register_pixbufs(GtkWidget * widget);
-void balsa_icon_create(const gchar ** data, GdkPixmap ** pmap,
- GdkBitmap ** bmap);
const gchar * balsa_icon_id(const gchar * name);
#endif
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index 05c4a6c..37c682c 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -329,10 +329,17 @@ bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
gtk_tree_path_free(path);
+#if GTK_CHECK_VERSION(2,22,0)
+ gdk_drag_status(context,
+ (gdk_drag_context_get_actions(context) ==
+ GDK_ACTION_COPY) ? GDK_ACTION_COPY :
+ GDK_ACTION_MOVE, time);
+#else
gdk_drag_status(context,
(context->actions ==
GDK_ACTION_COPY) ? GDK_ACTION_COPY :
GDK_ACTION_MOVE, time);
+#endif
return (ret_val && can_drop);
}
@@ -855,8 +862,13 @@ bmbl_drag_cb(GtkWidget * widget, GdkDragContext * context,
/* cannot transfer to the originating mailbox */
if (mailbox != NULL && mailbox != orig_mailbox)
+#if GTK_CHECK_VERSION(2,22,0)
+ balsa_index_transfer(orig_index, selected, mailbox,
+ gdk_drag_context_get_selected_action(context) != GDK_ACTION_MOVE);
+#else
balsa_index_transfer(orig_index, selected, mailbox,
context->action != GDK_ACTION_MOVE);
+#endif
gtk_tree_path_free(path);
}
balsa_index_selected_msgnos_free(orig_index, selected);
diff --git a/src/main-window.c b/src/main-window.c
index 4d2606a..f6a2a14 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -287,7 +287,7 @@ static void bw_notebook_size_allocate_cb(GtkWidget * notebook,
static void bw_size_allocate_cb(GtkWidget * window, GtkAllocation * alloc);
static void bw_notebook_switch_page_cb(GtkWidget * notebook,
- GtkNotebookPage * page,
+ void * page,
guint page_num,
gpointer data);
#if !defined(ENABLE_TOUCH_UI)
@@ -4887,7 +4887,7 @@ bw_size_allocate_cb(GtkWidget * window, GtkAllocation * alloc)
*/
static void
bw_notebook_switch_page_cb(GtkWidget * notebook,
- GtkNotebookPage * notebookpage, guint page_num,
+ void * notebookpage, guint page_num,
gpointer data)
{
BalsaWindow *window = BALSA_WINDOW(data);
@@ -5169,8 +5169,13 @@ bw_notebook_drag_received_cb(GtkWidget * widget, GdkDragContext * context,
mailbox = index->mailbox_node->mailbox;
if (mailbox != NULL && mailbox != orig_mailbox)
+#if GTK_CHECK_VERSION(2,22,0)
+ balsa_index_transfer(orig_index, selected, mailbox,
+ gdk_drag_context_get_selected_action(context) != GDK_ACTION_MOVE);
+#else
balsa_index_transfer(orig_index, selected, mailbox,
context->action != GDK_ACTION_MOVE);
+#endif
balsa_index_selected_msgnos_free(orig_index, selected);
}
@@ -5179,10 +5184,17 @@ static gboolean bw_notebook_drag_motion_cb(GtkWidget * widget,
gint x, gint y, guint time,
gpointer user_data)
{
+#if GTK_CHECK_VERSION(2,22,0)
+ gdk_drag_status(context,
+ (gdk_drag_context_get_actions(context) ==
+ GDK_ACTION_COPY) ? GDK_ACTION_COPY :
+ GDK_ACTION_MOVE, time);
+#else
gdk_drag_status(context,
(context->actions ==
GDK_ACTION_COPY) ? GDK_ACTION_COPY :
GDK_ACTION_MOVE, time);
+#endif
return FALSE;
}
diff --git a/src/main.c b/src/main.c
index ed99ea9..f073e45 100644
--- a/src/main.c
+++ b/src/main.c
@@ -168,7 +168,7 @@ enum {
static UniqueResponse
mw_message_received_cb(UniqueApp *app,
- UniqueCommand command,
+ gint command,
UniqueMessageData *message,
guint message_time,
gpointer user_data)
@@ -182,7 +182,7 @@ mw_message_received_cb(UniqueApp *app,
gchar **uris, **p;
BalsaSendmsg *snd;
- switch (command) {
+ switch ((gint) command) {
case UNIQUE_ACTIVATE:
/* move the main window to the screen that sent us the command */
gtk_window_set_screen(window,
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 0d47cec..e75d63b 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -3080,8 +3080,10 @@ drag_data_quote(GtkWidget * widget,
GArray *selected;
guint i;
+#if !GTK_CHECK_VERSION(2,22,0)
if (context->action == GDK_ACTION_ASK)
context->action = GDK_ACTION_COPY;
+#endif
switch(info) {
case TARGET_MESSAGES:
@@ -5671,7 +5673,9 @@ subject_not_empty(BalsaSendmsg * bsmsg)
gtk_window_set_modal (GTK_WINDOW (no_subj_dialog), TRUE);
gtk_window_set_resizable (GTK_WINDOW (no_subj_dialog), FALSE);
gtk_window_set_type_hint (GTK_WINDOW (no_subj_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+#if !GTK_CHECK_VERSION(2,22,0)
gtk_dialog_set_has_separator (GTK_DIALOG (no_subj_dialog), FALSE);
+#endif
dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(no_subj_dialog));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]