Mercurial > pidgin
changeset 29086:e2c8fe39a2f1
propagate from branch 'im.pidgin.pidgin' (head 458e696572314f8fd2d259d40713ad955dd82581)
to branch 'im.pidgin.pidgin.next.minor' (head 869b7c49cec24db5a508b838839d20cb497c47ab)
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 23 Aug 2009 02:37:12 +0000 |
parents | 208f4d20ac5d (current diff) 39005e0d26a0 (diff) |
children | 2dcff225172e |
files | pidgin/gtkblist.c pidgin/gtkcelllayout.c pidgin/gtkcelllayout.h pidgin/gtkcellrendererprogress.c pidgin/gtkcellrendererprogress.h pidgin/gtkcellview.c pidgin/gtkcellview.h pidgin/gtkcellviewmenuitem.c pidgin/gtkcellviewmenuitem.h pidgin/gtkexpander.c pidgin/gtkexpander.h pidgin/pidgincombobox.c pidgin/pidgincombobox.h |
diffstat | 39 files changed, 29 insertions(+), 8256 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Aug 23 02:11:21 2009 +0000 +++ b/ChangeLog Sun Aug 23 02:37:12 2009 +0000 @@ -1,5 +1,7 @@ Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul +version 2.7.0 (??/??/????): + version 2.6.2 (??/??/2009): libpurple: * Fix --disable-avahi to actually disable it in configure, as opposed
--- a/ChangeLog.API Sun Aug 23 02:11:21 2009 +0000 +++ b/ChangeLog.API Sun Aug 23 02:37:12 2009 +0000 @@ -1,5 +1,7 @@ Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul +version 2.7.0 (??/??/????): + version 2.6.1 (08/18/2009): No changes
--- a/ChangeLog.win32 Sun Aug 23 02:11:21 2009 +0000 +++ b/ChangeLog.win32 Sun Aug 23 02:37:12 2009 +0000 @@ -1,3 +1,5 @@ +version 2.7.0 (??/??/????): + version 2.6.1 (08/18/2009): * No changes
--- a/configure.ac Sun Aug 23 02:11:21 2009 +0000 +++ b/configure.ac Sun Aug 23 02:37:12 2009 +0000 @@ -43,19 +43,19 @@ # # Make sure to update finch/libgnt/configure.ac with libgnt version changes. # -m4_define([purple_lt_current], [6]) +m4_define([purple_lt_current], [7]) m4_define([purple_major_version], [2]) -m4_define([purple_minor_version], [6]) -m4_define([purple_micro_version], [2]) +m4_define([purple_minor_version], [7]) +m4_define([purple_micro_version], [0]) m4_define([purple_version_suffix], [devel]) m4_define([purple_version], [purple_major_version.purple_minor_version.purple_micro_version]) m4_define([purple_display_version], purple_version[]m4_ifdef([purple_version_suffix],[purple_version_suffix])) -m4_define([gnt_lt_current], [6]) +m4_define([gnt_lt_current], [7]) m4_define([gnt_major_version], [2]) -m4_define([gnt_minor_version], [6]) -m4_define([gnt_micro_version], [2]) +m4_define([gnt_minor_version], [7]) +m4_define([gnt_micro_version], [0]) m4_define([gnt_version_suffix], [devel]) m4_define([gnt_version], [gnt_major_version.gnt_minor_version.gnt_micro_version]) @@ -310,9 +310,9 @@ ) dnl ####################################################################### -dnl # Check for GLib 2.0 (required) +dnl # Check for GLib 2.12 (required) dnl ####################################################################### -PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.4.0 gobject-2.0 gmodule-2.0 gthread-2.0], , [ +PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12.0 gobject-2.0 gmodule-2.0 gthread-2.0], , [ AC_MSG_RESULT(no) AC_MSG_ERROR([ @@ -352,7 +352,7 @@ [enable_consoleui=$enableval force_finch=$enableval], [enable_consoleui=yes force_finch=no]) dnl ####################################################################### -dnl # Check for GTK+ 2.0 and other things used by the GTK UI +dnl # Check for GTK+ 2.10 and other things used by the GTK UI dnl ####################################################################### AC_ARG_ENABLE(screensaver, [AC_HELP_STRING([--disable-screensaver], @@ -399,11 +399,11 @@ fi if test "x$enable_gtkui" = "xyes" ; then - PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.4.0], , [ + PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.10.0], , [ AC_MSG_RESULT(no) AC_MSG_ERROR([ -You must have GTK+ 2.4.0 or newer development headers installed to compile +You must have GTK+ 2.10.0 or newer development headers installed to compile Pidgin. If you want to build only Finch then specify --disable-gtkui when running configure. ])])
--- a/finch/libgnt/configure.ac Sun Aug 23 02:11:21 2009 +0000 +++ b/finch/libgnt/configure.ac Sun Aug 23 02:37:12 2009 +0000 @@ -24,10 +24,10 @@ # Make sure to update ../../configure.ac with libgnt version changes. # -m4_define([gnt_lt_current], [6]) +m4_define([gnt_lt_current], [7]) m4_define([gnt_major_version], [2]) -m4_define([gnt_minor_version], [6]) -m4_define([gnt_micro_version], [2]) +m4_define([gnt_minor_version], [7]) +m4_define([gnt_micro_version], [0]) m4_define([gnt_version_suffix], [devel]) m4_define([gnt_version], [gnt_major_version.gnt_minor_version.gnt_micro_version])
--- a/libpurple/core.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/core.c Sun Aug 23 02:37:12 2009 +0000 @@ -496,7 +496,6 @@ if (purple_strequal(entry, "logs")) { char *link; -#if GLIB_CHECK_VERSION(2,4,0) GError *err = NULL; if ((link = g_file_read_link(name, &err)) == NULL) @@ -512,27 +511,6 @@ g_free(old_user_dir); return FALSE; } -#else - char buf[MAXPATHLEN]; - size_t linklen; - - if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) - { - char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); - purple_debug_error("core", "Error reading symlink %s: %s. Please report this at " PURPLE_DEVEL_WEBSITE "\n", - name_utf8, g_strerror(errno)); - g_free(name_utf8); - g_free(name); - g_dir_close(dir); - g_free(status_file); - g_free(old_user_dir); - return FALSE; - } - buf[linklen] = '\0'; - - /* This way we don't have to GLIB_VERSION_CHECK every g_free(link) below. */ - link = g_strdup(buf); -#endif logs_dir = g_build_filename(user_dir, "logs", NULL);
--- a/libpurple/internal.h Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/internal.h Sun Aug 23 02:37:12 2009 +0000 @@ -118,36 +118,13 @@ # include <unistd.h> #endif -/* MAXPATHLEN should only be used with readlink() on glib < 2.4.0. For - * anything else, use g_file_read_link() or other dynamic functions. This is - * important because Hurd has no hard limits on path length. */ -#if !GLIB_CHECK_VERSION(2,4,0) -# ifndef MAXPATHLEN -# ifdef PATH_MAX -# define MAXPATHLEN PATH_MAX -# else -# define MAXPATHLEN 1024 -# endif -# endif -#endif - #ifndef HOST_NAME_MAX # define HOST_NAME_MAX 255 #endif #include <glib.h> -#if !GLIB_CHECK_VERSION(2,4,0) -# define G_MAXUINT32 ((guint32) 0xffffffff) -#endif -#ifndef G_MAXSIZE -# if GLIB_SIZEOF_LONG == 8 -# define G_MAXSIZE ((gsize) 0xffffffffffffffff) -# else -# define G_MAXSIZE ((gsize) 0xffffffff) -# endif -#endif - +/* This wasn't introduced until Glib 2.14 :( */ #ifndef G_MAXSSIZE # if GLIB_SIZEOF_LONG == 8 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff) @@ -156,80 +133,12 @@ # endif #endif -#if GLIB_CHECK_VERSION(2,6,0) -# include <glib/gstdio.h> -#endif - -#if !GLIB_CHECK_VERSION(2,6,0) -# define g_freopen freopen -# define g_fopen fopen -# define g_rmdir rmdir -# define g_remove remove -# define g_unlink unlink -# define g_lstat lstat -# define g_stat stat -# define g_mkdir mkdir -# define g_rename rename -# define g_open open -#endif - -#if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32 -# define g_access access -#endif - -#if !GLIB_CHECK_VERSION(2,10,0) -# define g_slice_new(type) g_new(type, 1) -# define g_slice_new0(type) g_new0(type, 1) -# define g_slice_free(type, mem) g_free(mem) -#endif +#include <glib/gstdio.h> #ifdef _WIN32 #include "win32dep.h" #endif -/* ugly ugly ugly */ -/* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT - * are only defined in Glib >= 2.4 */ -#ifndef G_GINT64_MODIFIER -# if GLIB_SIZEOF_LONG == 8 -# define G_GINT64_MODIFIER "l" -# else -# define G_GINT64_MODIFIER "ll" -# endif -#endif - -#ifndef G_GSIZE_MODIFIER -# if GLIB_SIZEOF_LONG == 8 -# define G_GSIZE_MODIFIER "l" -# else -# define G_GSIZE_MODIFIER "" -# endif -#endif - -#ifndef G_GSIZE_FORMAT -# if GLIB_SIZEOF_LONG == 8 -# define G_GSIZE_FORMAT "lu" -# else -# define G_GSIZE_FORMAT "u" -# endif -#endif - -#ifndef G_GSSIZE_FORMAT -# if GLIB_SIZEOF_LONG == 8 -# define G_GSSIZE_FORMAT "li" -# else -# define G_GSSIZE_FORMAT "i" -# endif -#endif - -#ifndef G_GNUC_NULL_TERMINATED -# if __GNUC__ >= 4 -# define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) -# else -# define G_GNUC_NULL_TERMINATED -# endif -#endif - #ifdef HAVE_CONFIG_H #if SIZEOF_TIME_T == 4 # define PURPLE_TIME_T_MODIFIER "lu" @@ -242,38 +151,6 @@ #include <glib-object.h> -#ifndef G_DEFINE_TYPE -#define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \ -\ -static void type_name##_init (TypeName *self); \ -static void type_name##_class_init (TypeName##Class *klass); \ -static gpointer type_name##_parent_class = NULL; \ -static void type_name##_class_intern_init (gpointer klass) \ -{ \ - type_name##_parent_class = g_type_class_peek_parent (klass); \ - type_name##_class_init ((TypeName##Class*) klass); \ -} \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static GType g_define_type_id = 0; \ - if (G_UNLIKELY (g_define_type_id == 0)) \ - { \ - g_define_type_id = \ - g_type_register_static_simple (TYPE_PARENT, \ - g_intern_static_string (#TypeName), \ - sizeof (TypeName##Class), \ - (GClassInitFunc)type_name##_class_intern_init, \ - sizeof (TypeName), \ - (GInstanceInitFunc)type_name##_init, \ - (GTypeFlags) 0); \ - } \ - return g_define_type_id; \ -} /* closes type_name##_get_type() */ - -#endif - /* Safer ways to work with static buffers. When using non-static * buffers, either use g_strdup_* functions (preferred) or use * g_strlcpy/g_strlcpy directly. */
--- a/libpurple/plugin.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/plugin.c Sun Aug 23 02:37:12 2009 +0000 @@ -254,11 +254,7 @@ * * G_MODULE_BIND_LOCAL was added in glib 2.3.3. */ -#if GLIB_CHECK_VERSION(2,3,3) plugin->handle = g_module_open(filename, G_MODULE_BIND_LOCAL); -#else - plugin->handle = g_module_open(filename, 0); -#endif if (plugin->handle == NULL) { @@ -287,11 +283,7 @@ purple_debug_error("plugins", "%s is not loadable: %s\n", plugin->path, plugin->error); } -#if GLIB_CHECK_VERSION(2,3,3) plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); -#else - plugin->handle = g_module_open(filename, G_MODULE_BIND_LAZY); -#endif if (plugin->handle == NULL) {
--- a/libpurple/plugins/autoaccept.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/plugins/autoaccept.c Sun Aug 23 02:37:12 2009 +0000 @@ -28,13 +28,7 @@ /* System headers */ #include <glib.h> -#if GLIB_CHECK_VERSION(2,6,0) -# include <glib/gstdio.h> -#else -# include <sys/types.h> -# include <sys/stat.h> -# define g_mkdir mkdir -#endif +#include <glib/gstdio.h> /* Purple headers */ #include <plugin.h>
--- a/libpurple/protocols/jabber/jingle/session.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/session.c Sun Aug 23 02:37:12 2009 +0000 @@ -367,7 +367,6 @@ g_hash_table_lookup(js->sessions, sid) : NULL; } -#if GLIB_CHECK_VERSION(2,4,0) static gboolean find_by_jid_ghr(gpointer key, gpointer value, gpointer user_data) { @@ -387,58 +386,12 @@ return FALSE; } -#else /* GLIB_CHECK_VERSION 2.4.0 */ - -/* Ugly code; g_hash_table_find version above is much nicer */ -struct session_find_jid -{ - const gchar *jid; - JingleSession *ret; - gboolean use_bare; -}; - -static void find_by_jid_ghr(gpointer key, gpointer value, gpointer user_data) -{ - JingleSession *session = (JingleSession *)value; - struct session_find_jid *data = user_data; - gchar *remote_jid; - gchar *cmp_jid; - - if (data->ret != NULL) - return; - - remote_jid = jingle_session_get_remote_jid(session); - cmp_jid = data->use_bare ? jabber_get_bare_jid(remote_jid) - : g_strdup(remote_jid); - g_free(remote_jid); - - if (g_str_equal(data->jid, cmp_jid)) - data->ret = session; - - g_free(cmp_jid); -} -#endif /* GLIB_CHECK_VERSION 2.4.0 */ - JingleSession * jingle_session_find_by_jid(JabberStream *js, const gchar *jid) { -#if GLIB_CHECK_VERSION(2,4,0) return js->sessions != NULL ? g_hash_table_find(js->sessions, find_by_jid_ghr, (gpointer)jid) : NULL; -#else - struct session_find_jid data; - - if (js->sessions == NULL) - return NULL; - - data.jid = jid; - data.ret = NULL; - data.use_bare = g_utf8_strchr(jid, -1, '/') == NULL; - - g_hash_table_foreach(js->sessions, find_by_jid_ghr, &data); - return data.ret; -#endif } static xmlnode *
--- a/libpurple/protocols/msn/nexus.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/protocols/msn/nexus.c Sun Aug 23 02:37:12 2009 +0000 @@ -244,15 +244,6 @@ gpointer data; }; -#if !GLIB_CHECK_VERSION(2, 12, 0) -static gboolean -nexus_remove_all_cb(gpointer key, gpointer val, gpointer data) -{ - return TRUE; -} -#endif - - static gboolean nexus_parse_token(MsnNexus *nexus, int id, xmlnode *node) { @@ -281,12 +272,7 @@ if (token_str == NULL) return FALSE; -#if GLIB_CHECK_VERSION(2, 12, 0) g_hash_table_remove_all(nexus->tokens[id].token); -#else - g_hash_table_foreach_remove(nexus->tokens[id].token, - nexus_remove_all_cb, NULL); -#endif elems = g_strsplit(token_str, "&", 0);
--- a/libpurple/protocols/msn/state.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/protocols/msn/state.c Sun Aug 23 02:37:12 2009 +0000 @@ -114,11 +114,7 @@ * 6: Album * 7: ? */ -#if GLIB_CHECK_VERSION(2,6,0) strings = g_strv_length(cmedia_array); -#else - while (cmedia_array[++strings] != NULL); -#endif if (strings >= 4 && !strcmp(cmedia_array[2], "1")) { parsed = TRUE;
--- a/libpurple/protocols/yahoo/libymsg.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/protocols/yahoo/libymsg.c Sun Aug 23 02:37:12 2009 +0000 @@ -1679,11 +1679,8 @@ char *crumb = NULL; char *crypt = NULL; -#if GLIB_CHECK_VERSION(2,6,0) totalelements = g_strv_length(split_data); -#else - while (split_data[++totalelements] != NULL); -#endif + if (totalelements >= 4) { response_no = strtol(split_data[0], NULL, 10); crumb = g_strdup(split_data[1] + strlen("crumb=")); @@ -1765,11 +1762,8 @@ int response_no = -1; char *token = NULL; -#if GLIB_CHECK_VERSION(2,6,0) totalelements = g_strv_length(split_data); -#else - while (split_data[++totalelements] != NULL); -#endif + if(totalelements == 1) response_no = strtol(split_data[0], NULL, 10); else if(totalelements >= 2) {
--- a/libpurple/util.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/util.c Sun Aug 23 02:37:12 2009 +0000 @@ -220,50 +220,12 @@ gchar * purple_base64_encode(const guchar *data, gsize len) { -#if GLIB_CHECK_VERSION(2,12,0) return g_base64_encode(data, len); -#else - char *out, *rv; - - g_return_val_if_fail(data != NULL, NULL); - g_return_val_if_fail(len > 0, NULL); - - rv = out = g_malloc(((len/3)+1)*4 + 1); - - for (; len >= 3; len -= 3) - { - *out++ = alphabet[data[0] >> 2]; - *out++ = alphabet[((data[0] << 4) & 0x30) | (data[1] >> 4)]; - *out++ = alphabet[((data[1] << 2) & 0x3c) | (data[2] >> 6)]; - *out++ = alphabet[data[2] & 0x3f]; - data += 3; - } - - if (len > 0) - { - unsigned char fragment; - - *out++ = alphabet[data[0] >> 2]; - fragment = (data[0] << 4) & 0x30; - - if (len > 1) - fragment |= data[1] >> 4; - - *out++ = alphabet[fragment]; - *out++ = (len < 2) ? '=' : alphabet[(data[1] << 2) & 0x3c]; - *out++ = '='; - } - - *out = '\0'; - - return rv; -#endif /* GLIB < 2.12.0 */ } guchar * purple_base64_decode(const char *str, gsize *ret_len) { -#if GLIB_CHECK_VERSION(2,12,0) /* * We want to allow ret_len to be NULL for backward compatibility, * but g_base64_decode() requires a valid length variable. So if @@ -271,69 +233,6 @@ */ gsize unused; return g_base64_decode(str, ret_len != NULL ? ret_len : &unused); -#else - guchar *out = NULL; - char tmp = 0; - const char *c; - gint32 tmp2 = 0; - int len = 0, n = 0; - - g_return_val_if_fail(str != NULL, NULL); - - c = str; - - while (*c) { - if (*c >= 'A' && *c <= 'Z') { - tmp = *c - 'A'; - } else if (*c >= 'a' && *c <= 'z') { - tmp = 26 + (*c - 'a'); - } else if (*c >= '0' && *c <= 57) { - tmp = 52 + (*c - '0'); - } else if (*c == '+') { - tmp = 62; - } else if (*c == '/') { - tmp = 63; - } else if (*c == '\r' || *c == '\n') { - c++; - continue; - } else if (*c == '=') { - if (n == 3) { - out = g_realloc(out, len + 2); - out[len] = (guchar)(tmp2 >> 10) & 0xff; - len++; - out[len] = (guchar)(tmp2 >> 2) & 0xff; - len++; - } else if (n == 2) { - out = g_realloc(out, len + 1); - out[len] = (guchar)(tmp2 >> 4) & 0xff; - len++; - } - break; - } - tmp2 = ((tmp2 << 6) | (tmp & 0xff)); - n++; - if (n == 4) { - out = g_realloc(out, len + 3); - out[len] = (guchar)((tmp2 >> 16) & 0xff); - len++; - out[len] = (guchar)((tmp2 >> 8) & 0xff); - len++; - out[len] = (guchar)(tmp2 & 0xff); - len++; - tmp2 = 0; - n = 0; - } - c++; - } - - out = g_realloc(out, len + 1); - out[len] = 0; - - if (ret_len != NULL) - *ret_len = len; - - return out; -#endif /* GLIB < 2.12.0 */ } /************************************************************************** @@ -2656,56 +2555,7 @@ int purple_build_dir (const char *path, int mode) { -#if GLIB_CHECK_VERSION(2,8,0) return g_mkdir_with_parents(path, mode); -#else - char *dir, **components, delim[] = { G_DIR_SEPARATOR, '\0' }; - int cur, len; - - g_return_val_if_fail(path != NULL, -1); - - dir = g_new0(char, strlen(path) + 1); - components = g_strsplit(path, delim, -1); - len = 0; - for (cur = 0; components[cur] != NULL; cur++) { - /* If you don't know what you're doing on both - * win32 and *NIX, stay the hell away from this code */ - if(cur > 1) - dir[len++] = G_DIR_SEPARATOR; - strcpy(dir + len, components[cur]); - len += strlen(components[cur]); - if(cur == 0) - dir[len++] = G_DIR_SEPARATOR; - - if(g_file_test(dir, G_FILE_TEST_IS_DIR)) { - continue; -#ifdef _WIN32 - /* allow us to create subdirs on UNC paths - * (\\machinename\path\to\blah) - * g_file_test() doesn't work on "\\machinename" */ - } else if (cur == 2 && dir[0] == '\\' && dir[1] == '\\' - && components[cur + 1] != NULL) { - continue; -#endif - } else if(g_file_test(dir, G_FILE_TEST_EXISTS)) { - purple_debug_warning("build_dir", "bad path: %s\n", path); - g_strfreev(components); - g_free(dir); - return -1; - } - - if (g_mkdir(dir, mode) < 0) { - purple_debug_warning("build_dir", "mkdir: %s\n", g_strerror(errno)); - g_strfreev(components); - g_free(dir); - return -1; - } - } - - g_strfreev(components); - g_free(dir); - return 0; -#endif } /* @@ -3215,30 +3065,13 @@ gboolean purple_str_has_prefix(const char *s, const char *p) { -#if GLIB_CHECK_VERSION(2,2,0) return g_str_has_prefix(s, p); -#else - g_return_val_if_fail(s != NULL, FALSE); - g_return_val_if_fail(p != NULL, FALSE); - - return (!strncmp(s, p, strlen(p))); -#endif } gboolean purple_str_has_suffix(const char *s, const char *x) { -#if GLIB_CHECK_VERSION(2,2,0) return g_str_has_suffix(s, x); -#else - int off; - - g_return_val_if_fail(s != NULL, FALSE); - g_return_val_if_fail(x != NULL, FALSE); - - off = strlen(s) - strlen(x); - return (off >= 0 && purple_strequal(s + off, x)); -#endif } char * @@ -5134,18 +4967,5 @@ const gchar * purple_get_host_name(void) { -#if GLIB_CHECK_VERSION(2,8,0) return g_get_host_name(); -#else - static char hostname[256]; - int ret = gethostname(hostname, sizeof(hostname)); - hostname[sizeof(hostname) - 1] = '\0'; - - if (ret == -1 || hostname[0] == '\0') { - purple_debug_info("purple_get_host_name: ", "could not find host name"); - return "localhost"; - } else { - return hostname; - } -#endif }
--- a/libpurple/win32/libc_interface.c Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/win32/libc_interface.c Sun Aug 23 02:37:12 2009 +0000 @@ -469,65 +469,7 @@ /* stdio.h */ int wpurple_rename (const char *oldname, const char *newname) { - -#if GLIB_CHECK_VERSION(2,8,5) - return g_rename(oldname, newname); - -#else - - /* This is a ugly, but we still compile with 2.6.10 but use newer runtimes */ - struct stat oldstat, newstat; - - /* As of Glib 2.8.5, g_rename() uses MoveFileEx() with MOVEFILE_REPLACE_EXISTING to behave more sanely */ - if (glib_check_version(2, 8, 5) == NULL) { - return g_rename(oldname, newname); - } - - if(g_stat(oldname, &oldstat) == 0) { - /* newname exists */ - if(g_stat(newname, &newstat) == 0) { - /* oldname is a dir */ - if(S_ISDIR(oldstat.st_mode)) { - if(!S_ISDIR(newstat.st_mode)) { - return g_rename(oldname, newname); - } - /* newname is a dir */ - else { - /* This is not quite right.. If newname is empty and - is not a sub dir of oldname, newname should be - deleted and oldname should be renamed. - */ - purple_debug(PURPLE_DEBUG_WARNING, "wpurple", "wpurple_rename does not behave here as it should\n"); - return g_rename(oldname, newname); - } - } - /* oldname is not a dir */ - else { - /* newname is a dir */ - if(S_ISDIR(newstat.st_mode)) { - errno = EISDIR; - return -1; - } - /* newname is not a dir */ - else { - g_remove(newname); - return g_rename(oldname, newname); - } - } - } - /* newname doesn't exist */ - else - return g_rename(oldname, newname); - } - else { - /* oldname doesn't exist */ - errno = ENOENT; - return -1; - } - -#endif - } /* time.h */ @@ -1129,54 +1071,7 @@ wpurple_g_access (const gchar *filename, int mode) { -#if GLIB_CHECK_VERSION(2,8,0) - return g_access(filename, mode); - -#else - - if (G_WIN32_HAVE_WIDECHAR_API ()) - { - wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); - int retval; - int save_errno; - - if (wfilename == NULL) - { - errno = EINVAL; - return -1; - } - - retval = _waccess (wfilename, mode); - save_errno = errno; - - g_free (wfilename); - - errno = save_errno; - return retval; - } - else - { - gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL); - int retval; - int save_errno; - - if (cp_filename == NULL) - { - errno = EINVAL; - return -1; - } - - retval = access (cp_filename, mode); - save_errno = errno; - - g_free (cp_filename); - - errno = save_errno; - return retval; - } - -#endif }
--- a/libpurple/win32/libc_interface.h Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/win32/libc_interface.h Sun Aug 23 02:37:12 2009 +0000 @@ -115,11 +115,6 @@ #define close( fd ) \ wpurple_close( fd ) -#if !GLIB_CHECK_VERSION(2,8,0) -#define g_access( filename, mode) \ -wpurple_g_access( filename, mode ) -#endif - #ifndef sleep #define sleep(x) Sleep((x)*1000) #endif @@ -140,14 +135,12 @@ #define rename( oldname, newname ) \ wpurple_rename( oldname, newname ) -#if GLIB_CHECK_VERSION(2,6,0) #ifdef g_rename # undef g_rename #endif /* This is necessary because we want rename on win32 to be able to overwrite an existing file, it is done in internal.h if GLib < 2.6*/ #define g_rename(oldname, newname) \ wpurple_rename(oldname, newname) -#endif /* sys/stat.h */ #define fchmod(a,b)
--- a/libpurple/win32/libc_internal.h Sun Aug 23 02:11:21 2009 +0000 +++ b/libpurple/win32/libc_internal.h Sun Aug 23 02:37:12 2009 +0000 @@ -141,10 +141,6 @@ int wpurple_gethostname(char *name, size_t size); -#if !GLIB_CHECK_VERSION(2,8,0) -int wpurple_g_access(const gchar *filename, int mode); -#endif - /* stdio.h */ int wpurple_rename(const char *oldname, const char *newname);
--- a/pidgin/Makefile.am Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/Makefile.am Sun Aug 23 02:37:12 2009 +0000 @@ -74,17 +74,12 @@ pidgin_SOURCES = \ eggtrayicon.c \ - pidgincombobox.c \ pidginstock.c \ gtkaccount.c \ gtkblist.c \ gtkblist-theme.c \ gtkblist-theme-loader.c \ - gtkcelllayout.c \ gtkcellrendererexpander.c \ - gtkcellrendererprogress.c \ - gtkcellview.c \ - gtkcellviewmenuitem.c \ gtkcertmgr.c \ gtkconn.c \ gtkconv.c \ @@ -94,7 +89,6 @@ gtkdocklet.c \ gtkdocklet-x11.c \ gtkeventloop.c \ - gtkexpander.c \ gtkft.c \ gtkicon-theme.c \ gtkicon-theme-loader.c \ @@ -135,13 +129,8 @@ gtkblist.h \ gtkblist-theme.h \ gtkblist-theme-loader.h \ - gtkcelllayout.h \ gtkcellrendererexpander.h \ - gtkcellrendererprogress.h \ - gtkcellview.h \ - gtkcellviewmenuitem.h \ gtkcertmgr.h \ - pidgincombobox.h \ gtkconn.h \ gtkconv.h \ gtkconvwin.h \ @@ -150,7 +139,6 @@ gtkdnd-hints.h \ gtkdocklet.h \ gtkeventloop.h \ - gtkexpander.h \ gtkft.h \ gtkicon-theme.h \ gtkicon-theme-loader.h \
--- a/pidgin/gtkblist.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/gtkblist.c Sun Aug 23 02:37:12 2009 +0000 @@ -5387,12 +5387,7 @@ return; tooltips = gtk_tooltips_new (); -#if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink (tooltips); -#else - g_object_ref(tooltips); - gtk_object_sink(GTK_OBJECT(tooltips)); -#endif gtk_tooltips_force_window (tooltips); #if GTK_CHECK_VERSION(2, 12, 0)
--- a/pidgin/gtkcelllayout.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +0,0 @@ -/* gtkcelllayout.c - * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -/* -#include <config.h> -*/ -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,4,0) -#include "gtkcelllayout.h" - -GType -gtk_cell_layout_get_type (void) -{ - static GType cell_layout_type = 0; - - if (! cell_layout_type) - { - static const GTypeInfo cell_layout_info = - { - sizeof (GtkCellLayoutIface), - NULL, - NULL, - NULL, - NULL, - NULL, - 0, - 0, - NULL - }; - - cell_layout_type = - g_type_register_static (G_TYPE_INTERFACE, "PidginCellLayout", - &cell_layout_info, 0); - - g_type_interface_add_prerequisite (cell_layout_type, G_TYPE_OBJECT); - } - - return cell_layout_type; -} - -/** - * gtk_cell_layout_pack_start: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer. - * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout. - * - * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE, - * then the @cell is allocated no more space than it needs. Any unused space - * is divided evenly between cells for which @expand is %TRUE. - * - * Since: 2.4 - */ -void -gtk_cell_layout_pack_start (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_start) (cell_layout, - cell, - expand); -} - -/** - * gtk_cell_layout_pack_end: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer. - * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout. - * - * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the - * @cell is allocated no more space than it needs. Any unused space is - * divided evenly between cells for which @expand is %TRUE. - * - * Since: 2.4 - */ -void -gtk_cell_layout_pack_end (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end) (cell_layout, - cell, - expand); -} - -/** - * gtk_cell_layout_clear: - * @cell_layout: A #GtkCellLayout. - * - * Unsets all the mappings on all renderers on @cell_layout and - * removes all renderers from @cell_layout. - * - * Since: 2.4 - */ -void -gtk_cell_layout_clear (GtkCellLayout *cell_layout) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear) (cell_layout); -} - -static void -gtk_cell_layout_set_attributesv (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - va_list args) -{ - gchar *attribute; - gint column; - GtkCellLayoutIface *iface; - - attribute = va_arg (args, gchar *); - - iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout); - - (* iface->clear_attributes) (cell_layout, cell); - - while (attribute != NULL) - { - column = va_arg (args, gint); - (* iface->add_attribute) (cell_layout, cell, attribute, column); - attribute = va_arg (args, gchar *); - } -} - -/** - * gtk_cell_layout_set_attributes: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer. - * @Varargs: A %NULL-terminated list of attributes. - * - * Sets the attributes in list as the attributes of @cell_layout. The - * attributes should be in attribute/column order, as in - * gtk_cell_layout_add_attribute(). All existing attributes are removed, and - * replaced with the new attributes. - * - * Since: 2.4 - */ -void -gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - ...) -{ - va_list args; - - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - va_start (args, cell); - gtk_cell_layout_set_attributesv (cell_layout, cell, args); - va_end (args); -} - -/** - * gtk_cell_layout_add_attribute: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer. - * @attribute: An attribute on the renderer. - * @column: The column position on the model to get the attribute from. - * - * Adds an attribute mapping to the list in @cell_layout. The @column is the - * column of the model to get a value from, and the @attribute is the - * parameter on @cell to be set from the value. So for example if column 2 - * of the model contains strings, you could have the "text" attribute of a - * #GtkCellRendererText get its values from column 2. - * - * Since: 2.4 - */ -void -gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - g_return_if_fail (attribute != NULL); - g_return_if_fail (column >= 0); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute) (cell_layout, - cell, - attribute, - column); -} - -/** - * gtk_cell_layout_set_cell_data_func: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer. - * @func: The #GtkCellLayoutDataFunc to use. - * @func_data: The user data for @func. - * @destroy: The destroy notification for @func_data. - * - * Sets the #GtkCellLayoutDataFunc to use for @cell_layout. This function - * is used instead of the standard attributes mapping for setting the - * column value, and should set the value of @cell_layout's cell renderer(s) - * as appropriate. @func may be %NULL to remove and older one. - * - * Since: 2.4 - */ -void -gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->set_cell_data_func) (cell_layout, - cell, - func, - func_data, - destroy); -} - -/** - * gtk_cell_layout_clear_attributes: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer to clear the attribute mapping on. - * - * Clears all existing attributes previously set with - * gtk_cell_layout_set_attributes(). - * - * Since: 2.4 - */ -void -gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout, - GtkCellRenderer *cell) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes) (cell_layout, - cell); -} - -/** - * gtk_cell_layout_reorder: - * @cell_layout: A #GtkCellLayout. - * @cell: A #GtkCellRenderer to reorder. - * @position: New position to insert @cell at. - * - * Re-inserts @cell at @position. Note that @cell has already to be packed - * into @cell_layout for this to function properly. - * - * Since: 2.4 - */ -void -gtk_cell_layout_reorder (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gint position) -{ - g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - (* GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder) (cell_layout, - cell, - position); -} -#endif /* Gtk 2.4 */
--- a/pidgin/gtkcelllayout.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -/* gtkcelllayout.h - * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -#ifndef __GTK_CELL_LAYOUT_H__ -#define __GTK_CELL_LAYOUT_H__ - -#include <glib-object.h> - -#include <gtk/gtkcellrenderer.h> -#include <gtk/gtktreeviewcolumn.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_CELL_LAYOUT (gtk_cell_layout_get_type ()) -#define GTK_CELL_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_LAYOUT, GtkCellLayout)) -#define GTK_IS_CELL_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_LAYOUT)) -#define GTK_CELL_LAYOUT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_CELL_LAYOUT, GtkCellLayoutIface)) - -typedef struct _GtkCellLayout GtkCellLayout; /* dummy typedef */ -typedef struct _GtkCellLayoutIface GtkCellLayoutIface; - -/* keep in sync with GtkTreeCellDataFunc */ -typedef void (* GtkCellLayoutDataFunc) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data); - -struct _GtkCellLayoutIface -{ - GTypeInterface g_iface; - - /* Virtual Table */ - void (* pack_start) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand); - void (* pack_end) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand); - void (* clear) (GtkCellLayout *cell_layout); - void (* add_attribute) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column); - void (* set_cell_data_func) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy); - void (* clear_attributes) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell); - void (* reorder) (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gint position); -}; - -GType gtk_cell_layout_get_type (void); -void gtk_cell_layout_pack_start (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand); -void gtk_cell_layout_pack_end (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gboolean expand); -void gtk_cell_layout_clear (GtkCellLayout *cell_layout); -void gtk_cell_layout_set_attributes (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - ...); -void gtk_cell_layout_add_attribute (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column); -void gtk_cell_layout_set_cell_data_func (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy); -void gtk_cell_layout_clear_attributes (GtkCellLayout *cell_layout, - GtkCellRenderer *cell); -void gtk_cell_layout_reorder (GtkCellLayout *cell_layout, - GtkCellRenderer *cell, - gint position); - - -G_END_DECLS - -#endif /* __GTK_CELL_LAYOUT_H__ */
--- a/pidgin/gtkcellrendererprogress.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,296 +0,0 @@ -/* - * @file gtkcellrendererprogress.c GTK+ Cell Renderer Progress - * @ingroup pidgin - */ - -/* pidgin - * - * Pidgin is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -/* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by - * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc. - */ - -#include "gtkcellrendererprogress.h" - -static void pidgin_cell_renderer_progress_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void pidgin_cell_renderer_progress_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void pidgin_cell_renderer_progress_init (PidginCellRendererProgress *cellprogress); -static void pidgin_cell_renderer_progress_class_init (PidginCellRendererProgressClass *class); -static void pidgin_cell_renderer_progress_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); -static void pidgin_cell_renderer_progress_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - guint flags); -#if 0 -static gboolean pidgin_cell_renderer_progress_activate (GtkCellRenderer *cell, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - guint flags); -#endif -static void pidgin_cell_renderer_progress_finalize (GObject *gobject); - -enum { - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_PERCENTAGE, - PROP_TEXT, - PROP_SHOW_TEXT -}; - -static gpointer parent_class; -/* static guint progress_cell_renderer_signals [LAST_SIGNAL]; */ - -GType pidgin_cell_renderer_progress_get_type (void) -{ - static GType cell_progress_type = 0; - - if (!cell_progress_type) - { - static const GTypeInfo cell_progress_info = - { - sizeof (PidginCellRendererProgressClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) pidgin_cell_renderer_progress_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PidginCellRendererProgress), - 0, /* n_preallocs */ - (GInstanceInitFunc) pidgin_cell_renderer_progress_init, - NULL /* value_table */ - }; - - cell_progress_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER, - "PidginCellRendererProgress", - &cell_progress_info, 0); - } - - return cell_progress_type; -} - -static void pidgin_cell_renderer_progress_init (PidginCellRendererProgress *cellprogress) -{ - GTK_CELL_RENDERER(cellprogress)->mode = GTK_CELL_RENDERER_MODE_INERT; - GTK_CELL_RENDERER(cellprogress)->xpad = 2; - GTK_CELL_RENDERER(cellprogress)->ypad = 2; -} - -static void pidgin_cell_renderer_progress_class_init (PidginCellRendererProgressClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS(class); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class); - - parent_class = g_type_class_peek_parent (class); - object_class->finalize = pidgin_cell_renderer_progress_finalize; - - object_class->get_property = pidgin_cell_renderer_progress_get_property; - object_class->set_property = pidgin_cell_renderer_progress_set_property; - - cell_class->get_size = pidgin_cell_renderer_progress_get_size; - cell_class->render = pidgin_cell_renderer_progress_render; - - g_object_class_install_property (object_class, - PROP_PERCENTAGE, - g_param_spec_double ("percentage", - "Percentage", - "The fractional progress to display", - 0, 1, 0, - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_TEXT, - g_param_spec_string ("text", - "Text", - "Text to overlay over progress bar", - NULL, - G_PARAM_READWRITE)); - g_object_class_install_property(object_class, - PROP_SHOW_TEXT, - g_param_spec_string("text_set", - "Text set", - "Whether to overlay text on the progress bar", - FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE)); -} - -static void pidgin_cell_renderer_progress_finalize (GObject *object) -{ -/* - PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS(object); -*/ - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -static void pidgin_cell_renderer_progress_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *psec) -{ - PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS(object); - - switch (param_id) - { - case PROP_PERCENTAGE: - g_value_set_double(value, cellprogress->progress); - break; - case PROP_TEXT: - g_value_set_string(value, cellprogress->text); - break; - case PROP_SHOW_TEXT: - g_value_set_boolean(value, cellprogress->text_set); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec); - break; - } -} - -static void pidgin_cell_renderer_progress_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - PidginCellRendererProgress *cellprogress = PIDGIN_CELL_RENDERER_PROGRESS (object); - - switch (param_id) - { - case PROP_PERCENTAGE: - cellprogress->progress = g_value_get_double(value); - break; - case PROP_TEXT: - if (cellprogress->text) - g_free(cellprogress->text); - cellprogress->text = g_strdup(g_value_get_string(value)); - g_object_notify(object, "text"); - break; - case PROP_SHOW_TEXT: - cellprogress->text_set = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); - break; - } -} - -GtkCellRenderer *pidgin_cell_renderer_progress_new(void) -{ - return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL); -} - -static void pidgin_cell_renderer_progress_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - gint calc_width; - gint calc_height; - - calc_width = (gint) cell->xpad * 2 + 50; - calc_height = (gint) cell->ypad * 2 + 12; - - if (width) - *width = calc_width; - - if (height) - *height = calc_height; - - if (cell_area) - { - if (x_offset) - { - *x_offset = cell->xalign * (cell_area->width - calc_width); - *x_offset = MAX (*x_offset, 0); - } - if (y_offset) - { - *y_offset = cell->yalign * (cell_area->height - calc_height); - *y_offset = MAX (*y_offset, 0); - } - } -} - - -static void pidgin_cell_renderer_progress_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - guint flags) -{ - PidginCellRendererProgress *cellprogress = (PidginCellRendererProgress *) cell; - - gint width, height; - GtkStateType state; - - width = cell_area->width; - height = cell_area->height; - - if (GTK_WIDGET_HAS_FOCUS (widget)) - state = GTK_STATE_ACTIVE; - else - state = GTK_STATE_NORMAL; - - width -= cell->xpad*2; - height -= cell->ypad*2; - - gtk_paint_box (widget->style, - window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - NULL, widget, "trough", - cell_area->x + cell->xpad, - cell_area->y + cell->ypad, - width - 1, height - 1); - gtk_paint_box (widget->style, - window, - state, GTK_SHADOW_OUT, - NULL, widget, "bar", - cell_area->x + cell->xpad + 1, - cell_area->y + cell->ypad + 1, - (width - 3) * cellprogress->progress, - height - 3); -}
--- a/pidgin/gtkcellrendererprogress.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* gtkxcellrendererprogress.h - * Pidgin is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ -#ifndef _PIDGINCELLRENDERERPROGRESS_H_ -#define _PIDGINCELLRENDERERPROGRESS_H_ - -#include <gtk/gtk.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS (pidgin_cell_renderer_progress_get_type()) -#define PIDGIN_CELL_RENDERER_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgress)) -#define PIDGIN_CELL_RENDERER_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) -#define PIDGIN_IS_GTK_CELL_PROGRESS_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS)) -#define PIDGIN_IS_GTK_CELL_PROGRESS_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS)) -#define PIDGIN_CELL_RENDERER_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_GTK_CELL_RENDERER_PROGRESS, PidginCellRendererProgressClass)) - -typedef struct _PidginCellRendererProgress PidginCellRendererProgress; -typedef struct _PidginCellRendererProgressClass PidginCellRendererProgressClass; - -struct _PidginCellRendererProgress { - GtkCellRenderer parent; - - gdouble progress; - gchar *text; - gboolean text_set; -}; - -struct _PidginCellRendererProgressClass { - GtkCellRendererClass parent_class; -}; - -GType pidgin_cell_renderer_progress_get_type (void); -GtkCellRenderer *pidgin_cell_renderer_progress_new (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _PIDGINCELLRENDERERPROGRESS_H_ */
--- a/pidgin/gtkcellview.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1002 +0,0 @@ -/* gtkellview.c - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -/* -#include <config.h> -*/ -#include "gtkcellview.h" -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,6,0) -#if GTK_CHECK_VERSION(2,4,0) -#include <gtk/gtkcelllayout.h> -#else -#include "gtkcelllayout.h" -#endif -#include <gtk/gtksignal.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkcellrendererpixbuf.h> -#include <gobject/gmarshal.h> - -#define P_(x) (x) - -typedef struct _GtkCellViewCellInfo GtkCellViewCellInfo; -struct _GtkCellViewCellInfo -{ - GtkCellRenderer *cell; - - gint requested_width; - gint real_width; - guint expand : 1; - guint pack : 1; - - GSList *attributes; - - GtkCellLayoutDataFunc func; - gpointer func_data; - GDestroyNotify destroy; -}; - -struct _GtkCellViewPrivate -{ - GtkTreeModel *model; - GtkTreeRowReference *displayed_row; - GList *cell_list; - gint spacing; - - GdkColor background; - gboolean background_set; -}; - - -static void gtk_cell_view_class_init (GtkCellViewClass *klass); -static void gtk_cell_view_cell_layout_init (GtkCellLayoutIface *iface); -static void gtk_cell_view_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void gtk_cell_view_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_cell_view_init (GtkCellView *cellview); -static void gtk_cell_view_finalize (GObject *object); -static void gtk_cell_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void gtk_cell_view_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_cell_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gboolean gtk_cell_view_expose (GtkWidget *widget, - GdkEventExpose *event); -static void gtk_cell_view_set_valuesv (GtkCellView *cellview, - GtkCellRenderer *renderer, - va_list args); -static GtkCellViewCellInfo *gtk_cell_view_get_cell_info (GtkCellView *cellview, - GtkCellRenderer *renderer); -static void gtk_cell_view_set_cell_data (GtkCellView *cellview); - - -static void gtk_cell_view_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *renderer, - gboolean expand); -static void gtk_cell_view_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *renderer, - gboolean expand); -static void gtk_cell_view_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *renderer, - const gchar *attribute, - gint column); -static void gtk_cell_view_cell_layout_clear (GtkCellLayout *layout); -static void gtk_cell_view_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *renderer); -static void gtk_cell_view_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy); -static void gtk_cell_view_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position); - - -enum -{ - PROP_0, - PROP_BACKGROUND, - PROP_BACKGROUND_GDK, - PROP_BACKGROUND_SET -}; - -static GtkObjectClass *parent_class = NULL; - - -GType -gtk_cell_view_get_type (void) -{ - static GType cell_view_type = 0; - - if (!cell_view_type) - { - static const GTypeInfo cell_view_info = - { - sizeof (GtkCellViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellView), - 0, - (GInstanceInitFunc) gtk_cell_view_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_cell_view_cell_layout_init, - NULL, - NULL - }; - - cell_view_type = g_type_register_static (GTK_TYPE_WIDGET, "PidginCellView", - &cell_view_info, 0); - - g_type_add_interface_static (cell_view_type, GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return cell_view_type; -} - -static void -gtk_cell_view_class_init (GtkCellViewClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->get_property = gtk_cell_view_get_property; - gobject_class->set_property = gtk_cell_view_set_property; - gobject_class->finalize = gtk_cell_view_finalize; - - widget_class->expose_event = gtk_cell_view_expose; - widget_class->size_allocate = gtk_cell_view_size_allocate; - widget_class->size_request = gtk_cell_view_size_request; - widget_class->style_set = gtk_cell_view_style_set; - - /* properties */ - g_object_class_install_property (gobject_class, - PROP_BACKGROUND, - g_param_spec_string ("background", - P_("Background color name"), - P_("Background color as a string"), - NULL, - G_PARAM_WRITABLE)); - g_object_class_install_property (gobject_class, - PROP_BACKGROUND_GDK, - g_param_spec_boxed ("background_gdk", - P_("Background color"), - P_("Background color as a GdkColor"), - GDK_TYPE_COLOR, - G_PARAM_READABLE | G_PARAM_WRITABLE)); - -#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (gobject_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE)) - - ADD_SET_PROP ("background_set", PROP_BACKGROUND_SET, - P_("Background set"), - P_("Whether this tag affects the background color")); -} - -static void -gtk_cell_view_cell_layout_init (GtkCellLayoutIface *iface) -{ - iface->pack_start = gtk_cell_view_cell_layout_pack_start; - iface->pack_end = gtk_cell_view_cell_layout_pack_end; - iface->clear = gtk_cell_view_cell_layout_clear; - iface->add_attribute = gtk_cell_view_cell_layout_add_attribute; - iface->set_cell_data_func = gtk_cell_view_cell_layout_set_cell_data_func; - iface->clear_attributes = gtk_cell_view_cell_layout_clear_attributes; - iface->reorder = gtk_cell_view_cell_layout_reorder; -} - -static void -gtk_cell_view_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - GtkCellView *view = GTK_CELL_VIEW (object); - - switch (param_id) - { - case PROP_BACKGROUND_GDK: - { - GdkColor color; - - color = view->priv->background; - - g_value_set_boxed (value, &color); - } - break; - case PROP_BACKGROUND_SET: - g_value_set_boolean (value, view->priv->background_set); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -gtk_cell_view_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkCellView *view = GTK_CELL_VIEW (object); - - switch (param_id) - { - case PROP_BACKGROUND: - { - GdkColor color; - - if (!g_value_get_string (value)) - gtk_cell_view_set_background_color (view, NULL); - else if (gdk_color_parse (g_value_get_string (value), &color)) - gtk_cell_view_set_background_color (view, &color); - else - g_warning ("Don't know color `%s'", g_value_get_string (value)); - - g_object_notify (object, "background_gdk"); - } - break; - case PROP_BACKGROUND_GDK: - gtk_cell_view_set_background_color (view, g_value_get_boxed (value)); - break; - case PROP_BACKGROUND_SET: - view->priv->background_set = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -gtk_cell_view_init (GtkCellView *cellview) -{ - GTK_WIDGET_SET_FLAGS (cellview, GTK_NO_WINDOW); - - cellview->priv = g_new0(GtkCellViewPrivate,1); -} - -static void -gtk_cell_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - if (previous_style && GTK_WIDGET_REALIZED (widget)) - gdk_window_set_background (widget->window, - &widget->style->base[GTK_WIDGET_STATE (widget)]); -} - -static void -gtk_cell_view_finalize (GObject *object) -{ - GtkCellView *cellview = GTK_CELL_VIEW (object); - - gtk_cell_view_cell_layout_clear (GTK_CELL_LAYOUT (cellview)); - - if (cellview->priv->model) - g_object_unref (cellview->priv->model); - - if (cellview->priv->displayed_row) - gtk_tree_row_reference_free (cellview->priv->displayed_row); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); - - g_free (cellview->priv); -} - -static void -gtk_cell_view_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GList *i; - gboolean first_cell = TRUE; - GtkCellView *cellview; - - cellview = GTK_CELL_VIEW (widget); - - requisition->width = 0; - requisition->height = 0; - - if (cellview->priv->displayed_row) - gtk_cell_view_set_cell_data (cellview); - - for (i = cellview->priv->cell_list; i; i = i->next) - { - gint width, height; - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (!info->cell->visible) - continue; - - if (!first_cell) - requisition->width += cellview->priv->spacing; - - gtk_cell_renderer_get_size (info->cell, widget, NULL, NULL, NULL, - &width, &height); - - info->requested_width = width; - requisition->width += width; - requisition->height = MAX (requisition->height, height); - - first_cell = FALSE; - } -} - -static void -gtk_cell_view_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GList *i; - gint expand_cell_count = 0; - gint full_requested_width = 0; - gint extra_space; - GtkCellView *cellview; - - widget->allocation = *allocation; - - cellview = GTK_CELL_VIEW (widget); - - /* checking how much extra space we have */ - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (!info->cell->visible) - continue; - - if (info->expand) - expand_cell_count++; - - full_requested_width += info->requested_width; - } - - extra_space = widget->allocation.width - full_requested_width; - if (extra_space < 0) - extra_space = 0; - else if (extra_space > 0 && expand_cell_count > 0) - extra_space /= expand_cell_count; - - /* iterate list for PACK_START cells */ - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (info->pack == GTK_PACK_END) - continue; - - if (!info->cell->visible) - continue; - - info->real_width = info->requested_width + (info->expand ? extra_space : 0); - } - - /* iterate list for PACK_END cells */ - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (info->pack == GTK_PACK_START) - continue; - - if (!info->cell->visible) - continue; - - info->real_width = info->requested_width + (info->expand ? extra_space : 0); - } -} - -static gboolean -gtk_cell_view_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GList *i; - GtkCellView *cellview; - GdkRectangle area; - GtkCellRendererState state; - gboolean rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL); - - cellview = GTK_CELL_VIEW (widget); - - if (! GTK_WIDGET_DRAWABLE (widget)) - return FALSE; - - /* "blank" background */ - if (cellview->priv->background_set) - { - GdkGC *gc; - - gc = gdk_gc_new (GTK_WIDGET (cellview)->window); - gdk_gc_set_rgb_fg_color (gc, &cellview->priv->background); - - gdk_draw_rectangle (GTK_WIDGET (cellview)->window, - gc, - TRUE, - - /*0, 0,*/ - widget->allocation.x, - widget->allocation.y, - - widget->allocation.width, - widget->allocation.height); - - g_object_unref (G_OBJECT (gc)); - } - - /* set cell data (if available) */ - if (cellview->priv->displayed_row) - gtk_cell_view_set_cell_data (cellview); - else if (cellview->priv->model) - return FALSE; - - /* render cells */ - area = widget->allocation; - - /* we draw on our very own window, initialize x and y to zero */ - area.x = widget->allocation.x + (rtl ? widget->allocation.width : 0); - area.y = widget->allocation.y; - - if (GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) - state = GTK_CELL_RENDERER_PRELIT; - else - state = 0; - - /* PACK_START */ - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (info->pack == GTK_PACK_END) - continue; - - if (!info->cell->visible) - continue; - - area.width = info->real_width; - if (rtl) - area.x -= area.width; - - gtk_cell_renderer_render (info->cell, - event->window, - widget, - /* FIXME! */ - &area, &area, &event->area, state); - - if (!rtl) - area.x += info->real_width; - } - - area.x = rtl ? widget->allocation.x : (widget->allocation.x + widget->allocation.width); - - /* PACK_END */ - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (info->pack == GTK_PACK_START) - continue; - - if (!info->cell->visible) - continue; - - area.width = info->real_width; - if (!rtl) - area.x -= area.width; - - gtk_cell_renderer_render (info->cell, - widget->window, - widget, - /* FIXME ! */ - &area, &area, &event->area, state); - if (rtl) - area.x += info->real_width; - } - - return FALSE; -} - -static GtkCellViewCellInfo * -gtk_cell_view_get_cell_info (GtkCellView *cellview, - GtkCellRenderer *renderer) -{ - GList *i; - - for (i = cellview->priv->cell_list; i; i = i->next) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)i->data; - - if (info->cell == renderer) - return info; - } - - return NULL; -} - -static void -gtk_cell_view_set_cell_data (GtkCellView *cellview) -{ - GList *i; - GtkTreeIter iter; - GtkTreePath *path; - - g_return_if_fail (cellview->priv->displayed_row != NULL); - - path = gtk_tree_row_reference_get_path (cellview->priv->displayed_row); - gtk_tree_model_get_iter (cellview->priv->model, &iter, path); - gtk_tree_path_free (path); - - for (i = cellview->priv->cell_list; i; i = i->next) - { - GSList *j; - GtkCellViewCellInfo *info = i->data; - - g_object_freeze_notify (G_OBJECT (info->cell)); - - for (j = info->attributes; j && j->next; j = j->next->next) - { - gchar *property = j->data; - gint column = GPOINTER_TO_INT (j->next->data); - GValue value = {0, }; - - gtk_tree_model_get_value (cellview->priv->model, &iter, - column, &value); - g_object_set_property (G_OBJECT (info->cell), - property, &value); - g_value_unset (&value); - } - - if (info->func) - (* info->func) (GTK_CELL_LAYOUT (cellview), - info->cell, - cellview->priv->model, - &iter, - info->func_data); - - g_object_thaw_notify (G_OBJECT (info->cell)); - } -} - -/* GtkCellLayout implementation */ -static void -gtk_cell_view_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *renderer, - gboolean expand) -{ - GtkCellViewCellInfo *info; - GtkCellView *cellview = GTK_CELL_VIEW (layout); - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - g_return_if_fail (GTK_IS_CELL_RENDERER (renderer)); - g_return_if_fail (!gtk_cell_view_get_cell_info (cellview, renderer)); - - g_object_ref (G_OBJECT (renderer)); - gtk_object_sink (GTK_OBJECT (renderer)); - - info = g_new0 (GtkCellViewCellInfo, 1); - info->cell = renderer; - info->expand = expand ? TRUE : FALSE; - info->pack = GTK_PACK_START; - - cellview->priv->cell_list = g_list_append (cellview->priv->cell_list, info); -} - -static void -gtk_cell_view_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *renderer, - gboolean expand) -{ - GtkCellViewCellInfo *info; - GtkCellView *cellview = GTK_CELL_VIEW (layout); - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - g_return_if_fail (GTK_IS_CELL_RENDERER (renderer)); - g_return_if_fail (!gtk_cell_view_get_cell_info (cellview, renderer)); - - g_object_ref (G_OBJECT (renderer)); - gtk_object_sink (GTK_OBJECT (renderer)); - - info = g_new0 (GtkCellViewCellInfo, 1); - info->cell = renderer; - info->expand = expand ? TRUE : FALSE; - info->pack = GTK_PACK_END; - - cellview->priv->cell_list = g_list_append (cellview->priv->cell_list, info); -} - -static void -gtk_cell_view_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *renderer, - const gchar *attribute, - gint column) -{ - GtkCellViewCellInfo *info; - GtkCellView *cellview = GTK_CELL_VIEW (layout); - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - info = gtk_cell_view_get_cell_info (cellview, renderer); - g_return_if_fail (info != NULL); - - info->attributes = g_slist_prepend (info->attributes, - GINT_TO_POINTER (column)); - info->attributes = g_slist_prepend (info->attributes, - g_strdup (attribute)); -} - -static void -gtk_cell_view_cell_layout_clear (GtkCellLayout *layout) -{ - GtkCellView *cellview = GTK_CELL_VIEW (layout); - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - - while (cellview->priv->cell_list) - { - GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)cellview->priv->cell_list->data; - - gtk_cell_view_cell_layout_clear_attributes (layout, info->cell); - g_object_unref (G_OBJECT (info->cell)); - g_free (info); - cellview->priv->cell_list = g_list_delete_link (cellview->priv->cell_list, - cellview->priv->cell_list); - } -} - -static void -gtk_cell_view_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy) -{ - GtkCellView *cellview = GTK_CELL_VIEW (layout); - GtkCellViewCellInfo *info; - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - - info = gtk_cell_view_get_cell_info (cellview, cell); - g_return_if_fail (info != NULL); - - if (info->destroy) - { - GDestroyNotify d = info->destroy; - - info->destroy = NULL; - d (info->func_data); - } - - info->func = func; - info->func_data = func_data; - info->destroy = destroy; -} - -static void -gtk_cell_view_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *renderer) -{ - GtkCellViewCellInfo *info; - GtkCellView *cellview = GTK_CELL_VIEW (layout); - GSList *list; - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - g_return_if_fail (GTK_IS_CELL_RENDERER (renderer)); - - info = gtk_cell_view_get_cell_info (cellview, renderer); - if (info != NULL) - { - list = info->attributes; - while (list && list->next) - { - g_free (list->data); - list = list->next->next; - } - - g_slist_free (info->attributes); - info->attributes = NULL; - } -} - -static void -gtk_cell_view_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position) -{ - GList *link; - GtkCellViewCellInfo *info; - GtkCellView *cellview = GTK_CELL_VIEW (layout); - - g_return_if_fail (GTK_IS_CELL_VIEW (cellview)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - info = gtk_cell_view_get_cell_info (cellview, cell); - - g_return_if_fail (info != NULL); - g_return_if_fail (position >= 0); - - link = g_list_find (cellview->priv->cell_list, info); - - g_return_if_fail (link != NULL); - - cellview->priv->cell_list = g_list_remove_link (cellview->priv->cell_list, - link); - cellview->priv->cell_list = g_list_insert (cellview->priv->cell_list, - info, position); - - gtk_widget_queue_draw (GTK_WIDGET (cellview)); -} - -/* public API */ -GtkWidget * -gtk_cell_view_new (void) -{ - GtkCellView *cellview; - - cellview = GTK_CELL_VIEW (g_object_new (gtk_cell_view_get_type (), NULL)); - - return GTK_WIDGET (cellview); -} - -GtkWidget * -gtk_cell_view_new_with_text (const gchar *text) -{ - GtkCellView *cellview; - GtkCellRenderer *renderer; - GValue value = {0, }; - - cellview = GTK_CELL_VIEW (gtk_cell_view_new ()); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_view_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview), - renderer, TRUE); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, text); - gtk_cell_view_set_values (cellview, renderer, "text", &value, NULL); - g_value_unset (&value); - - return GTK_WIDGET (cellview); -} - -GtkWidget * -gtk_cell_view_new_with_markup (const gchar *markup) -{ - GtkCellView *cellview; - GtkCellRenderer *renderer; - GValue value = {0, }; - - cellview = GTK_CELL_VIEW (gtk_cell_view_new ()); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_view_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview), - renderer, TRUE); - - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, markup); - gtk_cell_view_set_values (cellview, renderer, "markup", &value, NULL); - g_value_unset (&value); - - return GTK_WIDGET (cellview); -} - -GtkWidget * -gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf) -{ - GtkCellView *cellview; - GtkCellRenderer *renderer; - GValue value = {0, }; - - cellview = GTK_CELL_VIEW (gtk_cell_view_new ()); - - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_cell_view_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview), - renderer, TRUE); - - g_value_init (&value, GDK_TYPE_PIXBUF); - g_value_set_object (&value, pixbuf); - gtk_cell_view_set_values (cellview, renderer, "pixbuf", &value, NULL); - g_value_unset (&value); - - return GTK_WIDGET (cellview); -} - -void -gtk_cell_view_set_value (GtkCellView *cell_view, - GtkCellRenderer *renderer, - gchar *property, - GValue *value) -{ - g_return_if_fail (GTK_IS_CELL_VIEW (cell_view)); - g_return_if_fail (GTK_IS_CELL_RENDERER (renderer)); - - g_object_set_property (G_OBJECT (renderer), property, value); - - /* force resize and redraw */ - gtk_widget_queue_resize (GTK_WIDGET (cell_view)); - gtk_widget_queue_draw (GTK_WIDGET (cell_view)); -} - -static void -gtk_cell_view_set_valuesv (GtkCellView *cell_view, - GtkCellRenderer *renderer, - va_list args) -{ - gchar *attribute; - GValue *value; - - attribute = va_arg (args, gchar *); - - while (attribute) - { - value = va_arg (args, GValue *); - gtk_cell_view_set_value (cell_view, renderer, attribute, value); - attribute = va_arg (args, gchar *); - } -} - -void -gtk_cell_view_set_values (GtkCellView *cell_view, - GtkCellRenderer *renderer, - ...) -{ - va_list args; - - g_return_if_fail (GTK_IS_CELL_VIEW (cell_view)); - g_return_if_fail (GTK_IS_CELL_RENDERER (renderer)); - g_return_if_fail (gtk_cell_view_get_cell_info (cell_view, renderer)); - - va_start (args, renderer); - gtk_cell_view_set_valuesv (cell_view, renderer, args); - va_end (args); -} - -void -gtk_cell_view_set_model (GtkCellView *cell_view, - GtkTreeModel *model) -{ - g_return_if_fail (GTK_IS_CELL_VIEW (cell_view)); - g_return_if_fail (GTK_IS_TREE_MODEL (model)); - - if (cell_view->priv->model) - { - if (cell_view->priv->displayed_row) - gtk_tree_row_reference_free (cell_view->priv->displayed_row); - cell_view->priv->displayed_row = NULL; - - g_object_unref (G_OBJECT (cell_view->priv->model)); - cell_view->priv->model = NULL; - } - - cell_view->priv->model = model; - - if (cell_view->priv->model) - g_object_ref (G_OBJECT (cell_view->priv->model)); -} - -/** - * gtk_cell_view_set_displayed_row: - * @cell_view: a #GtkCellView - * @path: a #GtkTreePath or %NULL to unset. - * - * Sets the row of the model that is currently displayed - * by the #GtkCellView. If the path is unset, then the - * contents of the cellview "stick" at their last value; - * this is not normally a desired result, but may be - * a needed intermediate state if say, the model for - * the #GtkCellView becomes temporarily empty. - **/ -void -gtk_cell_view_set_displayed_row (GtkCellView *cell_view, - GtkTreePath *path) -{ - g_return_if_fail (GTK_IS_CELL_VIEW (cell_view)); - g_return_if_fail (GTK_IS_TREE_MODEL (cell_view->priv->model)); - - if (cell_view->priv->displayed_row) - gtk_tree_row_reference_free (cell_view->priv->displayed_row); - - if (path) - { - cell_view->priv->displayed_row = - gtk_tree_row_reference_new (cell_view->priv->model, path); - } - else - cell_view->priv->displayed_row = NULL; - - /* force resize and redraw */ - gtk_widget_queue_resize (GTK_WIDGET (cell_view)); - gtk_widget_queue_draw (GTK_WIDGET (cell_view)); -} - -GtkTreePath * -gtk_cell_view_get_displayed_row (GtkCellView *cell_view) -{ - g_return_val_if_fail (GTK_IS_CELL_VIEW (cell_view), NULL); - - if (!cell_view->priv->displayed_row) - return NULL; - - return gtk_tree_row_reference_get_path (cell_view->priv->displayed_row); -} - -gboolean -gtk_cell_view_get_size_of_row (GtkCellView *cell_view, - GtkTreePath *path, - GtkRequisition *requisition) -{ - GtkTreeRowReference *tmp; - GtkRequisition req; - - g_return_val_if_fail (GTK_IS_CELL_VIEW (cell_view), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (requisition != NULL, FALSE); - - tmp = cell_view->priv->displayed_row; - cell_view->priv->displayed_row = - gtk_tree_row_reference_new (cell_view->priv->model, path); - - gtk_cell_view_size_request (GTK_WIDGET (cell_view), requisition); - - gtk_tree_row_reference_free (cell_view->priv->displayed_row); - cell_view->priv->displayed_row = tmp; - - /* restore actual size info */ - gtk_cell_view_size_request (GTK_WIDGET (cell_view), &req); - - return TRUE; -} - -void -gtk_cell_view_set_background_color (GtkCellView *view, - const GdkColor *color) -{ - g_return_if_fail (GTK_IS_CELL_VIEW (view)); - - if (color) - { - if (!view->priv->background_set) - { - view->priv->background_set = TRUE; - g_object_notify (G_OBJECT (view), "background_set"); - } - - view->priv->background = *color; - } - else - { - if (view->priv->background_set) - { - view->priv->background_set = FALSE; - g_object_notify (G_OBJECT (view), "background_set"); - } - } -} -#endif /* Gtk 2.6 */
--- a/pidgin/gtkcellview.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* gtkcellview.h - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -#ifndef __GTK_CELL_VIEW_H__ -#define __GTK_CELL_VIEW_H__ - -#include <gtk/gtkwidget.h> -#include <gtk/gtkcellrenderer.h> -#include <gtk/gtktreemodel.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_CELL_VIEW (gtk_cell_view_get_type ()) -#define GTK_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_VIEW, GtkCellView)) -#define GTK_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_CELL_VIEW, GtkCellViewClass)) -#define GTK_IS_CELL_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_VIEW)) -#define GTK_IS_CELL_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_CELL_VIEW)) -#define GTK_CELL_VIEW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_CELL_VIEW, GtkCellViewClass)) - -typedef struct _GtkCellView GtkCellView; -typedef struct _GtkCellViewClass GtkCellViewClass; -typedef struct _GtkCellViewPrivate GtkCellViewPrivate; - -struct _GtkCellView -{ - GtkWidget parent_instance; - - /*< private >*/ - GtkCellViewPrivate *priv; -}; - -struct _GtkCellViewClass -{ - GtkWidgetClass parent_class; -}; - -GType gtk_cell_view_get_type (void); -GtkWidget *gtk_cell_view_new (void); -GtkWidget *gtk_cell_view_new_with_text (const gchar *text); -GtkWidget *gtk_cell_view_new_with_markup (const gchar *markup); -GtkWidget *gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf); - - -void gtk_cell_view_set_value (GtkCellView *cell_view, - GtkCellRenderer *renderer, - gchar *property, - GValue *value); -void gtk_cell_view_set_values (GtkCellView *cell_view, - GtkCellRenderer *renderer, - ...); - -void gtk_cell_view_set_model (GtkCellView *cell_view, - GtkTreeModel *model); -void gtk_cell_view_set_displayed_row (GtkCellView *cell_view, - GtkTreePath *path); -GtkTreePath *gtk_cell_view_get_displayed_row (GtkCellView *cell_view); -gboolean gtk_cell_view_get_size_of_row (GtkCellView *cell_view, - GtkTreePath *path, - GtkRequisition *requisition); - -void gtk_cell_view_set_background_color (GtkCellView *cell_view, - const GdkColor *color); - -G_END_DECLS - -#endif /* __GTK_CELL_VIEW_H__ */
--- a/pidgin/gtkcellviewmenuitem.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +0,0 @@ -/* gtkcellviewmenuitem.c - * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -/* -#include <config.h> -*/ -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,6,0) -#include "gtkcellviewmenuitem.h" -#include "gtkcellview.h" - -struct _GtkCellViewMenuItemPrivate -{ - GtkWidget *cell_view; -}; - -static void gtk_cell_view_menu_item_init (GtkCellViewMenuItem *item); -static void gtk_cell_view_menu_item_class_init (GtkCellViewMenuItemClass *klass); -static void gtk_cell_view_menu_item_finalize (GObject *object); - - -GType -gtk_cell_view_menu_item_get_type (void) -{ - static GType cell_view_menu_item_type = 0; - - if (!cell_view_menu_item_type) - { - static const GTypeInfo cell_view_menu_item_info = - { - sizeof (GtkCellViewMenuItemClass), - NULL, - NULL, - (GClassInitFunc) gtk_cell_view_menu_item_class_init, - NULL, - NULL, - sizeof (GtkCellViewMenuItem), - 0, - (GInstanceInitFunc) gtk_cell_view_menu_item_init - }; - - cell_view_menu_item_type = - g_type_register_static (GTK_TYPE_MENU_ITEM, "PidginCellViewMenuItem", - &cell_view_menu_item_info, 0); - } - - return cell_view_menu_item_type; -} - -static void -gtk_cell_view_menu_item_class_init (GtkCellViewMenuItemClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *)klass; - object_class->finalize = gtk_cell_view_menu_item_finalize; -} - -static void -gtk_cell_view_menu_item_init (GtkCellViewMenuItem *item) -{ - item->priv = g_new0(GtkCellViewMenuItemPrivate,1); -} - -GtkWidget * -gtk_cell_view_menu_item_new (void) -{ - GtkCellViewMenuItem *item; - - item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL); - - item->priv->cell_view = gtk_cell_view_new (); - gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view); - gtk_widget_show (item->priv->cell_view); - - return GTK_WIDGET (item); -} - -GtkWidget * -gtk_cell_view_menu_item_new_with_pixbuf (GdkPixbuf *pixbuf) -{ - GtkCellViewMenuItem *item; - - item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL); - - item->priv->cell_view = gtk_cell_view_new_with_pixbuf (pixbuf); - gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view); - gtk_widget_show (item->priv->cell_view); - - return GTK_WIDGET (item); -} - -GtkWidget * -gtk_cell_view_menu_item_new_with_text (const gchar *text) -{ - GtkCellViewMenuItem *item; - - item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL); - - item->priv->cell_view = gtk_cell_view_new_with_text (text); - gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view); - gtk_widget_show (item->priv->cell_view); - - return GTK_WIDGET (item); -} - -GtkWidget * -gtk_cell_view_menu_item_new_with_markup (const gchar *markup) -{ - GtkCellViewMenuItem *item; - - item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL); - - item->priv->cell_view = gtk_cell_view_new_with_markup (markup); - gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view); - gtk_widget_show (item->priv->cell_view); - - return GTK_WIDGET (item); -} - -GtkWidget * -gtk_cell_view_menu_item_new_from_model (GtkTreeModel *model, - GtkTreePath *path) -{ - GtkCellViewMenuItem *item; - - item = g_object_new (GTK_TYPE_CELL_VIEW_MENU_ITEM, NULL); - - item->priv->cell_view = gtk_cell_view_new (); - gtk_container_add (GTK_CONTAINER (item), item->priv->cell_view); - - gtk_cell_view_set_model (GTK_CELL_VIEW (item->priv->cell_view), model); - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (item->priv->cell_view), path); - - gtk_widget_show (item->priv->cell_view); - - return GTK_WIDGET (item); -} - -static void -gtk_cell_view_menu_item_finalize (GObject *object) -{ - GtkCellViewMenuItem *item = GTK_CELL_VIEW_MENU_ITEM (object); - - g_free (item->priv); -} -#endif /* Gtk 2.6 */
--- a/pidgin/gtkcellviewmenuitem.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* gtkcellviewmenuitem.h - * Copyright (C) 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -#ifndef __GTK_CELL_VIEW_MENU_ITEM_H__ -#define __GTK_CELL_VIEW_MENU_ITEM_H__ - -#include <gtk/gtkmenuitem.h> -#include <gtk/gtktreemodel.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_CELL_VIEW_MENU_ITEM (gtk_cell_view_menu_item_get_type ()) -#define GTK_CELL_VIEW_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItem)) -#define GTK_CELL_VIEW_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItemClass)) -#define GTK_IS_CELL_VIEW_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM)) -#define GTK_IS_CELL_VIEW_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_VIEW_MENU_ITEM)) -#define GTK_CELL_VIEW_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_VIEW_MENU_ITEM, GtkCellViewMenuItemClass)) - - -typedef struct _GtkCellViewMenuItem GtkCellViewMenuItem; -typedef struct _GtkCellViewMenuItemClass GtkCellViewMenuItemClass; -typedef struct _GtkCellViewMenuItemPrivate GtkCellViewMenuItemPrivate; - -struct _GtkCellViewMenuItem -{ - GtkMenuItem parent_instance; - - /*< private >*/ - GtkCellViewMenuItemPrivate *priv; -}; - -struct _GtkCellViewMenuItemClass -{ - GtkMenuItemClass parent_class; -}; - - -GType gtk_cell_view_menu_item_get_type (void); -GtkWidget *gtk_cell_view_menu_item_new (void); - -GtkWidget *gtk_cell_view_menu_item_new_with_pixbuf (GdkPixbuf *pixbuf); -GtkWidget *gtk_cell_view_menu_item_new_with_text (const gchar *text); -GtkWidget *gtk_cell_view_menu_item_new_with_markup (const gchar *markup); - -GtkWidget *gtk_cell_view_menu_item_new_from_model (GtkTreeModel *model, - GtkTreePath *path); - - -G_END_DECLS - -#endif /* __GTK_CELL_VIEW_MENU_ITEM_H__ */
--- a/pidgin/gtkexpander.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1659 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - * - * Authors: - * Mark McLoughlin <mark@skynet.ie> - */ - -/* -#include <config.h> -*/ - -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,4,0) -#include "gtkexpander.h" - -#include <gtk/gtklabel.h> -#include <gtk/gtkcontainer.h> -#include <gtk/gtkmarshal.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkprivate.h> -#include <gdk/gdkkeysyms.h> - -#define P_(x) (x) - -#define DEFAULT_EXPANDER_SIZE 10 -#define DEFAULT_EXPANDER_SPACING 2 - -enum -{ - PROP_0, - PROP_EXPANDED, - PROP_LABEL, - PROP_USE_UNDERLINE, - PROP_USE_MARKUP, - PROP_SPACING, - PROP_LABEL_WIDGET -}; - -struct _GtkExpanderPrivate -{ - GtkWidget *label_widget; - GdkWindow *event_window; - gint spacing; - - GtkExpanderStyle expander_style; - guint animation_timeout; - - guint expanded : 1; - guint use_underline : 1; - guint use_markup : 1; - guint button_down : 1; - guint prelight : 1; -}; - -static void gtk_expander_class_init (GtkExpanderClass *klass); -static void gtk_expander_init (GtkExpander *expander); - -static void gtk_expander_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_expander_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gtk_expander_finalize (GObject *object); - -static void gtk_expander_destroy (GtkObject *object); - -static void gtk_expander_realize (GtkWidget *widget); -static void gtk_expander_unrealize (GtkWidget *widget); -static void gtk_expander_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_expander_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gtk_expander_map (GtkWidget *widget); -static void gtk_expander_unmap (GtkWidget *widget); -static gboolean gtk_expander_expose (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_expander_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean gtk_expander_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean gtk_expander_enter_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean gtk_expander_leave_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean gtk_expander_focus (GtkWidget *widget, - GtkDirectionType direction); -static void gtk_expander_grab_notify (GtkWidget *widget, - gboolean was_grabbed); -static void gtk_expander_state_changed (GtkWidget *widget, - GtkStateType previous_state); - -static void gtk_expander_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_expander_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_expander_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - -static void gtk_expander_activate (GtkExpander *expander); - -static void get_expander_bounds (GtkExpander *expander, - GdkRectangle *rect); - -static GtkBinClass *parent_class = NULL; - -GType -gtk_expander_get_type (void) -{ - static GType expander_type = 0; - - if (!expander_type) - { - static const GTypeInfo expander_info = - { - sizeof (GtkExpanderClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_expander_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkExpander), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_expander_init, - }; - - expander_type = g_type_register_static (GTK_TYPE_BIN, - "GtkExpander", - &expander_info, 0); - } - - return expander_type; -} - -static void -gtk_expander_class_init (GtkExpanderClass *klass) -{ - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class = (GObjectClass *) klass; - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - container_class = (GtkContainerClass *) klass; - - gobject_class->set_property = gtk_expander_set_property; - gobject_class->get_property = gtk_expander_get_property; - gobject_class->finalize = gtk_expander_finalize; - - object_class->destroy = gtk_expander_destroy; - - widget_class->realize = gtk_expander_realize; - widget_class->unrealize = gtk_expander_unrealize; - widget_class->size_request = gtk_expander_size_request; - widget_class->size_allocate = gtk_expander_size_allocate; - widget_class->map = gtk_expander_map; - widget_class->unmap = gtk_expander_unmap; - widget_class->expose_event = gtk_expander_expose; - widget_class->button_press_event = gtk_expander_button_press; - widget_class->button_release_event = gtk_expander_button_release; - widget_class->enter_notify_event = gtk_expander_enter_notify; - widget_class->leave_notify_event = gtk_expander_leave_notify; - widget_class->focus = gtk_expander_focus; - widget_class->grab_notify = gtk_expander_grab_notify; - widget_class->state_changed = gtk_expander_state_changed; - - container_class->add = gtk_expander_add; - container_class->remove = gtk_expander_remove; - container_class->forall = gtk_expander_forall; - - klass->activate = gtk_expander_activate; - - g_object_class_install_property (gobject_class, - PROP_EXPANDED, - g_param_spec_boolean ("expanded", - P_("Expanded"), - P_("Whether the expander has been opened to reveal the child widget"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_LABEL, - g_param_spec_string ("label", - P_("Label"), - P_("Text of the expander's label"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_USE_UNDERLINE, - g_param_spec_boolean ("use_underline", - P_("Use underline"), - P_("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_USE_MARKUP, - g_param_spec_boolean ("use_markup", - P_("Use markup"), - P_("The text of the label includes XML markup. See pango_parse_markup()"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_SPACING, - g_param_spec_int ("spacing", - P_("Spacing"), - P_("Space to put between the label and the child"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_LABEL_WIDGET, - g_param_spec_object ("label_widget", - P_("Label widget"), - P_("A widget to display in place of the usual expander label"), - GTK_TYPE_WIDGET, - G_PARAM_READWRITE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("expander-size", - P_("Expander Size"), - P_("Size of the expander arrow"), - 0, - G_MAXINT, - DEFAULT_EXPANDER_SIZE, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("expander-spacing", - P_("Indicator Spacing"), - P_("Spacing around expander arrow"), - 0, - G_MAXINT, - DEFAULT_EXPANDER_SPACING, - G_PARAM_READABLE)); - - widget_class->activate_signal = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GtkExpanderClass, activate), - NULL, NULL, - gtk_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -gtk_expander_finalize (GObject *obj) -{ - GtkExpander *self = (GtkExpander *)obj; - - g_free(self->priv); - - G_OBJECT_CLASS(parent_class)->finalize (obj); -} - -static void -gtk_expander_init (GtkExpander *expander) -{ - GtkExpanderPrivate *priv; - - expander->priv = priv = g_new0(GtkExpanderPrivate, 1); - - GTK_WIDGET_SET_FLAGS (expander, GTK_CAN_FOCUS); - GTK_WIDGET_SET_FLAGS (expander, GTK_NO_WINDOW); - - priv->label_widget = NULL; - priv->event_window = NULL; - priv->spacing = 0; - - priv->expander_style = GTK_EXPANDER_COLLAPSED; - priv->animation_timeout = 0; - - priv->expanded = FALSE; - priv->use_underline = FALSE; - priv->use_markup = FALSE; - priv->button_down = FALSE; - priv->prelight = FALSE; -} - -static void -gtk_expander_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkExpander *expander = GTK_EXPANDER (object); - - switch (prop_id) - { - case PROP_EXPANDED: - gtk_expander_set_expanded (expander, g_value_get_boolean (value)); - break; - case PROP_LABEL: - gtk_expander_set_label (expander, g_value_get_string (value)); - break; - case PROP_USE_UNDERLINE: - gtk_expander_set_use_underline (expander, g_value_get_boolean (value)); - break; - case PROP_USE_MARKUP: - gtk_expander_set_use_markup (expander, g_value_get_boolean (value)); - break; - case PROP_SPACING: - gtk_expander_set_spacing (expander, g_value_get_int (value)); - break; - case PROP_LABEL_WIDGET: - gtk_expander_set_label_widget (expander, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_expander_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkExpander *expander = GTK_EXPANDER (object); - GtkExpanderPrivate *priv = expander->priv; - - switch (prop_id) - { - case PROP_EXPANDED: - g_value_set_boolean (value, priv->expanded); - break; - case PROP_LABEL: - g_value_set_string (value, gtk_expander_get_label (expander)); - break; - case PROP_USE_UNDERLINE: - g_value_set_boolean (value, priv->use_underline); - break; - case PROP_USE_MARKUP: - g_value_set_boolean (value, priv->use_markup); - break; - case PROP_SPACING: - g_value_set_int (value, priv->spacing); - break; - case PROP_LABEL_WIDGET: - g_value_set_object (value, - priv->label_widget ? - G_OBJECT (priv->label_widget) : NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_expander_destroy (GtkObject *object) -{ - GtkExpanderPrivate *priv = GTK_EXPANDER (object)->priv; - - if (priv->animation_timeout) - { - g_source_remove (priv->animation_timeout); - priv->animation_timeout = 0; - } - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -gtk_expander_realize (GtkWidget *widget) -{ - GtkExpanderPrivate *priv; - GdkWindowAttr attributes; - gint attributes_mask; - gint border_width; - GdkRectangle expander_rect; - - priv = GTK_EXPANDER (widget)->priv; - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - border_width = GTK_CONTAINER (widget)->border_width; - - get_expander_bounds (GTK_EXPANDER (widget), &expander_rect); - - attributes.window_type = GDK_WINDOW_CHILD; - attributes.x = widget->allocation.x + border_width; - attributes.y = expander_rect.y; - attributes.width = MAX (widget->allocation.width - 2 * border_width, 1); - attributes.height = expander_rect.width; - attributes.wclass = GDK_INPUT_ONLY; - attributes.event_mask = gtk_widget_get_events (widget) | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y; - - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); - - priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (priv->event_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); -} - -static void -gtk_expander_unrealize (GtkWidget *widget) -{ - GtkExpanderPrivate *priv = GTK_EXPANDER (widget)->priv; - - if (priv->event_window) - { - gdk_window_set_user_data (priv->event_window, NULL); - gdk_window_destroy (priv->event_window); - priv->event_window = NULL; - } - - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); -} - -static void -gtk_expander_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkExpander *expander; - GtkBin *bin; - GtkExpanderPrivate *priv; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - - bin = GTK_BIN (widget); - expander = GTK_EXPANDER (widget); - priv = expander->priv; - - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - requisition->width = expander_size + 2 * expander_spacing + - 2 * focus_width + 2 * focus_pad; - requisition->height = interior_focus ? (2 * focus_width + 2 * focus_pad) : 0; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkRequisition label_requisition; - - gtk_widget_size_request (priv->label_widget, &label_requisition); - - requisition->width += label_requisition.width; - requisition->height += label_requisition.height; - } - - requisition->height = MAX (expander_size + 2 * expander_spacing, requisition->height); - - if (!interior_focus) - requisition->height += 2 * focus_width + 2 * focus_pad; - - if (bin->child && GTK_WIDGET_CHILD_VISIBLE (bin->child)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (bin->child, &child_requisition); - - requisition->width = MAX (requisition->width, child_requisition.width); - requisition->height += child_requisition.height + priv->spacing; - } - - requisition->width += 2 * border_width; - requisition->height += 2 * border_width; -} - -static void -get_expander_bounds (GtkExpander *expander, - GdkRectangle *rect) -{ - GtkWidget *widget; - GtkBin *bin; - GtkExpanderPrivate *priv; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - gboolean ltr; - - widget = GTK_WIDGET (expander); - bin = GTK_BIN (expander); - priv = expander->priv; - - border_width = GTK_CONTAINER (expander)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - rect->x = widget->allocation.x + border_width; - rect->y = widget->allocation.y + border_width; - - if (ltr) - rect->x += expander_spacing; - else - rect->x += widget->allocation.width - 2 * border_width - - expander_spacing - expander_size; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation; - - label_allocation = priv->label_widget->allocation; - - if (expander_size < label_allocation.height) - rect->y += focus_width + focus_pad + (label_allocation.height - expander_size) / 2; - else - rect->y += expander_spacing; - } - else - { - rect->y += expander_spacing; - } - - if (!interior_focus) - { - if (ltr) - rect->x += focus_width + focus_pad; - else - rect->x -= focus_width + focus_pad; - rect->y += focus_width + focus_pad; - } - - rect->width = rect->height = expander_size; -} - -static void -gtk_expander_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkExpander *expander; - GtkBin *bin; - GtkExpanderPrivate *priv; - GtkRequisition child_requisition; - gboolean child_visible = FALSE; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - gint label_height; - - expander = GTK_EXPANDER (widget); - bin = GTK_BIN (widget); - priv = expander->priv; - - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - child_requisition.width = 0; - child_requisition.height = 0; - if (bin->child && GTK_WIDGET_CHILD_VISIBLE (bin->child)) - { - child_visible = TRUE; - gtk_widget_get_child_requisition (bin->child, &child_requisition); - } - - widget->allocation = *allocation; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation; - GtkRequisition label_requisition; - gboolean ltr; - - gtk_widget_get_child_requisition (priv->label_widget, &label_requisition); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - if (ltr) - label_allocation.x = (widget->allocation.x + - border_width + focus_width + focus_pad + - expander_size + 2 * expander_spacing); - else - label_allocation.x = (widget->allocation.x + widget->allocation.width - - (label_requisition.width + - border_width + focus_width + focus_pad + - expander_size + 2 * expander_spacing)); - - label_allocation.y = widget->allocation.y + border_width + focus_width + focus_pad; - - label_allocation.width = MIN (label_requisition.width, - allocation->width - 2 * border_width - - expander_size - 2 * expander_spacing - - 2 * focus_width - 2 * focus_pad); - label_allocation.width = MAX (label_allocation.width, 1); - - label_allocation.height = MIN (label_requisition.height, - allocation->height - 2 * border_width - - 2 * focus_width - 2 * focus_pad - - (child_visible ? priv->spacing : 0)); - label_allocation.height = MAX (label_allocation.height, 1); - - gtk_widget_size_allocate (priv->label_widget, &label_allocation); - - label_height = label_allocation.height; - } - else - { - label_height = 0; - } - - if (GTK_WIDGET_REALIZED (widget)) - { - GdkRectangle rect; - - get_expander_bounds (expander, &rect); - - gdk_window_move_resize (priv->event_window, - allocation->x + border_width, rect.y, - MAX (allocation->width - 2 * border_width, 1), rect.width); - } - - if (child_visible) - { - GtkAllocation child_allocation; - gint top_height; - - top_height = MAX (2 * expander_spacing + expander_size, - label_height + - (interior_focus ? 2 * focus_width + 2 * focus_pad : 0)); - - child_allocation.x = widget->allocation.x + border_width; - child_allocation.y = widget->allocation.y + border_width + top_height + priv->spacing; - - if (!interior_focus) - child_allocation.y += 2 * focus_width + 2 * focus_pad; - - child_allocation.width = MAX (allocation->width - 2 * border_width, 1); - - child_allocation.height = allocation->height - top_height - - 2 * border_width - priv->spacing - - (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0); - child_allocation.height = MAX (child_allocation.height, 1); - - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} - -static void -gtk_expander_map (GtkWidget *widget) -{ - GtkExpanderPrivate *priv = GTK_EXPANDER (widget)->priv; - - if (priv->label_widget) - gtk_widget_map (priv->label_widget); - - GTK_WIDGET_CLASS (parent_class)->map (widget); - - if (priv->event_window) - gdk_window_show (priv->event_window); -} - -static void -gtk_expander_unmap (GtkWidget *widget) -{ - GtkExpanderPrivate *priv = GTK_EXPANDER (widget)->priv; - - if (priv->event_window) - gdk_window_hide (priv->event_window); - - GTK_WIDGET_CLASS (parent_class)->unmap (widget); - - if (priv->label_widget) - gtk_widget_unmap (priv->label_widget); -} - -static void -gtk_expander_paint_prelight (GtkExpander *expander) -{ - GtkWidget *widget; - GtkContainer *container; - GtkExpanderPrivate *priv; - GdkRectangle area; - gboolean interior_focus; - int focus_width; - int focus_pad; - int expander_size; - int expander_spacing; - - priv = expander->priv; - widget = GTK_WIDGET (expander); - container = GTK_CONTAINER (expander); - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - area.x = widget->allocation.x + container->border_width; - area.y = widget->allocation.y + container->border_width; - area.width = widget->allocation.width - (2 * container->border_width); - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - area.height = priv->label_widget->allocation.height; - else - area.height = 0; - - area.height += interior_focus ? (focus_width + focus_pad) * 2 : 0; - area.height = MAX (area.height, expander_size + 2 * expander_spacing); - area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0; - - gtk_paint_flat_box (widget->style, widget->window, - GTK_STATE_PRELIGHT, - GTK_SHADOW_ETCHED_OUT, - &area, widget, "expander", - area.x, area.y, - area.width, area.height); -} - -static void -gtk_expander_paint (GtkExpander *expander) -{ - GtkWidget *widget; - GdkRectangle clip; - GtkStateType state; - - widget = GTK_WIDGET (expander); - - get_expander_bounds (expander, &clip); - - state = widget->state; - if (expander->priv->prelight) - { - state = GTK_STATE_PRELIGHT; - - gtk_expander_paint_prelight (expander); - } - - gtk_paint_expander (widget->style, - widget->window, - state, - &clip, - widget, - "expander", - clip.x + clip.width / 2, - clip.y + clip.height / 2, - expander->priv->expander_style); -} - -static void -gtk_expander_paint_focus (GtkExpander *expander, - GdkRectangle *area) -{ - GtkWidget *widget; - GtkExpanderPrivate *priv; - gint x, y, width, height; - gboolean interior_focus; - gint border_width; - gint focus_width; - gint focus_pad; - gint expander_size; - gint expander_spacing; - gboolean ltr; - - widget = GTK_WIDGET (expander); - priv = expander->priv; - - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; - - if (ltr && interior_focus) - x += expander_spacing * 2 + expander_size; - - width = height = 0; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation = priv->label_widget->allocation; - - width = label_allocation.width; - height = label_allocation.height; - } - - if (!interior_focus) - { - width += expander_size + 2 * expander_spacing; - height = MAX (height, expander_size + 2 * expander_spacing); - } - - width += 2 * focus_pad + 2 * focus_width; - height += 2 * focus_pad + 2 * focus_width; - - gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), - area, widget, "expander", - x, y, width, height); -} - -static gboolean -gtk_expander_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - if (GTK_WIDGET_DRAWABLE (widget)) - { - GtkExpander *expander = GTK_EXPANDER (widget); - - gtk_expander_paint (expander); - - if (GTK_WIDGET_HAS_FOCUS (expander)) - gtk_expander_paint_focus (expander, &event->area); - - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - } - - return FALSE; -} - -static gboolean -gtk_expander_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - GtkExpander *expander = GTK_EXPANDER (widget); - - if (event->button == 1 && event->window == expander->priv->event_window) - { - expander->priv->button_down = TRUE; - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_expander_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - GtkExpander *expander = GTK_EXPANDER (widget); - - if (event->button == 1 && expander->priv->button_down) - { - gtk_widget_activate (widget); - expander->priv->button_down = FALSE; - return TRUE; - } - - return FALSE; -} - -static void -gtk_expander_grab_notify (GtkWidget *widget, - gboolean was_grabbed) -{ - if (!was_grabbed) - GTK_EXPANDER (widget)->priv->button_down = FALSE; -} - -static void -gtk_expander_state_changed (GtkWidget *widget, - GtkStateType previous_state) -{ - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - GTK_EXPANDER (widget)->priv->button_down = FALSE; -} - -static void -gtk_expander_redraw_expander (GtkExpander *expander) -{ - GtkWidget *widget; - - widget = GTK_WIDGET (expander); - - if (GTK_WIDGET_REALIZED (widget)) - gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE); -} - -static gboolean -gtk_expander_enter_notify (GtkWidget *widget, - GdkEventCrossing *event) -{ - GtkExpander *expander = GTK_EXPANDER (widget); - GtkWidget *event_widget; - - event_widget = gtk_get_event_widget ((GdkEvent *) event); - - if (event_widget == widget && - event->detail != GDK_NOTIFY_INFERIOR) - { - expander->priv->prelight = TRUE; - - if (expander->priv->label_widget) - gtk_widget_set_state (expander->priv->label_widget, GTK_STATE_PRELIGHT); - - gtk_expander_redraw_expander (expander); - } - - return FALSE; -} - -static gboolean -gtk_expander_leave_notify (GtkWidget *widget, - GdkEventCrossing *event) -{ - GtkExpander *expander = GTK_EXPANDER (widget); - GtkWidget *event_widget; - - event_widget = gtk_get_event_widget ((GdkEvent *) event); - - if (event_widget == widget && - event->detail != GDK_NOTIFY_INFERIOR) - { - expander->priv->prelight = FALSE; - - if (expander->priv->label_widget) - gtk_widget_set_state (expander->priv->label_widget, GTK_STATE_NORMAL); - - gtk_expander_redraw_expander (expander); - } - - return FALSE; -} - -typedef enum -{ - FOCUS_NONE, - FOCUS_WIDGET, - FOCUS_LABEL, - FOCUS_CHILD -} FocusSite; - -static gboolean -focus_current_site (GtkExpander *expander, - GtkDirectionType direction) -{ - GtkWidget *current_focus; - - current_focus = GTK_CONTAINER (expander)->focus_child; - - if (!current_focus) - return FALSE; - - return gtk_widget_child_focus (current_focus, direction); -} - -static gboolean -focus_in_site (GtkExpander *expander, - FocusSite site, - GtkDirectionType direction) -{ - switch (site) - { - case FOCUS_WIDGET: - gtk_widget_grab_focus (GTK_WIDGET (expander)); - return TRUE; - case FOCUS_LABEL: - if (expander->priv->label_widget) - return gtk_widget_child_focus (expander->priv->label_widget, direction); - else - return FALSE; - case FOCUS_CHILD: - { - GtkWidget *child = gtk_bin_get_child (GTK_BIN (expander)); - - if (child && GTK_WIDGET_CHILD_VISIBLE (child)) - return gtk_widget_child_focus (child, direction); - else - return FALSE; - } - case FOCUS_NONE: - break; - } - - g_assert_not_reached (); - return FALSE; -} - -static FocusSite -get_next_site (GtkExpander *expander, - FocusSite site, - GtkDirectionType direction) -{ - gboolean ltr; - - ltr = gtk_widget_get_direction (GTK_WIDGET (expander)) != GTK_TEXT_DIR_RTL; - - switch (site) - { - case FOCUS_NONE: - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_LEFT: - case GTK_DIR_UP: - return FOCUS_CHILD; - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_DOWN: - case GTK_DIR_RIGHT: - return FOCUS_WIDGET; - } - case FOCUS_WIDGET: - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_UP: - return FOCUS_NONE; - case GTK_DIR_LEFT: - return ltr ? FOCUS_NONE : FOCUS_LABEL; - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_DOWN: - return FOCUS_LABEL; - case GTK_DIR_RIGHT: - return ltr ? FOCUS_LABEL : FOCUS_NONE; - break; - } - case FOCUS_LABEL: - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_UP: - return FOCUS_WIDGET; - case GTK_DIR_LEFT: - return ltr ? FOCUS_WIDGET : FOCUS_CHILD; - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_DOWN: - return FOCUS_CHILD; - case GTK_DIR_RIGHT: - return ltr ? FOCUS_CHILD : FOCUS_WIDGET; - break; - } - case FOCUS_CHILD: - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_LEFT: - case GTK_DIR_UP: - return FOCUS_LABEL; - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_DOWN: - case GTK_DIR_RIGHT: - return FOCUS_NONE; - } - } - - g_assert_not_reached (); - return FOCUS_NONE; -} - -static gboolean -gtk_expander_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkExpander *expander = GTK_EXPANDER (widget); - - if (!focus_current_site (expander, direction)) - { - GtkWidget *old_focus_child; - gboolean widget_is_focus; - FocusSite site = FOCUS_NONE; - - widget_is_focus = gtk_widget_is_focus (widget); - old_focus_child = GTK_CONTAINER (widget)->focus_child; - - if (old_focus_child && old_focus_child == expander->priv->label_widget) - site = FOCUS_LABEL; - else if (old_focus_child) - site = FOCUS_CHILD; - else if (widget_is_focus) - site = FOCUS_WIDGET; - - while ((site = get_next_site (expander, site, direction)) != FOCUS_NONE) - { - if (focus_in_site (expander, site, direction)) - return TRUE; - } - - return FALSE; - } - - return TRUE; -} - -static void -gtk_expander_add (GtkContainer *container, - GtkWidget *widget) -{ - GTK_CONTAINER_CLASS (parent_class)->add (container, widget); - - gtk_widget_set_child_visible (widget, GTK_EXPANDER (container)->priv->expanded); - gtk_widget_queue_resize (GTK_WIDGET (container)); -} - -static void -gtk_expander_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkExpander *expander = GTK_EXPANDER (container); - - if (GTK_EXPANDER (expander)->priv->label_widget == widget) - gtk_expander_set_label_widget (expander, NULL); - else - GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); -} - -static void -gtk_expander_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkBin *bin = GTK_BIN (container); - GtkExpanderPrivate *priv = GTK_EXPANDER (container)->priv; - - if (bin->child) - (* callback) (bin->child, callback_data); - - if (priv->label_widget) - (* callback) (priv->label_widget, callback_data); -} - -static void -gtk_expander_activate (GtkExpander *expander) -{ - gtk_expander_set_expanded (expander, !expander->priv->expanded); -} - - -/** - * gtk_expander_new: - * @label: the text of the label - * - * Creates a new expander using @label as the text of the label. - * - * Return value: a new #GtkExpander widget. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_expander_new (const gchar *label) -{ - return g_object_new (GTK_TYPE_EXPANDER, "label", label, NULL); -} - -/** - * gtk_expander_new_with_mnemonic: - * @label: the text of the label with an underscore in front of the - * mnemonic character - * - * Creates a new expander using @label as the text of the label. - * If characters in @label are preceded by an underscore, they are underlined. - * If you need a literal underscore character in a label, use '__' (two - * underscores). The first underlined character represents a keyboard - * accelerator called a mnemonic. - * Pressing Alt and that key activates the button. - * - * Return value: a new #GtkExpander widget. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_expander_new_with_mnemonic (const gchar *label) -{ - return g_object_new (GTK_TYPE_EXPANDER, - "label", label, - "use_underline", TRUE, - NULL); -} - -static gboolean -gtk_expander_animation_timeout (GtkExpander *expander) -{ - GtkExpanderPrivate *priv = expander->priv; - GdkRectangle area; - gboolean finish = FALSE; - - GDK_THREADS_ENTER(); - - if (GTK_WIDGET_REALIZED (expander)) - { - get_expander_bounds (expander, &area); - gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE); - } - - if (priv->expanded) - { - if (priv->expander_style == GTK_EXPANDER_COLLAPSED) - { - priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED; - } - else - { - priv->expander_style = GTK_EXPANDER_EXPANDED; - finish = TRUE; - } - } - else - { - if (priv->expander_style == GTK_EXPANDER_EXPANDED) - { - priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED; - } - else - { - priv->expander_style = GTK_EXPANDER_COLLAPSED; - finish = TRUE; - } - } - - if (finish) - { - priv->animation_timeout = 0; - if (GTK_BIN (expander)->child) - gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded); - gtk_widget_queue_resize (GTK_WIDGET (expander)); - } - - GDK_THREADS_LEAVE(); - - return !finish; -} - -static void -gtk_expander_start_animation (GtkExpander *expander) -{ - GtkExpanderPrivate *priv = expander->priv; - - if (priv->animation_timeout) - g_source_remove (priv->animation_timeout); - - priv->animation_timeout = - g_timeout_add (50, - (GSourceFunc) gtk_expander_animation_timeout, - expander); -} - -/** - * gtk_expander_set_expanded: - * @expander: a #GtkExpander - * @expanded: whether the child widget is revealed - * - * Sets the state of the expander. Set to %TRUE, if you want - * the child widget to be revealed, and %FALSE if you want the - * child widget to be hidden. - * - * Since: 2.4 - **/ -void -gtk_expander_set_expanded (GtkExpander *expander, - gboolean expanded) -{ - GtkExpanderPrivate *priv; - - g_return_if_fail (GTK_IS_EXPANDER (expander)); - - priv = expander->priv; - - expanded = expanded != FALSE; - - if (priv->expanded != expanded) - { - priv->expanded = expanded; - - if (GTK_WIDGET_REALIZED (expander)) - { - gtk_expander_start_animation (expander); - } - else - { - priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : - GTK_EXPANDER_COLLAPSED; - - if (GTK_BIN (expander)->child) - { - gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded); - gtk_widget_queue_resize (GTK_WIDGET (expander)); - } - } - - g_object_notify (G_OBJECT (expander), "expanded"); - } -} - -/** - * gtk_expander_get_expanded: - * @expander:a #GtkExpander - * - * Queries a #GtkExpander and returns its current state. Returns %TRUE - * if the child widget is revealed. - * - * See gtk_expander_set_expanded(). - * - * Return value: the current state of the expander. - * - * Since: 2.4 - **/ -gboolean -gtk_expander_get_expanded (GtkExpander *expander) -{ - g_return_val_if_fail (GTK_IS_EXPANDER (expander), FALSE); - - return expander->priv->expanded; -} - -/** - * gtk_expander_set_spacing: - * @expander: a #GtkExpander - * @spacing: distance between the expander and child in pixels. - * - * Sets the spacing field of @expander, which is the number of pixels to - * place between expander and the child. - * - * Since: 2.4 - **/ -void -gtk_expander_set_spacing (GtkExpander *expander, - gint spacing) -{ - g_return_if_fail (GTK_IS_EXPANDER (expander)); - g_return_if_fail (spacing >= 0); - - if (expander->priv->spacing != spacing) - { - expander->priv->spacing = spacing; - - gtk_widget_queue_resize (GTK_WIDGET (expander)); - - g_object_notify (G_OBJECT (expander), "spacing"); - } -} - -/** - * gtk_expander_get_spacing: - * @expander: a #GtkExpander - * - * Gets the value set by gtk_expander_set_spacing(). - * - * Return value: spacing between the expander and child. - * - * Since: 2.4 - **/ -gint -gtk_expander_get_spacing (GtkExpander *expander) -{ - g_return_val_if_fail (GTK_IS_EXPANDER (expander), 0); - - return expander->priv->spacing; -} - -/** - * gtk_expander_set_label: - * @expander: a #GtkExpander - * @label: a string - * - * Sets the text of the label of the expander to @label. - * - * This will also clear any previously set labels. - * - * Since: 2.4 - **/ -void -gtk_expander_set_label (GtkExpander *expander, - const gchar *label) -{ - g_return_if_fail (GTK_IS_EXPANDER (expander)); - - if (!label) - { - gtk_expander_set_label_widget (expander, NULL); - } - else - { - GtkWidget *child; - - child = gtk_label_new (label); - gtk_label_set_use_underline (GTK_LABEL (child), expander->priv->use_underline); - gtk_label_set_use_markup (GTK_LABEL (child), expander->priv->use_markup); - gtk_widget_show (child); - - gtk_expander_set_label_widget (expander, child); - } - - g_object_notify (G_OBJECT (expander), "label"); -} - -/** - * gtk_expander_get_label: - * @expander: a #GtkExpander - * - * Fetches the text from the label of the expander, as set by - * gtk_expander_set_label(). If the label text has not - * been set the return value will be %NULL. This will be the - * case if you create an empty button with gtk_button_new() to - * use as a container. - * - * Return value: The text of the label widget. This string is owned - * by the widget and must not be modified or freed. - * - * Since: 2.4 - **/ -G_CONST_RETURN char * -gtk_expander_get_label (GtkExpander *expander) -{ - GtkExpanderPrivate *priv; - - g_return_val_if_fail (GTK_IS_EXPANDER (expander), NULL); - - priv = expander->priv; - - if (priv->label_widget && GTK_IS_LABEL (priv->label_widget)) - return gtk_label_get_text (GTK_LABEL (priv->label_widget)); - else - return NULL; -} - -/** - * gtk_expander_set_use_underline: - * @expander: a #GtkExpander - * @use_underline: %TRUE if underlines in the text indicate mnemonics - * - * If true, an underline in the text of the expander label indicates - * the next character should be used for the mnemonic accelerator key. - * - * Since: 2.4 - **/ -void -gtk_expander_set_use_underline (GtkExpander *expander, - gboolean use_underline) -{ - GtkExpanderPrivate *priv; - - g_return_if_fail (GTK_IS_EXPANDER (expander)); - - priv = expander->priv; - - use_underline = use_underline != FALSE; - - if (priv->use_underline != use_underline) - { - priv->use_underline = use_underline; - - if (priv->label_widget && GTK_IS_LABEL (priv->label_widget)) - gtk_label_set_use_underline (GTK_LABEL (priv->label_widget), use_underline); - - g_object_notify (G_OBJECT (expander), "use-underline"); - } -} - -/** - * gtk_expander_get_use_underline: - * @expander: a #GtkExpander - * - * Returns whether an embedded underline in the expander label indicates a - * mnemonic. See gtk_expander_set_use_underline(). - * - * Return value: %TRUE if an embedded underline in the expander label - * indicates the mnemonic accelerator keys. - * - * Since: 2.4 - **/ -gboolean -gtk_expander_get_use_underline (GtkExpander *expander) -{ - g_return_val_if_fail (GTK_IS_EXPANDER (expander), FALSE); - - return expander->priv->use_underline; -} - -/** - * gtk_expander_set_use_markup: - * @expander: a #GtkExpander - * @use_markup: %TRUE if the label's text should be parsed for markup - * - * Sets whether the text of the label contains markup in <link - * linkend="PangoMarkupFormat">Pango's text markup - * language</link>. See gtk_label_set_markup(). - * - * Since: 2.4 - **/ -void -gtk_expander_set_use_markup (GtkExpander *expander, - gboolean use_markup) -{ - GtkExpanderPrivate *priv; - - g_return_if_fail (GTK_IS_EXPANDER (expander)); - - priv = expander->priv; - - use_markup = use_markup != FALSE; - - if (priv->use_markup != use_markup) - { - priv->use_markup = use_markup; - - if (priv->label_widget && GTK_IS_LABEL (priv->label_widget)) - gtk_label_set_use_markup (GTK_LABEL (priv->label_widget), use_markup); - - g_object_notify (G_OBJECT (expander), "use-markup"); - } -} - -/** - * gtk_expander_get_use_markup: - * @expander: a #GtkExpander - * - * Returns whether the label's text is interpreted as marked up with - * the <link linkend="PangoMarkupFormat">Pango text markup - * language</link>. See gtk_expander_set_use_markup (). - * - * Return value: %TRUE if the label's text will be parsed for markup - * - * Since: 2.4 - **/ -gboolean -gtk_expander_get_use_markup (GtkExpander *expander) -{ - g_return_val_if_fail (GTK_IS_EXPANDER (expander), FALSE); - - return expander->priv->use_markup; -} - -/** - * gtk_expander_set_label_widget: - * @expander: a #GtkExpander - * @label_widget: the new label widget - * - * Set the label widget for the expander. This is the widget - * that will appear embedded alongside the expander arrow. - * - * Since: 2.4 - **/ -void -gtk_expander_set_label_widget (GtkExpander *expander, - GtkWidget *label_widget) -{ - GtkExpanderPrivate *priv; - - g_return_if_fail (GTK_IS_EXPANDER (expander)); - g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); - g_return_if_fail (label_widget == NULL || label_widget->parent == NULL); - - priv = expander->priv; - - if (priv->label_widget == label_widget) - return; - - if (priv->label_widget) - { - gtk_widget_set_state (priv->label_widget, GTK_STATE_NORMAL); - gtk_widget_unparent (priv->label_widget); - } - - priv->label_widget = label_widget; - - if (label_widget) - { - priv->label_widget = label_widget; - - gtk_widget_set_parent (label_widget, GTK_WIDGET (expander)); - - if (priv->prelight) - gtk_widget_set_state (label_widget, GTK_STATE_PRELIGHT); - } - - if (GTK_WIDGET_VISIBLE (expander)) - gtk_widget_queue_resize (GTK_WIDGET (expander)); - - g_object_freeze_notify (G_OBJECT (expander)); - g_object_notify (G_OBJECT (expander), "label-widget"); - g_object_notify (G_OBJECT (expander), "label"); - g_object_thaw_notify (G_OBJECT (expander)); -} - -/** - * gtk_expander_get_label_widget: - * @expander: a #GtkExpander - * - * Retrieves the label widget for the frame. See - * gtk_expander_set_label_widget(). - * - * Return value: the label widget, or %NULL if there is none. - * - * Since: 2.4 - **/ -GtkWidget * -gtk_expander_get_label_widget (GtkExpander *expander) -{ - g_return_val_if_fail (GTK_IS_EXPANDER (expander), NULL); - - return expander->priv->label_widget; -} - -#define __GTK_EXPANDER_C__ - -#endif /* Gtk 2.4 */
--- a/pidgin/gtkexpander.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - * - * Authors: - * Mark McLoughlin <mark@skynet.ie> - */ - -#ifndef __GTK_EXPANDER_H__ -#define __GTK_EXPANDER_H__ - -#include <gtk/gtkbin.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_EXPANDER (gtk_expander_get_type ()) -#define GTK_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_EXPANDER, GtkExpander)) -#define GTK_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_EXPANDER, GtkExpanderClass)) -#define GTK_IS_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_EXPANDER)) -#define GTK_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EXPANDER)) -#define GTK_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_EXPANDER, GtkExpanderClass)) - -typedef struct _GtkExpander GtkExpander; -typedef struct _GtkExpanderClass GtkExpanderClass; -typedef struct _GtkExpanderPrivate GtkExpanderPrivate; - -struct _GtkExpander -{ - GtkBin bin; - - GtkExpanderPrivate *priv; -}; - -struct _GtkExpanderClass -{ - GtkBinClass parent_class; - - /* Key binding signal; to get notification on the expansion - * state connect to notify:expanded. - */ - void (* activate) (GtkExpander *expander); -}; - -GType gtk_expander_get_type (void) G_GNUC_CONST; - -GtkWidget *gtk_expander_new (const gchar *label); -GtkWidget *gtk_expander_new_with_mnemonic (const gchar *label); - -void gtk_expander_set_expanded (GtkExpander *expander, - gboolean expanded); -gboolean gtk_expander_get_expanded (GtkExpander *expander); - -/* Spacing between the expander/label and the child */ -void gtk_expander_set_spacing (GtkExpander *expander, - gint spacing); -gint gtk_expander_get_spacing (GtkExpander *expander); - -void gtk_expander_set_label (GtkExpander *expander, - const gchar *label); -G_CONST_RETURN gchar *gtk_expander_get_label (GtkExpander *expander); - -void gtk_expander_set_use_underline (GtkExpander *expander, - gboolean use_underline); -gboolean gtk_expander_get_use_underline (GtkExpander *expander); - -void gtk_expander_set_use_markup (GtkExpander *expander, - gboolean use_markup); -gboolean gtk_expander_get_use_markup (GtkExpander *expander); - -void gtk_expander_set_label_widget (GtkExpander *expander, - GtkWidget *label_widget); -GtkWidget *gtk_expander_get_label_widget (GtkExpander *expander); - -G_END_DECLS - -#endif /* __GTK_EXPANDER_H__ */
--- a/pidgin/gtkft.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/gtkft.c Sun Aug 23 02:37:12 2009 +0000 @@ -32,10 +32,8 @@ #include "prpl.h" #include "util.h" -#include "gtkcellrendererprogress.h" #include "gtkft.h" #include "prefs.h" -#include "gtkexpander.h" #include "pidginstock.h" #include "gtkutils.h" @@ -621,7 +619,7 @@ gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); /* Progress bar column */ - renderer = pidgin_cell_renderer_progress_new(); + renderer = gtk_cell_renderer_progress_new(); column = gtk_tree_view_column_new_with_attributes(_("Progress"), renderer, "percentage", COLUMN_PROGRESS, NULL); gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
--- a/pidgin/gtkimhtml.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/gtkimhtml.c Sun Aug 23 02:37:12 2009 +0000 @@ -3666,11 +3666,7 @@ image->filesel = NULL; if (save->data && save->datasize) { -#if GLIB_CHECK_VERSION(2,8,0) g_file_set_contents(filename, save->data, save->datasize, &error); -#else - purple_util_write_data_to_file_absolute(filename, save->data, save->datasize); -#endif } else { gchar *type = NULL; #if GTK_CHECK_VERSION(2,2,0)
--- a/pidgin/gtkmain.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/gtkmain.c Sun Aug 23 02:37:12 2009 +0000 @@ -742,9 +742,7 @@ return 1; } -#if GLIB_CHECK_VERSION(2,2,0) g_set_application_name(_("Pidgin")); -#endif /* glib-2.0 >= 2.2.0 */ #ifdef _WIN32 winpidgin_init(hint);
--- a/pidgin/gtksavedstatuses.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/gtksavedstatuses.c Sun Aug 23 02:37:12 2009 +0000 @@ -34,7 +34,6 @@ #include "util.h" #include "gtkblist.h" -#include "gtkexpander.h" #include "pidgin.h" #include "gtkimhtml.h" #include "gtkimhtmltoolbar.h"
--- a/pidgin/pidgincombobox.c Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3749 +0,0 @@ -/* pidgincombobox.c - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -/* -#include <config.h> -*/ -#include <gtk/gtkversion.h> -#if !GTK_CHECK_VERSION(2,6,0) -#include "pidgincombobox.h" - -#if !GTK_CHECK_VERSION(2,4,0) -#include <gtk/gtkarrow.h> -#include <gtk/gtkbindings.h> -#include "gtkcelllayout.h" -#include <gtk/gtkcellrenderertext.h> -#include "gtkcellview.h" -#include "gtkcellviewmenuitem.h" -#include <gtk/gtkeventbox.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtktreeselection.h> -/* -#include <gtk/gtktreeprivate.h> -*/ -#include <gtk/gtkvseparator.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtkversion.h> - -#include <gdk/gdkkeysyms.h> - -#include <gobject/gvaluecollector.h> - -#include <string.h> -#include <stdarg.h> - -#define P_(x) (x) - -/* WELCOME, to THE house of evil code */ - -typedef struct _ComboCellInfo ComboCellInfo; -struct _ComboCellInfo -{ - GtkCellRenderer *cell; - GSList *attributes; - - GtkCellLayoutDataFunc func; - gpointer func_data; - GDestroyNotify destroy; - - guint expand : 1; - guint pack : 1; -}; - -struct _GtkComboBoxPrivate -{ - GtkTreeModel *model; - - gint col_column; - gint row_column; - - gint wrap_width; - - gint active_item; - - GtkWidget *tree_view; - GtkTreeViewColumn *column; - - GtkWidget *cell_view; - GtkWidget *cell_view_frame; - - GtkWidget *button; - GtkWidget *box; - GtkWidget *arrow; - GtkWidget *separator; - - GtkWidget *popup_widget; - GtkWidget *popup_window; - GtkWidget *popup_frame; - - guint inserted_id; - guint deleted_id; - guint reordered_id; - guint changed_id; - - gint width; - GSList *cells; - - guint popup_in_progress : 1; - guint destroying : 1; -}; - -/* While debugging this evil code, I have learned that - * there are actually 4 modes to this widget, which can - * be characterized as follows - * - * 1) menu mode, no child added - * - * tree_view -> NULL - * cell_view -> GtkCellView, regular child - * cell_view_frame -> NULL - * button -> GtkToggleButton set_parent to combo - * box -> child of button - * arrow -> child of box - * separator -> child of box - * popup_widget -> GtkMenu - * popup_window -> NULL - * popup_frame -> NULL - * - * 2) menu mode, child added - * - * tree_view -> NULL - * cell_view -> NULL - * cell_view_frame -> NULL - * button -> GtkToggleButton set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> GtkMenu - * popup_window -> NULL - * popup_frame -> NULL - * - * 3) list mode, no child added - * - * tree_view -> GtkTreeView, child of popup_frame - * cell_view -> GtkCellView, regular child - * cell_view_frame -> GtkFrame, set parent to combo - * button -> GtkToggleButton, set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> tree_view - * popup_window -> GtkWindow - * popup_frame -> GtkFrame, child of popup_window - * - * 4) list mode, child added - * - * tree_view -> GtkTreeView, child of popup_frame - * cell_view -> NULL - * cell_view_frame -> NULL - * button -> GtkToggleButton, set_parent to combo - * box -> NULL - * arrow -> GtkArrow, child of button - * separator -> NULL - * popup_widget -> tree_view - * popup_window -> GtkWindow - * popup_frame -> GtkFrame, child of popup_window - * - */ - -enum { - CHANGED, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_MODEL, - PROP_WRAP_WIDTH, - PROP_ROW_SPAN_COLUMN, - PROP_COLUMN_SPAN_COLUMN, - PROP_ACTIVE -}; - -static GtkBinClass *parent_class = NULL; -static guint combo_box_signals[LAST_SIGNAL] = {0,}; - -#define BONUS_PADDING 4 - - -/* common */ -static void gtk_combo_box_class_init (GtkComboBoxClass *klass); -static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface); -static void gtk_combo_box_init (GtkComboBox *combo_box); -static void gtk_combo_box_finalize (GObject *object); -static void gtk_combo_box_destroy (GtkObject *object); - -static void gtk_combo_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *spec); -static void gtk_combo_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *spec); - -static void gtk_combo_box_state_changed (GtkWidget *widget, - GtkStateType previous); -static void gtk_combo_box_style_set (GtkWidget *widget, - GtkStyle *previous); -static void gtk_combo_box_button_toggled (GtkWidget *widget, - gpointer data); -static void gtk_combo_box_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_combo_box_remove (GtkContainer *container, - GtkWidget *widget); - -static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box, - GtkCellRenderer *cell); - -static void gtk_combo_box_menu_show (GtkWidget *menu, - gpointer user_data); -static void gtk_combo_box_menu_hide (GtkWidget *menu, - gpointer user_data); - -static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, - GtkWidget *popup); -#if GTK_CHECK_VERSION(2,2,0) -static void gtk_combo_box_menu_position_below (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -static void gtk_combo_box_menu_position_over (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -static void gtk_combo_box_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data); -#endif - -static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, - GtkTreePath *path); -static void gtk_combo_box_remeasure (GtkComboBox *combo_box); - -static void gtk_combo_box_unset_model (GtkComboBox *combo_box); - -static void gtk_combo_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_combo_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gtk_combo_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static gboolean gtk_combo_box_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static gboolean gtk_combo_box_scroll_event (GtkWidget *widget, - GdkEventScroll *event); -static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box, - gint index); -static gboolean gtk_combo_box_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); - -/* listening to the model */ -static void gtk_combo_box_model_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data); -static void gtk_combo_box_model_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data); -static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data); -static void gtk_combo_box_model_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); - -/* list */ -static void gtk_combo_box_list_position (GtkComboBox *combo_box, - gint *x, - gint *y, - gint *width, - gint *height); - -static void gtk_combo_box_list_setup (GtkComboBox *combo_box); -static void gtk_combo_box_list_destroy (GtkComboBox *combo_box); - -static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box); - -static gboolean gtk_combo_box_list_button_released (GtkWidget *widget, - GdkEventButton *event, - gpointer data); -static gboolean gtk_combo_box_list_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); -static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget, - GdkEventButton *event, - gpointer data); - -static void gtk_combo_box_list_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); - -/* menu */ -static void gtk_combo_box_menu_setup (GtkComboBox *combo_box, - gboolean add_children); -static void gtk_combo_box_menu_fill (GtkComboBox *combo_box); -static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box); - -static void gtk_combo_box_item_get_size (GtkComboBox *combo_box, - gint index, - gint *cols, - gint *rows); -static void gtk_combo_box_relayout_item (GtkComboBox *combo_box, - gint index); -static void gtk_combo_box_relayout (GtkComboBox *combo_box); - -static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); -static void gtk_combo_box_menu_item_activate (GtkWidget *item, - gpointer user_data); -static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data); -static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data); -static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data); -static void gtk_combo_box_menu_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); -static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data); - -/* cell layout */ -static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand); -static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand); -static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout); -static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column); -static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy); -static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *cell); -static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position); -static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling); - -static void cell_view_sync_cells (GtkComboBox *combo_box, - GtkCellView *cell_view); - -#if !GTK_CHECK_VERSION(2,4,0) -static void gtk_menu_attach (GtkMenu *menu, - GtkWidget *child, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach); -#endif - -GType -gtk_combo_box_get_type (void) -{ - static GType combo_box_type = 0; - - if (!combo_box_type) - { - static const GTypeInfo combo_box_info = - { - sizeof (GtkComboBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_combo_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkComboBox), - 0, - (GInstanceInitFunc) gtk_combo_box_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_combo_box_cell_layout_init, - NULL, - NULL - }; - - combo_box_type = g_type_register_static (GTK_TYPE_BIN, - "PidginComboBox", - &combo_box_info, - 0); - - g_type_add_interface_static (combo_box_type, - GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return combo_box_type; -} - -/* common */ -static void -gtk_combo_box_class_init (GtkComboBoxClass *klass) -{ - GObjectClass *object_class; - GtkBindingSet *binding_set; - GtkObjectClass *gtk_object_class; - GtkContainerClass *container_class; - GtkWidgetClass *widget_class; - - binding_set = gtk_binding_set_by_class (klass); - - container_class = (GtkContainerClass *)klass; - container_class->forall = gtk_combo_box_forall; - container_class->add = gtk_combo_box_add; - container_class->remove = gtk_combo_box_remove; - - widget_class = (GtkWidgetClass *)klass; - widget_class->size_allocate = gtk_combo_box_size_allocate; - widget_class->size_request = gtk_combo_box_size_request; - widget_class->expose_event = gtk_combo_box_expose_event; - widget_class->scroll_event = gtk_combo_box_scroll_event; - widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate; - widget_class->style_set = gtk_combo_box_style_set; - widget_class->state_changed = gtk_combo_box_state_changed; - - gtk_object_class = (GtkObjectClass *)klass; - gtk_object_class->destroy = gtk_combo_box_destroy; - - object_class = (GObjectClass *)klass; - object_class->finalize = gtk_combo_box_finalize; - object_class->set_property = gtk_combo_box_set_property; - object_class->get_property = gtk_combo_box_get_property; - - parent_class = g_type_class_peek_parent (klass); - - /* signals */ - combo_box_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GtkComboBoxClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - /* properties */ - g_object_class_install_property (object_class, - PROP_MODEL, - g_param_spec_object ("model", - P_("ComboBox model"), - P_("The model for the combo box"), - GTK_TYPE_TREE_MODEL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_WRAP_WIDTH, - g_param_spec_int ("wrap_width", - P_("Wrap width"), - P_("Wrap width for layouting the items in a grid"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ROW_SPAN_COLUMN, - g_param_spec_int ("row_span_column", - P_("Row span column"), - P_("TreeModel column containing the row span values"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_COLUMN_SPAN_COLUMN, - g_param_spec_int ("column_span_column", - P_("Column span column"), - - P_("TreeModel column containing the column span values"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ACTIVE, - g_param_spec_int ("active", - P_("Active item"), - P_("The item which is currently active"), - -1, - G_MAXINT, - -1, - G_PARAM_READWRITE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boolean ("appears-as-list", - P_("Appears as list"), - P_("Whether combobox dropdowns should look like lists rather than menus"), - FALSE, - G_PARAM_READABLE)); -} - -static void -gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface) -{ - iface->pack_start = gtk_combo_box_cell_layout_pack_start; - iface->pack_end = gtk_combo_box_cell_layout_pack_end; - iface->clear = gtk_combo_box_cell_layout_clear; - iface->add_attribute = gtk_combo_box_cell_layout_add_attribute; - iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func; - iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes; - iface->reorder = gtk_combo_box_cell_layout_reorder; -} - -static void -gtk_combo_box_init (GtkComboBox *combo_box) -{ - combo_box->priv = g_new0(GtkComboBoxPrivate,1); - - combo_box->priv->cell_view = gtk_cell_view_new (); - gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (combo_box)); - GTK_BIN (combo_box)->child = combo_box->priv->cell_view; - gtk_widget_show (combo_box->priv->cell_view); - - combo_box->priv->width = 0; - combo_box->priv->wrap_width = 0; - - combo_box->priv->active_item = -1; - combo_box->priv->col_column = -1; - combo_box->priv->row_column = -1; -} - -static void -gtk_combo_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - switch (prop_id) - { - case PROP_MODEL: - gtk_combo_box_set_model (combo_box, g_value_get_object (value)); - break; - - case PROP_WRAP_WIDTH: - gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value)); - break; - - case PROP_ROW_SPAN_COLUMN: - gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value)); - break; - - case PROP_COLUMN_SPAN_COLUMN: - gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value)); - break; - - case PROP_ACTIVE: - gtk_combo_box_set_active (combo_box, g_value_get_int (value)); - break; - - default: - break; - } -} - -static void -gtk_combo_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - switch (prop_id) - { - case PROP_MODEL: - g_value_set_object (value, combo_box->priv->model); - break; - - case PROP_WRAP_WIDTH: - g_value_set_int (value, combo_box->priv->wrap_width); - break; - - case PROP_ROW_SPAN_COLUMN: - g_value_set_int (value, combo_box->priv->row_column); - break; - - case PROP_COLUMN_SPAN_COLUMN: - g_value_set_int (value, combo_box->priv->col_column); - break; - - case PROP_ACTIVE: - g_value_set_int (value, gtk_combo_box_get_active (combo_box)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_combo_box_state_changed (GtkWidget *widget, - GtkStateType previous) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - if (GTK_WIDGET_REALIZED (widget)) - { - if (combo_box->priv->tree_view && combo_box->priv->cell_view) - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - &widget->style->base[GTK_WIDGET_STATE (widget)]); - } - - gtk_widget_queue_draw (widget); -} - -static void -gtk_combo_box_check_appearance (GtkComboBox *combo_box) -{ - gboolean appears_as_list; - - /* if wrap_width > 0, then we are in grid-mode and forced to use - * unix style - */ - if (combo_box->priv->wrap_width) - appears_as_list = FALSE; - else - gtk_widget_style_get (GTK_WIDGET (combo_box), - "appears-as-list", &appears_as_list, - NULL); - - if (appears_as_list) - { - /* Destroy all the menu mode widgets, if they exist. */ - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - gtk_combo_box_menu_destroy (combo_box); - - /* Create the list mode widgets, if they don't already exist. */ - if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_setup (combo_box); - } - else - { - /* Destroy all the list mode widgets, if they exist. */ - if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_destroy (combo_box); - - /* Create the menu mode widgets, if they don't already exist. */ - if (!GTK_IS_MENU (combo_box->priv->popup_widget)) - gtk_combo_box_menu_setup (combo_box, TRUE); - } -} - -static void -gtk_combo_box_style_set (GtkWidget *widget, - GtkStyle *previous) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - gtk_combo_box_check_appearance (combo_box); - - if (combo_box->priv->tree_view && combo_box->priv->cell_view) - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - &widget->style->base[GTK_WIDGET_STATE (widget)]); -} - -static void -gtk_combo_box_button_toggled (GtkWidget *widget, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) - { - if (!combo_box->priv->popup_in_progress) - gtk_combo_box_popup (combo_box); - } - else - gtk_combo_box_popdown (combo_box); -} - -static void -gtk_combo_box_add (GtkContainer *container, - GtkWidget *widget) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - - if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent) - { - gtk_widget_unparent (combo_box->priv->cell_view); - GTK_BIN (container)->child = NULL; - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - - gtk_widget_set_parent (widget, GTK_WIDGET (container)); - GTK_BIN (container)->child = widget; - - if (combo_box->priv->cell_view && - widget != combo_box->priv->cell_view) - { - /* since the cell_view was unparented, it's gone now */ - combo_box->priv->cell_view = NULL; - - if (!combo_box->priv->tree_view && combo_box->priv->separator) - { - gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent), - combo_box->priv->separator); - combo_box->priv->separator = NULL; - - gtk_widget_queue_resize (GTK_WIDGET (container)); - } - else if (combo_box->priv->cell_view_frame) - { - gtk_widget_unparent (combo_box->priv->cell_view_frame); - combo_box->priv->cell_view_frame = NULL; - } - } -} - -static void -gtk_combo_box_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - gboolean appears_as_list; - - gtk_widget_unparent (widget); - GTK_BIN (container)->child = NULL; - - if (combo_box->priv->destroying) - return; - - gtk_widget_queue_resize (GTK_WIDGET (container)); - - if (!combo_box->priv->tree_view) - appears_as_list = FALSE; - else - appears_as_list = TRUE; - - if (appears_as_list) - gtk_combo_box_list_destroy (combo_box); - else if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_combo_box_menu_destroy (combo_box); - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (!combo_box->priv->cell_view) - { - combo_box->priv->cell_view = gtk_cell_view_new (); - gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container)); - GTK_BIN (container)->child = combo_box->priv->cell_view; - - gtk_widget_show (combo_box->priv->cell_view); - gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), - combo_box->priv->model); - cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view)); - } - - - if (appears_as_list) - gtk_combo_box_list_setup (combo_box); - else - gtk_combo_box_menu_setup (combo_box, TRUE); - - gtk_combo_box_set_active_internal (combo_box, combo_box->priv->active_item); -} - -static ComboCellInfo * -gtk_combo_box_get_cell_info (GtkComboBox *combo_box, - GtkCellRenderer *cell) -{ - GSList *i; - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - - if (info && info->cell == cell) - return info; - } - - return NULL; -} - -static void -gtk_combo_box_menu_show (GtkWidget *menu, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - combo_box->priv->popup_in_progress = FALSE; -} - -static void -gtk_combo_box_menu_hide (GtkWidget *menu, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - FALSE); -} - -static void -gtk_combo_box_detacher (GtkWidget *widget, - GtkMenu *menu) -{ - GtkComboBox *combo_box; - - g_return_if_fail (GTK_IS_COMBO_BOX (widget)); - - combo_box = GTK_COMBO_BOX (widget); - g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu); - - g_signal_handlers_disconnect_by_func (menu, - gtk_combo_box_menu_show, - combo_box); - g_signal_handlers_disconnect_by_func (menu, - gtk_combo_box_menu_hide, - combo_box); - - combo_box->priv->popup_widget = NULL; -} - -static void -gtk_combo_box_set_popup_widget (GtkComboBox *combo_box, - GtkWidget *popup) -{ - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - else if (combo_box->priv->popup_widget) - { - gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame), - combo_box->priv->popup_widget); - g_object_unref (G_OBJECT (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (GTK_IS_MENU (popup)) - { - if (combo_box->priv->popup_window) - { - gtk_widget_destroy (combo_box->priv->popup_window); - combo_box->priv->popup_window = NULL; - combo_box->priv->popup_frame = NULL; - } - - combo_box->priv->popup_widget = popup; - - g_signal_connect (popup, "show", - G_CALLBACK (gtk_combo_box_menu_show), combo_box); - g_signal_connect (popup, "hide", - G_CALLBACK (gtk_combo_box_menu_hide), combo_box); - - gtk_menu_attach_to_widget (GTK_MENU (popup), - GTK_WIDGET (combo_box), - gtk_combo_box_detacher); - } - else - { - if (!combo_box->priv->popup_window) - { - combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_resizable (GTK_WINDOW (combo_box->priv->popup_window), FALSE); -#if GTK_CHECK_VERSION(2,2,0) - gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window), - gtk_widget_get_screen (GTK_WIDGET (combo_box))); -#endif - - combo_box->priv->popup_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame), - GTK_SHADOW_ETCHED_IN); - gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window), - combo_box->priv->popup_frame); - - gtk_widget_show (combo_box->priv->popup_frame); - } - - gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame), - popup); - gtk_widget_show (popup); - g_object_ref (G_OBJECT (popup)); - combo_box->priv->popup_widget = popup; - } -} - -#if GTK_CHECK_VERSION(2,2,0) -static void -gtk_combo_box_menu_position_below (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint sx, sy; - GtkWidget *child; - GtkRequisition req; - GdkScreen *screen; - gint monitor_num; - GdkRectangle monitor; - - /* FIXME: is using the size request here broken? */ - child = GTK_BIN (combo_box)->child; - - gdk_window_get_origin (child->window, &sx, &sy); - - if (GTK_WIDGET_NO_WINDOW (child)) - { - sx += child->allocation.x; - sy += child->allocation.y; - } - - gtk_widget_size_request (GTK_WIDGET (menu), &req); - - if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR) - *x = sx; - else - *x = sx + child->allocation.width - req.width; - *y = sy; - - screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); - gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - - if (*x < monitor.x) - *x = monitor.x; - else if (*x + req.width > monitor.x + monitor.width) - *x = monitor.x + monitor.width - req.width; - - if (monitor.y + monitor.height - *y - child->allocation.height >= req.height) - *y += child->allocation.height; - else if (*y - monitor.y >= req.height) - *y -= req.height; - else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y) - *y += child->allocation.height; - else - *y -= req.height; - - *push_in = FALSE; -} - -static void -gtk_combo_box_menu_position_over (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box; - GtkWidget *active; - GtkWidget *child; - GtkWidget *widget; - GtkRequisition requisition; - GList *children; - gint screen_width; - gint menu_xpos; - gint menu_ypos; - gint menu_width; - - g_return_if_fail (GTK_IS_COMBO_BOX (user_data)); - - combo_box = GTK_COMBO_BOX (user_data); - widget = GTK_WIDGET (combo_box); - - gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); - menu_width = requisition.width; - - active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); - gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos); - - menu_xpos += widget->allocation.x; - menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2; - - if (active != NULL) - { - gtk_widget_get_child_requisition (active, &requisition); - menu_ypos -= requisition.height / 2; - } - - children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children; - while (children) - { - child = children->data; - - if (active == child) - break; - - if (GTK_WIDGET_VISIBLE (child)) - { - gtk_widget_get_child_requisition (child, &requisition); - menu_ypos -= requisition.height; - } - - children = children->next; - } - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - menu_xpos = menu_xpos + widget->allocation.width - menu_width; - - /* Clamp the position on screen */ - screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); - - if (menu_xpos < 0) - menu_xpos = 0; - else if ((menu_xpos + menu_width) > screen_width) - menu_xpos -= ((menu_xpos + menu_width) - screen_width); - - *x = menu_xpos; - *y = menu_ypos; - - *push_in = TRUE; -} - -static void -gtk_combo_box_menu_position (GtkMenu *menu, - gint *x, - gint *y, - gint *push_in, - gpointer user_data) -{ - GtkComboBox *combo_box; - GtkWidget *menu_item; - - combo_box = GTK_COMBO_BOX (user_data); - - if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL) - gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data); - else - { - menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget)); - if (menu_item) - gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget), - menu_item); - - gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data); - } - -} -#endif /* Gtk 2.2 */ - -static void -gtk_combo_box_list_position (GtkComboBox *combo_box, - gint *x, - gint *y, - gint *width, - gint *height) -{ - GtkWidget *sample; - GtkRequisition popup_req; -#if GTK_CHECK_VERSION(2,2,0) - GdkScreen *screen; - gint monitor_num; - GdkRectangle monitor; -#endif - - sample = GTK_BIN (combo_box)->child; - - *width = sample->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_window, &popup_req); - *height = popup_req.height; - - gdk_window_get_origin (sample->window, x, y); - - if (combo_box->priv->cell_view_frame) - { - *x -= GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; - *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - } - - if (GTK_WIDGET_NO_WINDOW (sample)) - { - *x += sample->allocation.x; - *y += sample->allocation.y; - } - -#if GTK_CHECK_VERSION(2,2,0) - screen = gtk_widget_get_screen (GTK_WIDGET (combo_box)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (combo_box)->window); - gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - - if (*x < monitor.x) - *x = monitor.x; - else if (*x + *width > monitor.x + monitor.width) - *x = monitor.x + monitor.width - *width; - - if (*y + sample->allocation.height + *height <= monitor.y + monitor.height) - *y += sample->allocation.height; - else - *y -= *height; -#endif /* Gtk 2.2 */ -} - -/** - * gtk_combo_box_popup: - * @combo_box: a #GtkComboBox - * - * Pops up the menu or dropdown list of @combo_box. - * - * This function is mostly intended for use by accessibility technologies; - * applications should have little use for it. - * - * Since: 2.4 - **/ -void -gtk_combo_box_popup (GtkComboBox *combo_box) -{ - gint x, y, width, height; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget)) - return; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), - combo_box->priv->active_item); - - if (combo_box->priv->wrap_width == 0) - { - GtkRequisition requisition; - - width = GTK_WIDGET (combo_box)->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); - - gtk_widget_set_size_request (combo_box->priv->popup_widget, - MAX (width, requisition.width), -1); - } - - gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), - NULL, NULL, -#if GTK_CHECK_VERSION(2,2,0) - gtk_combo_box_menu_position, -#else - NULL, -#endif - combo_box, 0, 0); - return; - } - - gtk_widget_show_all (combo_box->priv->popup_frame); - gtk_combo_box_list_position (combo_box, &x, &y, &width, &height); - - gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1); - gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y); - - /* popup */ - gtk_widget_show (combo_box->priv->popup_window); - - gtk_widget_grab_focus (combo_box->priv->popup_window); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - - if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view)) - { - gdk_keyboard_grab (combo_box->priv->popup_window->window, - FALSE, GDK_CURRENT_TIME); - gtk_widget_grab_focus (combo_box->priv->tree_view); - } - - gtk_grab_add (combo_box->priv->popup_window); - gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); - - gtk_grab_add (combo_box->priv->tree_view); -} - -/** - * gtk_combo_box_popdown: - * @combo_box: a #GtkComboBox - * - * Hides the menu or dropdown list of @combo_box. - * - * This function is mostly intended for use by accessibility technologies; - * applications should have little use for it. - * - * Since: 2.4 - **/ -void -gtk_combo_box_popdown (GtkComboBox *combo_box) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box))) - return; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget)); - return; - } - - gtk_combo_box_list_remove_grabs (combo_box); - gtk_widget_hide_all (combo_box->priv->popup_window); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - FALSE); -} - -static gint -gtk_combo_box_calc_requested_width (GtkComboBox *combo_box, - GtkTreePath *path) -{ - gint padding; - GtkRequisition req; - - if (combo_box->priv->cell_view) - gtk_widget_style_get (combo_box->priv->cell_view, - "focus-line-width", &padding, - NULL); - else - padding = 0; - - /* add some pixels for good measure */ - padding += BONUS_PADDING; - - if (combo_box->priv->cell_view) - gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), - path, &req); - else - req.width = 0; - - return req.width + padding; -} - -static void -gtk_combo_box_remeasure (GtkComboBox *combo_box) -{ - GtkTreeIter iter; - GtkTreePath *path; - gint padding = 0; - - if (!combo_box->priv->model || - !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter)) - return; - - combo_box->priv->width = 0; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (0, -1); -#else - path = gtk_tree_path_new_first(); -#endif - - if (combo_box->priv->cell_view) - gtk_widget_style_get (combo_box->priv->cell_view, - "focus-line-width", &padding, - NULL); - else - padding = 0; - - /* add some pixels for good measure */ - padding += BONUS_PADDING; - - do - { - GtkRequisition req; - - if (combo_box->priv->cell_view) - gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view), - path, &req); - else - req.width = 0; - - combo_box->priv->width = MAX (combo_box->priv->width, - req.width + padding); - - gtk_tree_path_next (path); - } - while (gtk_tree_model_iter_next (combo_box->priv->model, &iter)); - - gtk_tree_path_free (path); -} - -static void -gtk_combo_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - gint width, height; - GtkRequisition bin_req; - - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - /* common */ - gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req); - gtk_combo_box_remeasure (combo_box); - bin_req.width = MAX (bin_req.width, combo_box->priv->width); - - gtk_combo_box_check_appearance (combo_box); - - if (!combo_box->priv->tree_view) - { - /* menu mode */ - - if (combo_box->priv->cell_view) - { - GtkRequisition button_req, sep_req, arrow_req; - gint border_width, xthickness, ythickness; - - gtk_widget_size_request (combo_box->priv->button, &button_req); - border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; - xthickness = combo_box->priv->button->style->xthickness; - ythickness = combo_box->priv->button->style->ythickness; - - bin_req.width = MAX (bin_req.width, combo_box->priv->width); - - gtk_widget_size_request (combo_box->priv->separator, &sep_req); - gtk_widget_size_request (combo_box->priv->arrow, &arrow_req); - - height = MAX (sep_req.height, arrow_req.height); - height = MAX (height, bin_req.height); - - width = bin_req.width + sep_req.width + arrow_req.width; - - height += border_width + 1 + ythickness * 2 + 4; - width += border_width + 1 + xthickness * 2 + 4; - - requisition->width = width; - requisition->height = height; - } - else - { - GtkRequisition but_req; - - gtk_widget_size_request (combo_box->priv->button, &but_req); - - requisition->width = bin_req.width + but_req.width; - requisition->height = MAX (bin_req.height, but_req.height); - } - } - else - { - /* list mode */ - GtkRequisition button_req, frame_req; - - /* sample + frame */ - *requisition = bin_req; - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req); - requisition->width += 2 * - (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - requisition->height += 2 * - (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); - } - - /* the button */ - gtk_widget_size_request (combo_box->priv->button, &button_req); - - requisition->height = MAX (requisition->height, button_req.height); - requisition->width += button_req.width; - } -} - -static void -gtk_combo_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - GtkAllocation child; - GtkRequisition req; - gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - - widget->allocation = *allocation; - - gtk_combo_box_check_appearance (combo_box); - - if (!combo_box->priv->tree_view) - { - if (combo_box->priv->cell_view) - { - gint border_width, xthickness, ythickness; - gint width; - - /* menu mode */ - gtk_widget_size_allocate (combo_box->priv->button, allocation); - - /* set some things ready */ - border_width = GTK_CONTAINER (combo_box->priv->button)->border_width; - xthickness = combo_box->priv->button->style->xthickness; - ythickness = combo_box->priv->button->style->ythickness; - - child.x = allocation->x + border_width + 1 + xthickness + 2; - child.y = allocation->y + border_width + 1 + ythickness + 2; - - width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4)); - - /* handle the children */ - gtk_widget_size_request (combo_box->priv->arrow, &req); - child.width = req.width; - child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y)); - if (!is_rtl) - child.x += width - req.width; - gtk_widget_size_allocate (combo_box->priv->arrow, &child); - if (is_rtl) - child.x += req.width; - gtk_widget_size_request (combo_box->priv->separator, &req); - child.width = req.width; - if (!is_rtl) - child.x -= req.width; - gtk_widget_size_allocate (combo_box->priv->separator, &child); - - if (is_rtl) - { - child.x += req.width; - child.width = MAX(1, allocation->x + allocation->width - - (border_width + 1 + xthickness + 2) - child.x); - } - else - { - child.width = child.x; - child.x = allocation->x + border_width + 1 + xthickness + 2; - child.width = MAX(1, child.width - child.x); - } - - gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); - } - else - { - gtk_widget_size_request (combo_box->priv->button, &req); - if (is_rtl) - child.x = allocation->x; - else - child.x = allocation->x + allocation->width - req.width; - child.y = allocation->y; - child.width = req.width; - child.height = allocation->height; - gtk_widget_size_allocate (combo_box->priv->button, &child); - - if (is_rtl) - child.x = allocation->x + req.width; - else - child.x = allocation->x; - child.y = allocation->y; - child.width = MAX(1, allocation->width - req.width); - gtk_widget_size_allocate (GTK_BIN (widget)->child, &child); - } - } - else - { - /* list mode */ - - /* button */ - gtk_widget_size_request (combo_box->priv->button, &req); - if (is_rtl) - child.x = allocation->x; - else - child.x = allocation->x + allocation->width - req.width; - child.y = allocation->y; - child.width = req.width; - child.height = allocation->height; - gtk_widget_size_allocate (combo_box->priv->button, &child); - - /* frame */ - if (is_rtl) - child.x = allocation->x + req.width; - else - child.x = allocation->x; - child.y = allocation->y; - child.width = MAX (1, allocation->width - req.width); - child.height = allocation->height; - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child); - - /* the sample */ - child.x += - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness; - child.y += - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness; - child.width -= 2 * ( - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness); - child.width = MAX(1,child.width); - child.height -= 2 * ( - GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width + - GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness); - child.height = MAX(1,child.height); - } - - gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child); - } -} - -static void -gtk_combo_box_unset_model (GtkComboBox *combo_box) -{ - if (combo_box->priv->model) - { - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->inserted_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->deleted_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->reordered_id); - g_signal_handler_disconnect (combo_box->priv->model, - combo_box->priv->changed_id); - } - - /* menu mode */ - if (!combo_box->priv->tree_view) - { - if (combo_box->priv->popup_widget) - gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget), - (GtkCallback)gtk_widget_destroy, NULL); - } - - if (combo_box->priv->model) - { - g_object_unref (G_OBJECT (combo_box->priv->model)); - combo_box->priv->model = NULL; - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); -} - -static void -gtk_combo_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (container); - - if (include_internals) - { - if (combo_box->priv->button) - (* callback) (combo_box->priv->button, callback_data); - if (combo_box->priv->cell_view_frame) - (* callback) (combo_box->priv->cell_view_frame, callback_data); - } - - if (GTK_BIN (container)->child) - (* callback) (GTK_BIN (container)->child, callback_data); -} - -static gboolean -gtk_combo_box_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - if (!combo_box->priv->tree_view) - { - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->button, event); - } - else - { - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->button, event); - - if (combo_box->priv->cell_view_frame) - gtk_container_propagate_expose (GTK_CONTAINER (widget), - combo_box->priv->cell_view_frame, event); - } - - gtk_container_propagate_expose (GTK_CONTAINER (widget), - GTK_BIN (widget)->child, event); - - return FALSE; -} - -static gboolean -gtk_combo_box_scroll_event (GtkWidget *widget, - GdkEventScroll *event) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - gint index; - gint items; - - index = gtk_combo_box_get_active (combo_box); - - if (index != -1) - { - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - - if (event->direction == GDK_SCROLL_UP) - index--; - else - index++; - - gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1)); - } - - return TRUE; -} - -/* - * menu style - */ - -static void -cell_view_sync_cells (GtkComboBox *combo_box, - GtkCellView *cell_view) -{ - GSList *k; - - for (k = combo_box->priv->cells; k; k = k->next) - { - GSList *j; - ComboCellInfo *info = (ComboCellInfo *)k->data; - - if (info->pack == GTK_PACK_START) - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view), - info->cell, info->expand); - else if (info->pack == GTK_PACK_END) - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view), - info->cell, info->expand); - - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view), - info->cell, - info->func, info->func_data, NULL); - - for (j = info->attributes; j; j = j->next->next) - { - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view), - info->cell, - j->data, - GPOINTER_TO_INT (j->next->data)); - } - } -} - -static void -gtk_combo_box_menu_setup (GtkComboBox *combo_box, - gboolean add_children) -{ - GtkWidget *menu; - - if (combo_box->priv->cell_view) - { - combo_box->priv->button = gtk_toggle_button_new (); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box->priv->button, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - - combo_box->priv->box = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->box); - - combo_box->priv->separator = gtk_vseparator_new (); - gtk_container_add (GTK_CONTAINER (combo_box->priv->box), - combo_box->priv->separator); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->box), - combo_box->priv->arrow); - - gtk_widget_show_all (combo_box->priv->button); - } - else - { - combo_box->priv->button = gtk_toggle_button_new (); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->arrow); - gtk_widget_show_all (combo_box->priv->button); - } - - g_signal_connect (combo_box->priv->button, "button_press_event", - G_CALLBACK (gtk_combo_box_menu_button_press), - combo_box); - - /* create our funky menu */ - menu = gtk_menu_new (); - g_signal_connect (menu, "key_press_event", - G_CALLBACK (gtk_combo_box_menu_key_press), combo_box); - gtk_combo_box_set_popup_widget (combo_box, menu); - - /* add items */ - if (add_children) - gtk_combo_box_menu_fill (combo_box); - -} - -static void -gtk_combo_box_menu_fill (GtkComboBox *combo_box) -{ - gint i, items; - GtkWidget *menu; - GtkWidget *tmp; - - if (!combo_box->priv->model) - return; - - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - menu = combo_box->priv->popup_widget; - - for (i = 0; i < items; i++) - { - GtkTreePath *path; -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (i, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", i); - path = gtk_tree_path_new_from_string(buf); -#endif - tmp = gtk_cell_view_menu_item_new_from_model (combo_box->priv->model, - path); - g_signal_connect (tmp, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); - - cell_view_sync_cells (combo_box, - GTK_CELL_VIEW (GTK_BIN (tmp)->child)); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp); - - if (combo_box->priv->wrap_width) - gtk_combo_box_relayout_item (combo_box, i); - - gtk_widget_show (tmp); - - gtk_tree_path_free (path); - } -} - -static void -gtk_combo_box_menu_destroy (GtkComboBox *combo_box) -{ - g_signal_handlers_disconnect_matched (combo_box->priv->button, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_menu_button_press, NULL); - - /* unparent will remove our latest ref */ - gtk_widget_unparent (combo_box->priv->button); - - combo_box->priv->box = NULL; - combo_box->priv->button = NULL; - combo_box->priv->arrow = NULL; - combo_box->priv->separator = NULL; - - /* changing the popup window will unref the menu and the children */ -} - -/* - * grid - */ - -static void -gtk_combo_box_item_get_size (GtkComboBox *combo_box, - gint index_, - gint *cols, - gint *rows) -{ - GtkTreeIter iter; - - gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, NULL, index_); - - if (cols) - { - if (combo_box->priv->col_column == -1) - *cols = 1; - else - gtk_tree_model_get (combo_box->priv->model, &iter, - combo_box->priv->col_column, cols, - -1); - } - - if (rows) - { - if (combo_box->priv->row_column == -1) - *rows = 1; - else - gtk_tree_model_get (combo_box->priv->model, &iter, - combo_box->priv->row_column, rows, - -1); - } -} - -static gboolean -menu_occupied (GtkMenu *menu, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach) -{ - GList *i; - - g_return_val_if_fail (GTK_IS_MENU (menu), TRUE); - g_return_val_if_fail (left_attach < right_attach, TRUE); - g_return_val_if_fail (top_attach < bottom_attach, TRUE); - - for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next) - { - guint l, r, b, t; - gboolean h_intersect = FALSE; - gboolean v_intersect = FALSE; - - gtk_container_child_get (GTK_CONTAINER (menu), i->data, - "left_attach", &l, - "right_attach", &r, - "bottom_attach", &b, - "top_attach", &t, - NULL); - - /* look if this item intersects with the given coordinates */ - h_intersect = left_attach <= l && l <= right_attach; - h_intersect &= left_attach <= r && r <= right_attach; - - v_intersect = top_attach <= t && t <= bottom_attach; - v_intersect &= top_attach <= b && b <= bottom_attach; - - if (h_intersect && v_intersect) - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_relayout_item (GtkComboBox *combo_box, - gint index) -{ - gint current_col = 0, current_row = 0; - gint rows, cols; - GList *list, *nth; - GtkWidget *item, *last; - GtkWidget *menu; - - menu = combo_box->priv->popup_widget; - if (!GTK_IS_MENU_SHELL (menu)) - return; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - nth = g_list_nth (list, index); - item = nth->data; - if (nth->prev) - last = nth->prev->data; - else - last = NULL; - g_list_free (list); - - gtk_combo_box_item_get_size (combo_box, index, &cols, &rows); - - if (combo_box->priv->col_column == -1 && - combo_box->priv->row_column == -1 && - last) - { - gtk_container_child_get (GTK_CONTAINER (menu), - last, - "right_attach", ¤t_col, - "top_attach", ¤t_row, - NULL); - if (current_col + cols > combo_box->priv->wrap_width) - { - current_col = 0; - current_row++; - } - } - else - { - /* look for a good spot */ - while (1) - { - if (current_col + cols > combo_box->priv->wrap_width) - { - current_col = 0; - current_row++; - } - - if (!menu_occupied (GTK_MENU (menu), - current_col, current_col + cols, - current_row, current_row + rows)) - break; - - current_col++; - } - } - - /* set attach props */ - gtk_menu_attach (GTK_MENU (menu), item, - current_col, current_col + cols, - current_row, current_row + rows); -} - -static void -gtk_combo_box_relayout (GtkComboBox *combo_box) -{ - GList *list, *j; - GtkWidget *menu; - - menu = combo_box->priv->popup_widget; - - /* do nothing unless we are in menu style and realized */ - if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu)) - return; - - /* get rid of all children */ - list = gtk_container_get_children (GTK_CONTAINER (menu)); - - for (j = g_list_last (list); j; j = j->prev) - gtk_container_remove (GTK_CONTAINER (menu), j->data); - - g_list_free (list); - - /* and relayout */ - gtk_combo_box_menu_fill (combo_box); -} - -/* callbacks */ -static gboolean -gtk_combo_box_menu_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (! GTK_IS_MENU (combo_box->priv->popup_widget)) - return FALSE; - - if (event->type == GDK_BUTTON_PRESS && event->button == 1) - { - combo_box->priv->popup_in_progress = TRUE; - - gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget), - combo_box->priv->active_item); - - if (combo_box->priv->wrap_width == 0) - { - GtkRequisition requisition; - gint width; - - width = GTK_WIDGET (combo_box)->allocation.width; - gtk_widget_size_request (combo_box->priv->popup_widget, &requisition); - - gtk_widget_set_size_request (combo_box->priv->popup_widget, - MAX (width, requisition.width), -1); - } - - gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget), - NULL, NULL, -#if GTK_CHECK_VERSION(2,2,0) - gtk_combo_box_menu_position, -#else - NULL, -#endif - combo_box, event->button, event->time); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_menu_item_activate (GtkWidget *item, - gpointer user_data) -{ - gint index; - GtkWidget *menu; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - index = g_list_index (GTK_MENU_SHELL (menu)->children, item); - - gtk_combo_box_set_active (combo_box, index); -} - -static void -gtk_combo_box_model_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (combo_box->priv->active_item >= index) - combo_box->priv->active_item++; - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_row_inserted (model, path, iter, user_data); -} - -static void -gtk_combo_box_model_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_row_deleted (model, path, user_data); - - if (index == combo_box->priv->active_item) - { - gint items = gtk_tree_model_iter_n_children (model, NULL); - - if (items == 0) - gtk_combo_box_set_active_internal (combo_box, -1); - else if (index == items) - gtk_combo_box_set_active_internal (combo_box, index - 1); - else - gtk_combo_box_set_active_internal (combo_box, index); - } - else if (combo_box->priv->active_item > index) - combo_box->priv->active_item--; -} - -static void -gtk_combo_box_model_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint items = gtk_tree_model_iter_n_children (model, NULL); - gint i; - - for (i = 0; i < items; i++) - if (new_order[i] == combo_box->priv->active_item) - { - combo_box->priv->active_item = i; - break; - } - - if (!combo_box->priv->tree_view) - gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data); -} - -static void -gtk_combo_box_model_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint index = gtk_tree_path_get_indices (path)[0]; - - if (index == combo_box->priv->active_item && - combo_box->priv->cell_view) - gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view)); - - if (combo_box->priv->tree_view) - gtk_combo_box_list_row_changed (model, path, iter, user_data); - else - gtk_combo_box_menu_row_changed (model, path, iter, user_data); -} - - -static void -gtk_combo_box_menu_row_inserted (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkWidget *menu; - GtkWidget *item; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (!combo_box->priv->popup_widget) - return; - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - item = gtk_cell_view_menu_item_new_from_model (model, path); - g_signal_connect (item, "activate", - G_CALLBACK (gtk_combo_box_menu_item_activate), - combo_box); - - cell_view_sync_cells (combo_box, GTK_CELL_VIEW (GTK_BIN (item)->child)); - - gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, - gtk_tree_path_get_indices (path)[0]); - gtk_widget_show (item); -} - -static void -gtk_combo_box_menu_row_deleted (GtkTreeModel *model, - GtkTreePath *path, - gpointer user_data) -{ - gint index; - GtkWidget *menu; - GtkWidget *item; - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - if (!combo_box->priv->popup_widget) - return; - - index = gtk_tree_path_get_indices (path)[0]; - - menu = combo_box->priv->popup_widget; - g_return_if_fail (GTK_IS_MENU (menu)); - - item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index); - g_return_if_fail (GTK_IS_MENU_ITEM (item)); - - gtk_container_remove (GTK_CONTAINER (menu), item); -} - -static void -gtk_combo_box_menu_rows_reordered (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gint *new_order, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - - gtk_combo_box_relayout (combo_box); -} - -static void -gtk_combo_box_menu_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer user_data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (user_data); - gint width; - - if (!combo_box->priv->popup_widget) - return; - - if (combo_box->priv->wrap_width) - gtk_combo_box_relayout_item (combo_box, - gtk_tree_path_get_indices (path)[0]); - - width = gtk_combo_box_calc_requested_width (combo_box, path); - - if (width > combo_box->priv->width) - { - if (combo_box->priv->cell_view) - { - gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); - gtk_widget_queue_resize (combo_box->priv->cell_view); - } - combo_box->priv->width = width; - } -} - -/* - * list style - */ - -static void -gtk_combo_box_list_setup (GtkComboBox *combo_box) -{ - GSList *i; - GtkTreeSelection *sel; - - combo_box->priv->button = gtk_toggle_button_new (); - gtk_widget_set_parent (combo_box->priv->button, - GTK_BIN (combo_box)->child->parent); - g_signal_connect (combo_box->priv->button, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box); - g_signal_connect (combo_box->priv->button, "toggled", - G_CALLBACK (gtk_combo_box_button_toggled), combo_box); - g_signal_connect_after (combo_box, "key_press_event", - G_CALLBACK (gtk_combo_box_key_press), combo_box); - - combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (combo_box->priv->button), - combo_box->priv->arrow); - combo_box->priv->separator = NULL; - gtk_widget_show_all (combo_box->priv->button); - - if (combo_box->priv->cell_view) - { - combo_box->priv->cell_view_frame = gtk_frame_new (NULL); - gtk_widget_set_parent (combo_box->priv->cell_view_frame, - GTK_BIN (combo_box)->child->parent); - gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame), - GTK_SHADOW_IN); - - gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view), - >K_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]); - - combo_box->priv->box = gtk_event_box_new (); - /* - gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box), - FALSE); - */ - - gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame), - combo_box->priv->box); - - gtk_widget_show_all (combo_box->priv->cell_view_frame); - - g_signal_connect (combo_box->priv->box, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), - combo_box); - } - - combo_box->priv->tree_view = gtk_tree_view_new (); - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); - gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (combo_box->priv->tree_view), - FALSE); - /* - _gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view), - TRUE); - */ - if (combo_box->priv->model) - gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->model); - - g_signal_connect (combo_box->priv->tree_view, "button_press_event", - G_CALLBACK (gtk_combo_box_list_button_pressed), - combo_box); - g_signal_connect (combo_box->priv->tree_view, "button_release_event", - G_CALLBACK (gtk_combo_box_list_button_released), - combo_box); - g_signal_connect (combo_box->priv->tree_view, "key_press_event", - G_CALLBACK (gtk_combo_box_list_key_press), - combo_box); - - combo_box->priv->column = gtk_tree_view_column_new (); - gtk_tree_view_append_column (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->column); - - /* sync up */ - for (i = combo_box->priv->cells; i; i = i->next) - { - GSList *j; - ComboCellInfo *info = (ComboCellInfo *)i->data; - - if (info->pack == GTK_PACK_START) - gtk_tree_view_column_pack_start (combo_box->priv->column, - info->cell, info->expand); - else if (info->pack == GTK_PACK_END) - gtk_tree_view_column_pack_end (combo_box->priv->column, - info->cell, info->expand); - - for (j = info->attributes; j; j = j->next->next) - { - gtk_tree_view_column_add_attribute (combo_box->priv->column, - info->cell, - j->data, - GPOINTER_TO_INT (j->next->data)); - } - } - - if (combo_box->priv->active_item != -1) - { - GtkTreePath *path; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (combo_box->priv->active_item, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", combo_box->priv->active_item); - path = gtk_tree_path_new_from_string(buf); -#endif - if (path) - { - gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), - path, NULL, FALSE); - gtk_tree_path_free (path); - } - } - - /* set sample/popup widgets */ - gtk_combo_box_set_popup_widget (combo_box, combo_box->priv->tree_view); - - gtk_widget_show (combo_box->priv->tree_view); -} - -static void -gtk_combo_box_list_destroy (GtkComboBox *combo_box) -{ - /* disconnect signals */ - g_signal_handlers_disconnect_matched (combo_box->priv->tree_view, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, combo_box); - g_signal_handlers_disconnect_matched (combo_box->priv->button, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_list_button_pressed, - NULL); - if (combo_box->priv->box) - g_signal_handlers_disconnect_matched (combo_box->priv->box, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - gtk_combo_box_list_button_pressed, - NULL); - - /* destroy things (unparent will kill the latest ref from us) - * last unref on button will destroy the arrow - */ - gtk_widget_unparent (combo_box->priv->button); - combo_box->priv->button = NULL; - combo_box->priv->arrow = NULL; - - if (combo_box->priv->cell_view) - { - g_object_set (G_OBJECT (combo_box->priv->cell_view), - "background_set", FALSE, - NULL); - } - - if (combo_box->priv->cell_view_frame) - { - gtk_widget_unparent (combo_box->priv->cell_view_frame); - combo_box->priv->cell_view_frame = NULL; - combo_box->priv->box = NULL; - } - - gtk_widget_destroy (combo_box->priv->tree_view); - - combo_box->priv->tree_view = NULL; - combo_box->priv->popup_widget = NULL; -} - -/* callbacks */ -static void -gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box) -{ - if (combo_box->priv->tree_view && - GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view)) - { - gtk_grab_remove (combo_box->priv->tree_view); - } - - if (combo_box->priv->popup_window && - GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window)) - { - gtk_grab_remove (combo_box->priv->popup_window); - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } -} - -static gboolean -gtk_combo_box_list_button_pressed (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); - - if (ewidget == combo_box->priv->tree_view) - return TRUE; - - if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) || - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) - return FALSE; - - gtk_combo_box_popup (combo_box); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), - TRUE); - - combo_box->priv->popup_in_progress = TRUE; - - return TRUE; -} - -static gboolean -gtk_combo_box_list_button_released (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - gboolean ret; - GtkTreePath *path = NULL; - - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - - gboolean popup_in_progress = FALSE; - - GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event); - - if (combo_box->priv->popup_in_progress) - { - popup_in_progress = TRUE; - combo_box->priv->popup_in_progress = FALSE; - } - - if (ewidget != combo_box->priv->tree_view) - { - if (ewidget == combo_box->priv->button && - !popup_in_progress && - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) - { - gtk_combo_box_popdown (combo_box); - return TRUE; - } - - /* released outside treeview */ - if (ewidget != combo_box->priv->button) - { - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; - } - - /* select something cool */ - ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), - event->x, event->y, - &path, - NULL, NULL, NULL); - - if (!ret) - return TRUE; /* clicked outside window? */ - - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_combo_box_popdown (combo_box); - - gtk_tree_path_free (path); - - return TRUE; -} - -static gboolean -gtk_combo_box_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - gint items = 0; - gint index = gtk_combo_box_get_active (combo_box); - gint new_index; - - if (combo_box->priv->model) - items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL); - - if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) && - state == GDK_MOD1_MASK) - { - gtk_combo_box_popup (combo_box); - - return TRUE; - } - - switch (event->keyval) - { - case GDK_Down: - case GDK_KP_Down: - new_index = index + 1; - break; - case GDK_Up: - case GDK_KP_Up: - new_index = index - 1; - break; - case GDK_Page_Up: - case GDK_KP_Page_Up: - case GDK_Home: - case GDK_KP_Home: - new_index = 0; - break; - case GDK_Page_Down: - case GDK_KP_Page_Down: - case GDK_End: - case GDK_KP_End: - new_index = items - 1; - break; - default: - return FALSE; - } - - if (items > 0) - gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1)); - - return TRUE; -} - -static gboolean -gtk_combo_box_menu_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - - if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && - state == GDK_MOD1_MASK) - { - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; -} - -static gboolean -gtk_combo_box_list_key_press (GtkWidget *widget, - GdkEventKey *event, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - guint state = event->state & gtk_accelerator_get_default_mod_mask (); - - if (event->keyval == GDK_Escape || - ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && - state == GDK_MOD1_MASK)) - { - /* reset active item -- this is incredibly lame and ugly */ - gtk_combo_box_set_active (combo_box, - gtk_combo_box_get_active (combo_box)); - - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter || - event->keyval == GDK_space || event->keyval == GDK_KP_Space) - { - gboolean ret = FALSE; - GtkTreeIter iter; - GtkTreeModel *model = NULL; - - if (combo_box->priv->model) - { - GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)); - - ret = gtk_tree_selection_get_selected (sel, &model, &iter); - } - if (ret) - { - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &iter); - if (path) - { - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_tree_path_free (path); - } - } - - gtk_combo_box_popdown (combo_box); - - return TRUE; - } - - return FALSE; -} - -static void -gtk_combo_box_list_row_changed (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (data); - gint width; - - width = gtk_combo_box_calc_requested_width (combo_box, path); - - if (width > combo_box->priv->width) - { - if (combo_box->priv->cell_view) - { - gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1); - gtk_widget_queue_resize (combo_box->priv->cell_view); - } - combo_box->priv->width = width; - } -} - -/* - * GtkCellLayout implementation - */ -static void -gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - g_object_ref (G_OBJECT (cell)); - gtk_object_sink (GTK_OBJECT (cell)); - - info = g_new0 (ComboCellInfo, 1); - info->cell = cell; - info->expand = expand; - info->pack = GTK_PACK_START; - - combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); - - if (combo_box->priv->cell_view) - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, expand); - - if (combo_box->priv->column) - gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout, - GtkCellRenderer *cell, - gboolean expand) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - g_object_ref (G_OBJECT (cell)); - gtk_object_sink (GTK_OBJECT (cell)); - - info = g_new0 (ComboCellInfo, 1); - info->cell = cell; - info->expand = expand; - info->pack = GTK_PACK_END; - - combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info); - - if (combo_box->priv->cell_view) - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, expand); - - if (combo_box->priv->column) - gtk_tree_view_column_pack_end (combo_box->priv->column, cell, expand); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_clear (GtkCellLayout *layout) -{ - GtkWidget *menu; - GtkComboBox *combo_box; - GSList *i; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - - combo_box = GTK_COMBO_BOX (layout); - - if (combo_box->priv->cell_view) - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view)); - - if (combo_box->priv->column) - gtk_tree_view_column_clear (combo_box->priv->column); - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - - gtk_combo_box_cell_layout_clear_attributes (layout, info->cell); - g_object_unref (G_OBJECT (info->cell)); - g_free (info); - i->data = NULL; - } - g_slist_free (combo_box->priv->cells); - combo_box->priv->cells = NULL; - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (view)); - } - g_list_free (list); - } -} - -static void -gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout, - GtkCellRenderer *cell, - const gchar *attribute, - gint column) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - - info->attributes = g_slist_prepend (info->attributes, - GINT_TO_POINTER (column)); - info->attributes = g_slist_prepend (info->attributes, - g_strdup (attribute)); - - if (combo_box->priv->cell_view) - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, attribute, column); - - if (combo_box->priv->column) - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column), - cell, attribute, column); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell, - attribute, column); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout, - GtkCellRenderer *cell, - GtkCellLayoutDataFunc func, - gpointer func_data, - GDestroyNotify destroy) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - g_return_if_fail (info != NULL); - - if (info->destroy) - { - GDestroyNotify d = info->destroy; - - info->destroy = NULL; - d (info->func_data); - } - - info->func = func; - info->func_data = func_data; - info->destroy = destroy; - - if (combo_box->priv->cell_view) - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell, func, func_data, NULL); - - if (combo_box->priv->column) - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->column), cell, func, func_data, NULL); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell, - func, func_data, NULL); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout, - GtkCellRenderer *cell) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - GSList *list; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - if (info) - { - list = info->attributes; - while (list && list->next) - { - g_free (list->data); - list = list->next->next; - } - g_slist_free (info->attributes); - info->attributes = NULL; - } - - if (combo_box->priv->cell_view) - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell); - - if (combo_box->priv->column) - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->column), cell); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell); - } - g_list_free (list); - } - - gtk_widget_queue_resize (GTK_WIDGET (combo_box)); -} - -static void -gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout, - GtkCellRenderer *cell, - gint position) -{ - ComboCellInfo *info; - GtkComboBox *combo_box; - GtkWidget *menu; - GSList *link; - - g_return_if_fail (GTK_IS_COMBO_BOX (layout)); - g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); - - combo_box = GTK_COMBO_BOX (layout); - - info = gtk_combo_box_get_cell_info (combo_box, cell); - - g_return_if_fail (info != NULL); - g_return_if_fail (position >= 0); - - link = g_slist_find (combo_box->priv->cells, info); - - g_return_if_fail (link != NULL); - - combo_box->priv->cells = g_slist_delete_link (combo_box->priv->cells, link); - combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info, - position); - - if (combo_box->priv->cell_view) - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view), - cell, position); - - if (combo_box->priv->column) - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column), - cell, position); - - menu = combo_box->priv->popup_widget; - if (GTK_IS_MENU (menu)) - { - GList *i, *list; - - list = gtk_container_get_children (GTK_CONTAINER (menu)); - for (i = list; i; i = i->next) - { - GtkCellView *view; - - if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data)) - view = GTK_CELL_VIEW (GTK_BIN (i->data)->child); - else - view = GTK_CELL_VIEW (i->data); - - gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position); - } - g_list_free (list); - } - - gtk_widget_queue_draw (GTK_WIDGET (combo_box)); -} - -/* - * public API - */ - -/** - * gtk_combo_box_new: - * - * Creates a new empty #GtkComboBox. - * - * Return value: A new #GtkComboBox. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new (void) -{ - return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL)); -} - -/** - * gtk_combo_box_new_with_model: - * @model: A #GtkTreeModel. - * - * Creates a new #GtkComboBox with the model initialized to @model. - * - * Return value: A new #GtkComboBox. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new_with_model (GtkTreeModel *model) -{ - GtkComboBox *combo_box; - - g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL); - - combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX, - "model", model, - NULL)); - - return GTK_WIDGET (combo_box); -} - -/** - * gtk_combo_box_set_wrap_width: - * @combo_box: A #GtkComboBox. - * @width: Preferred number of columns. - * - * Sets the wrap width of @combo_box to be @width. The wrap width is basically - * the preferred number of columns when you want to the popup to be layed out - * in a table. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, - gint width) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (width >= 0); - - if (width != combo_box->priv->wrap_width) - { - combo_box->priv->wrap_width = width; - - gtk_combo_box_check_appearance (combo_box); - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "wrap_width"); - } -} - -/** - * gtk_combo_box_set_row_span_column: - * @combo_box: A #GtkComboBox. - * @row_span: A column in the model passed during construction. - * - * Sets the column with row span information for @combo_box to be @row_span. - * The row span column contains integers which indicate how many rows - * an item should span. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, - gint row_span) -{ - gint col; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - col = gtk_tree_model_get_n_columns (combo_box->priv->model); - g_return_if_fail (row_span >= 0 && row_span < col); - - if (row_span != combo_box->priv->row_column) - { - combo_box->priv->row_column = row_span; - - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "row_span_column"); - } -} - -/** - * gtk_combo_box_set_column_span_column: - * @combo_box: A #GtkComboBox. - * @column_span: A column in the model passed during construction. - * - * Sets the column with column span information for @combo_box to be - * @column_span. The column span column contains integers which indicate - * how many columns an item should span. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, - gint column_span) -{ - gint col; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - col = gtk_tree_model_get_n_columns (combo_box->priv->model); - g_return_if_fail (column_span >= 0 && column_span < col); - - if (column_span != combo_box->priv->col_column) - { - combo_box->priv->col_column = column_span; - - gtk_combo_box_relayout (combo_box); - - g_object_notify (G_OBJECT (combo_box), "column_span_column"); - } -} - -/** - * gtk_combo_box_get_active: - * @combo_box: A #GtkComboBox. - * - * Returns the index of the currently active item, or -1 if there's no - * active item. - * - * Return value: An integer which is the index of the currently active item, or - * -1 if there's no active item. - * - * Since: 2.4 - */ -gint -gtk_combo_box_get_active (GtkComboBox *combo_box) -{ - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0); - - return combo_box->priv->active_item; -} - -/** - * gtk_combo_box_set_active: - * @combo_box: A #GtkComboBox. - * @index_: An index in the model passed during construction, or -1 to have - * no active item. - * - * Sets the active item of @combo_box to be the item at @index. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_active (GtkComboBox *combo_box, - gint index_) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - /* -1 means "no item selected" */ - g_return_if_fail (index_ >= -1); - - if (combo_box->priv->active_item == index_) - return; - - gtk_combo_box_set_active_internal (combo_box, index_); -} - -static void -gtk_combo_box_set_active_internal (GtkComboBox *combo_box, - gint index) -{ - GtkTreePath *path; - - combo_box->priv->active_item = index; - - if (index == -1) - { - if (combo_box->priv->tree_view) - gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view))); - else - { - GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); - - if (GTK_IS_MENU (menu)) - gtk_menu_set_active (menu, -1); - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL); - } - else - { -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (index, -1); -#else - char buf[32]; - g_snprintf(buf, sizeof(buf), "%d", index); - path = gtk_tree_path_new_from_string(buf); -#endif - - if (combo_box->priv->tree_view) - gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), path, NULL, FALSE); - else - { - GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget); - - if (GTK_IS_MENU (menu)) - gtk_menu_set_active (GTK_MENU (menu), index); - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), path); - - gtk_tree_path_free (path); - } - - g_signal_emit_by_name (combo_box, "changed", NULL, NULL); -} - - -/** - * gtk_combo_box_get_active_iter: - * @combo_box: A #GtkComboBox - * @iter: The uninitialized #GtkTreeIter. - * - * Sets @iter to point to the current active item, if it exists. - * - * Return value: %TRUE, if @iter was set - * - * Since: 2.4 - **/ -gboolean -gtk_combo_box_get_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter) -{ - GtkTreePath *path; - gint active; - gboolean retval; -#if !GTK_CHECK_VERSION(2,2,0) - char buf[32]; -#endif - - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE); - - active = gtk_combo_box_get_active (combo_box); - if (active < 0) - return FALSE; - -#if GTK_CHECK_VERSION(2,2,0) - path = gtk_tree_path_new_from_indices (active, -1); -#else - g_snprintf(buf, sizeof(buf), "%d", active); - path = gtk_tree_path_new_from_string(buf); -#endif - retval = gtk_tree_model_get_iter (gtk_combo_box_get_model (combo_box), - iter, path); - gtk_tree_path_free (path); - - return retval; -} - -/** - * gtk_combo_box_set_active_iter: - * @combo_box: A #GtkComboBox - * @iter: The #GtkTreeIter. - * - * Sets the current active item to be the one referenced by @iter. - * @iter must correspond to a path of depth one. - * - * Since: 2.4 - **/ -void -gtk_combo_box_set_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter) -{ - GtkTreePath *path; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter); - g_return_if_fail (path != NULL); - g_return_if_fail (gtk_tree_path_get_depth (path) == 1); - - gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]); - gtk_tree_path_free (path); -} - -/** - * gtk_combo_box_set_model: - * @combo_box: A #GtkComboBox. - * @model: A #GtkTreeModel. - * - * Sets the model used by @combo_box to be @model. Will unset a previously set - * model (if applicable). If @model is %NULL, then it will unset the model. - * - * Note that this function does not clear the cell renderers, you have to - * call gtk_combo_box_cell_layout_clear() yourself if you need to set up - * different cell renderers for the new model. - * - * Since: 2.4 - */ -void -gtk_combo_box_set_model (GtkComboBox *combo_box, - GtkTreeModel *model) -{ - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - - if (!model) - { - gtk_combo_box_unset_model (combo_box); - return; - } - - g_return_if_fail (GTK_IS_TREE_MODEL (model)); - - if (model == combo_box->priv->model) - return; - - if (combo_box->priv->model) - gtk_combo_box_unset_model (combo_box); - - combo_box->priv->model = model; - g_object_ref (G_OBJECT (combo_box->priv->model)); - - combo_box->priv->inserted_id = - g_signal_connect (combo_box->priv->model, "row_inserted", - G_CALLBACK (gtk_combo_box_model_row_inserted), - combo_box); - combo_box->priv->deleted_id = - g_signal_connect (combo_box->priv->model, "row_deleted", - G_CALLBACK (gtk_combo_box_model_row_deleted), - combo_box); - combo_box->priv->reordered_id = - g_signal_connect (combo_box->priv->model, "rows_reordered", - G_CALLBACK (gtk_combo_box_model_rows_reordered), - combo_box); - combo_box->priv->changed_id = - g_signal_connect (combo_box->priv->model, "row_changed", - G_CALLBACK (gtk_combo_box_model_row_changed), - combo_box); - - if (combo_box->priv->tree_view) - { - /* list mode */ - gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view), - combo_box->priv->model); - } - else - { - /* menu mode */ - if (combo_box->priv->popup_widget) - gtk_combo_box_menu_fill (combo_box); - - } - - if (combo_box->priv->cell_view) - gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view), - combo_box->priv->model); -} - -/** - * gtk_combo_box_get_model - * @combo_box: A #GtkComboBox. - * - * Returns the #GtkTreeModel which is acting as data source for @combo_box. - * - * Return value: A #GtkTreeModel which was passed during construction. - * - * Since: 2.4 - */ -GtkTreeModel * -gtk_combo_box_get_model (GtkComboBox *combo_box) -{ - g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL); - - return combo_box->priv->model; -} - - -/* convenience API for simple text combos */ - -/** - * gtk_combo_box_new_text: - * - * Convenience function which constructs a new text combo box, which is a - * #GtkComboBox just displaying strings. If you use this function to create - * a text combo box, you should only manipulate its data source with the - * following convenience functions: gtk_combo_box_append_text(), - * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and - * gtk_combo_box_remove_text(). - * - * Return value: A new text combo box. - * - * Since: 2.4 - */ -GtkWidget * -gtk_combo_box_new_text (void) -{ - GtkWidget *combo_box; - GtkCellRenderer *cell; - GtkListStore *store; - - store = gtk_list_store_new (1, G_TYPE_STRING); - combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - g_object_unref (store); - - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell, - "text", 0, - NULL); - - return combo_box; -} - -/** - * gtk_combo_box_append_text: - * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). - * @text: A string. - * - * Appends @string to the list of strings stored in @combo_box. Note that - * you can only use this function with combo boxes constructed with - * gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_append_text (GtkComboBox *combo_box, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_insert_text: - * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text(). - * @position: An index to insert @text. - * @text: A string. - * - * Inserts @string at @position in the list of strings stored in @combo_box. - * Note that you can only use this function with combo boxes constructed - * with gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_insert_text (GtkComboBox *combo_box, - gint position, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (position >= 0); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_insert (store, &iter, position); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_prepend_text: - * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). - * @text: A string. - * - * Prepends @string to the list of strings stored in @combo_box. Note that - * you can only use this function with combo boxes constructed with - * gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_prepend_text (GtkComboBox *combo_box, - const gchar *text) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (text != NULL); - - store = GTK_LIST_STORE (combo_box->priv->model); - - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, 0, text, -1); -} - -/** - * gtk_combo_box_remove_text: - * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text(). - * @position: Index of the item to remove. - * - * Removes the string at @position from @combo_box. Note that you can only use - * this function with combo boxes constructed with gtk_combo_box_new_text(). - * - * Since: 2.4 - */ -void -gtk_combo_box_remove_text (GtkComboBox *combo_box, - gint position) -{ - GtkTreeIter iter; - GtkListStore *store; - - g_return_if_fail (GTK_IS_COMBO_BOX (combo_box)); - g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model)); - g_return_if_fail (position >= 0); - - store = GTK_LIST_STORE (combo_box->priv->model); - - if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, - NULL, position)) - gtk_list_store_remove (store, &iter); -} - -static gboolean -gtk_combo_box_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (widget); - - gtk_widget_grab_focus (combo_box->priv->button); - - return TRUE; -} - -static void -gtk_combo_box_destroy (GtkObject *object) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - - gtk_combo_box_popdown (combo_box); - - combo_box->priv->destroying = 1; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); - combo_box->priv->cell_view = NULL; - - combo_box->priv->destroying = 0; -} - -static void -gtk_combo_box_finalize (GObject *object) -{ - GtkComboBox *combo_box = GTK_COMBO_BOX (object); - GSList *i; - - if (GTK_IS_MENU (combo_box->priv->popup_widget)) - { - gtk_combo_box_menu_destroy (combo_box); - gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget)); - combo_box->priv->popup_widget = NULL; - } - - if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view)) - gtk_combo_box_list_destroy (combo_box); - - if (combo_box->priv->popup_window) - gtk_widget_destroy (combo_box->priv->popup_window); - - gtk_combo_box_unset_model (combo_box); - - for (i = combo_box->priv->cells; i; i = i->next) - { - ComboCellInfo *info = (ComboCellInfo *)i->data; - GSList *list = info->attributes; - - if (info->destroy) - info->destroy (info->func_data); - - while (list && list->next) - { - g_free (list->data); - list = list->next->next; - } - g_slist_free (info->attributes); - - g_object_unref (G_OBJECT (info->cell)); - g_free (info); - } - g_slist_free (combo_box->priv->cells); - - g_free (combo_box->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - -/** - * Code below this point has been pulled in from gtkmenu.c in 2.4.14 - * and is needed to provide gtk_menu_attach() - */ - -typedef struct -{ - gint left_attach; - gint right_attach; - gint top_attach; - gint bottom_attach; - gint effective_left_attach; - gint effective_right_attach; - gint effective_top_attach; - gint effective_bottom_attach; -} AttachInfo; - -#define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key" - -static AttachInfo * -get_attach_info (GtkWidget *child) -{ - GObject *object = G_OBJECT (child); - AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY); - - if (!ai) - { - ai = g_new0 (AttachInfo, 1); - g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free); - } - - return ai; -} - -/** - * gtk_menu_attach: - * @menu: a #GtkMenu. - * @child: a #GtkMenuItem. - * @left_attach: The column number to attach the left side of the item to. - * @right_attach: The column number to attach the right side of the item to. - * @top_attach: The row number to attach the top of the item to. - * @bottom_attach: The row number to attach the bottom of the item to. - * - * Adds a new #GtkMenuItem to a (table) menu. The number of 'cells' that - * an item will occupy is specified by @left_attach, @right_attach, - * @top_attach and @bottom_attach. These each represent the leftmost, - * rightmost, uppermost and lower column and row numbers of the table. - * (Columns and rows are indexed from zero). - * - * Note that this function is not related to gtk_menu_detach(). - * - * Since: 2.4 - **/ -static void -gtk_menu_attach (GtkMenu *menu, - GtkWidget *child, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach) -{ - GtkMenuShell *menu_shell; - - g_return_if_fail (GTK_IS_MENU (menu)); - g_return_if_fail (GTK_IS_MENU_ITEM (child)); - g_return_if_fail (child->parent == NULL || - child->parent == GTK_WIDGET (menu)); - g_return_if_fail (left_attach < right_attach); - g_return_if_fail (top_attach < bottom_attach); - - menu_shell = GTK_MENU_SHELL (menu); - - if (!child->parent) - { - AttachInfo *ai = get_attach_info (child); - - ai->left_attach = left_attach; - ai->right_attach = right_attach; - ai->top_attach = top_attach; - ai->bottom_attach = bottom_attach; - - menu_shell->children = g_list_append (menu_shell->children, child); - - gtk_widget_set_parent (child, GTK_WIDGET (menu)); - - /* - menu_queue_resize (menu); - */ - } - else - { - gtk_container_child_set (GTK_CONTAINER (child->parent), child, - "left_attach", left_attach, - "right_attach", right_attach, - "top_attach", top_attach, - "bottom_attach", bottom_attach, - NULL); - } -} -#endif /* Gtk 2.4 */ - -gchar * -gtk_combo_box_get_active_text (GtkComboBox *combo_box) -{ - GtkTreeIter iter; - gchar *text = NULL; - - /* g_return_val_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model), NULL); */ - - if (gtk_combo_box_get_active_iter (combo_box, &iter)) - gtk_tree_model_get (gtk_combo_box_get_model(combo_box), &iter, - 0, &text, -1); - return text; -} - -#endif
--- a/pidgin/pidgincombobox.h Sun Aug 23 02:11:21 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* gtkcombobox.h - * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02111-1301, USA. - */ - -#ifndef __PIDGIN_COMBO_BOX_H__ -#define __PIDGIN_COMBO_BOX_H__ - -#ifndef __GTK_COMBO_BOX_H__ -#define __GTK_COMBO_BOX_H__ - -#include <gtk/gtkbin.h> -#include <gtk/gtktreemodel.h> -#include <gtk/gtktreeview.h> - -G_BEGIN_DECLS - -#define GTK_TYPE_COMBO_BOX (gtk_combo_box_get_type ()) -#define GTK_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO_BOX, GtkComboBox)) -#define GTK_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) -#define GTK_IS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO_BOX)) -#define GTK_IS_COMBO_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_TYPE_COMBO_BOX)) -#define GTK_COMBO_BOX_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_TYPE_COMBO_BOX, GtkComboBoxClass)) - -typedef struct _GtkComboBox GtkComboBox; -typedef struct _GtkComboBoxClass GtkComboBoxClass; -typedef struct _GtkComboBoxPrivate GtkComboBoxPrivate; - -struct _GtkComboBox -{ - GtkBin parent_instance; - - /*< private >*/ - GtkComboBoxPrivate *priv; -}; - -struct _GtkComboBoxClass -{ - GtkBinClass parent_class; - - /* signals */ - void (* changed) (GtkComboBox *combo_box); - - /* Padding for future expansion */ - void (*_gtk_reserved0) (void); - void (*_gtk_reserved1) (void); - void (*_gtk_reserved2) (void); - void (*_gtk_reserved3) (void); -}; - - -/* construction */ -GType gtk_combo_box_get_type (void); -GtkWidget *gtk_combo_box_new (void); -GtkWidget *gtk_combo_box_new_with_model (GtkTreeModel *model); - -/* grids */ -void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, - gint width); -void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, - gint row_span); -void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, - gint column_span); - -/* get/set active item */ -gint gtk_combo_box_get_active (GtkComboBox *combo_box); -void gtk_combo_box_set_active (GtkComboBox *combo_box, - gint index_); -gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter); -void gtk_combo_box_set_active_iter (GtkComboBox *combo_box, - GtkTreeIter *iter); - -/* getters and setters */ -void gtk_combo_box_set_model (GtkComboBox *combo_box, - GtkTreeModel *model); -GtkTreeModel *gtk_combo_box_get_model (GtkComboBox *combo_box); - -/* convenience -- text */ -GtkWidget *gtk_combo_box_new_text (void); -void gtk_combo_box_append_text (GtkComboBox *combo_box, - const gchar *text); -void gtk_combo_box_insert_text (GtkComboBox *combo_box, - gint position, - const gchar *text); -void gtk_combo_box_prepend_text (GtkComboBox *combo_box, - const gchar *text); -void gtk_combo_box_remove_text (GtkComboBox *combo_box, - gint position); -/* programmatic control */ -void gtk_combo_box_popup (GtkComboBox *combo_box); -void gtk_combo_box_popdown (GtkComboBox *combo_box); - -G_END_DECLS - -#endif /* __GTK_COMBO_BOX_H__ */ - -gchar *gtk_combo_box_get_active_text (GtkComboBox *combo_box); - -#endif /* __PIDGIN_COMBOX_BOX_H__ */
--- a/pidgin/pidginstock.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/pidginstock.c Sun Aug 23 02:37:12 2009 +0000 @@ -239,7 +239,6 @@ find_file_common(const char *name) { gchar *filename; -#if GLIB_CHECK_VERSION(2,6,0) const gchar *userdir; const gchar * const *sysdirs; @@ -256,7 +255,6 @@ return filename; g_free(filename); } -#endif filename = g_build_filename(DATADIR, name, NULL); if (g_file_test(filename, G_FILE_TEST_EXISTS)) return filename;
--- a/pidgin/win32/gtkdocklet-win32.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/win32/gtkdocklet-win32.c Sun Aug 23 02:37:12 2009 +0000 @@ -585,12 +585,7 @@ G_CALLBACK(dummy_button_cb), NULL); image = gtk_image_new(); -#if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink(image); -#else - g_object_ref(image); - gtk_object_sink(GTK_OBJECT(image)); -#endif osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo);
--- a/pidgin/win32/untar.c Sun Aug 23 02:11:21 2009 +0000 +++ b/pidgin/win32/untar.c Sun Aug 23 02:37:12 2009 +0000 @@ -80,14 +80,7 @@ #include "untar.h" #include <glib.h> -#if GLIB_CHECK_VERSION(2,6,0) -# include <glib/gstdio.h> -#else -#define mkdir(a,b) _mkdir((a)) -#define g_mkdir mkdir -#define g_fopen fopen -#define g_unlink unlink -#endif +#include <glib/gstdio.h> #define untar_error( error, args... ) purple_debug(PURPLE_DEBUG_ERROR, "untar", error, ## args ) #define untar_warning( warning, args... ) purple_debug(PURPLE_DEBUG_WARNING, "untar", warning, ## args )