annotate src/gtkcombobox.c @ 12272:3ef381cdc47e

[gaim-migrate @ 14574] This should fix idle time reporting for all accounts. Previously it would only work for one account because I'm dumb. We're also doing one idleness check every 5 seconds instead of checking for each account every 20 seconds. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 30 Nov 2005 06:03:49 +0000
parents 8cb75ba77f9d
children 1ee0a397157f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1 /* gtkcombobox.c
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2 * Copyright (C) 2002, 2003 Kristian Rietveld <kris@gtk.org>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
5 * modify it under the terms of the GNU Library General Public
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
8 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
12 * Library General Public License for more details.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
13 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
14 * You should have received a copy of the GNU Library General Public
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
15 * License along with this library; if not, write to the
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
17 * Boston, MA 02111-1307, USA.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
18 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
19
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
20 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
21 #include <config.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
22 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
23 #include <gtk/gtkversion.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
24 #if !GTK_CHECK_VERSION(2,4,0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
25 #include "gtkcombobox.h"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
26
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
27 #include <gtk/gtkarrow.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
28 #include <gtk/gtkbindings.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
29 #include "gtkcelllayout.h"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
30 #include <gtk/gtkcellrenderertext.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
31 #include "gtkcellview.h"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
32 #include "gtkcellviewmenuitem.h"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
33 #include <gtk/gtkeventbox.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
34 #include <gtk/gtkframe.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
35 #include <gtk/gtkhbox.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
36 #include <gtk/gtkliststore.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
37 #include <gtk/gtkmain.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
38 #include <gtk/gtkmenu.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
39 #include <gtk/gtktogglebutton.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
40 #include <gtk/gtktreeselection.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
41 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
42 #include <gtk/gtktreeprivate.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
43 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
44 #include <gtk/gtkvseparator.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
45 #include <gtk/gtkwindow.h>
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
46 #include <gtk/gtkversion.h>
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
47
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
48 #include <gdk/gdkkeysyms.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
49
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
50 #include <gobject/gvaluecollector.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
51
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
52 #include <string.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
53 #include <stdarg.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
54
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
55 #ifdef ENABLE_NLS
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
56 # include <libintl.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
57 # define _(x) gettext(x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
58 # ifdef gettext_noop
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
59 # define N_(String) gettext_noop (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
60 # else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
61 # define N_(String) (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
62 # endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
63 #else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
64 # define N_(String) (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
65 # define _(x) (x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
66 #endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
67
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
68 /* WELCOME, to THE house of evil code */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
69
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
70 typedef struct _ComboCellInfo ComboCellInfo;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
71 struct _ComboCellInfo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
72 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
73 GtkCellRenderer *cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
74 GSList *attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
75
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
76 GtkCellLayoutDataFunc func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
77 gpointer func_data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
78 GDestroyNotify destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
79
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
80 guint expand : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
81 guint pack : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
82 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
83
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
84 struct _GtkComboBoxPrivate
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
85 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
86 GtkTreeModel *model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
87
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
88 gint col_column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
89 gint row_column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
90
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
91 gint wrap_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
92
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
93 gint active_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
94
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
95 GtkWidget *tree_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
96 GtkTreeViewColumn *column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
97
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
98 GtkWidget *cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
99 GtkWidget *cell_view_frame;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
100
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
101 GtkWidget *button;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
102 GtkWidget *box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
103 GtkWidget *arrow;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
104 GtkWidget *separator;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
105
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
106 GtkWidget *popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
107 GtkWidget *popup_window;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
108 GtkWidget *popup_frame;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
109
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
110 guint inserted_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
111 guint deleted_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
112 guint reordered_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
113 guint changed_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
114
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
115 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
116 GSList *cells;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
117
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
118 guint popup_in_progress : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
119 guint destroying : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
120 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
121
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
122 /* While debugging this evil code, I have learned that
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
123 * there are actually 4 modes to this widget, which can
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
124 * be characterized as follows
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
125 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
126 * 1) menu mode, no child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
127 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
128 * tree_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
129 * cell_view -> GtkCellView, regular child
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
130 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
131 * button -> GtkToggleButton set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
132 * box -> child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
133 * arrow -> child of box
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
134 * separator -> child of box
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
135 * popup_widget -> GtkMenu
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
136 * popup_window -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
137 * popup_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
138 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
139 * 2) menu mode, child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
140 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
141 * tree_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
142 * cell_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
143 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
144 * button -> GtkToggleButton set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
145 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
146 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
147 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
148 * popup_widget -> GtkMenu
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
149 * popup_window -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
150 * popup_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
151 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
152 * 3) list mode, no child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
153 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
154 * tree_view -> GtkTreeView, child of popup_frame
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
155 * cell_view -> GtkCellView, regular child
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
156 * cell_view_frame -> GtkFrame, set parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
157 * button -> GtkToggleButton, set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
158 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
159 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
160 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
161 * popup_widget -> tree_view
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
162 * popup_window -> GtkWindow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
163 * popup_frame -> GtkFrame, child of popup_window
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
164 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
165 * 4) list mode, child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
166 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
167 * tree_view -> GtkTreeView, child of popup_frame
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
168 * cell_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
169 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
170 * button -> GtkToggleButton, set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
171 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
172 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
173 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
174 * popup_widget -> tree_view
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
175 * popup_window -> GtkWindow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
176 * popup_frame -> GtkFrame, child of popup_window
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
177 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
178 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
179
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
180 enum {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
181 CHANGED,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
182 LAST_SIGNAL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
183 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
184
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
185 enum {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
186 PROP_0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
187 PROP_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
188 PROP_WRAP_WIDTH,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
189 PROP_ROW_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
190 PROP_COLUMN_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
191 PROP_ACTIVE
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
192 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
193
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
194 static GtkBinClass *parent_class = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
195 static guint combo_box_signals[LAST_SIGNAL] = {0,};
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
196
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
197 #define BONUS_PADDING 4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
198
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
199
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
200 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
201 static void gtk_combo_box_class_init (GtkComboBoxClass *klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
202 static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
203 static void gtk_combo_box_init (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
204 static void gtk_combo_box_finalize (GObject *object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
205 static void gtk_combo_box_destroy (GtkObject *object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
206
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
207 static void gtk_combo_box_set_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
208 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
209 const GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
210 GParamSpec *spec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
211 static void gtk_combo_box_get_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
212 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
213 GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
214 GParamSpec *spec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
215
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
216 static void gtk_combo_box_state_changed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
217 GtkStateType previous);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
218 static void gtk_combo_box_style_set (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
219 GtkStyle *previous);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
220 static void gtk_combo_box_button_toggled (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
221 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
222 static void gtk_combo_box_add (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
223 GtkWidget *widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
224 static void gtk_combo_box_remove (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
225 GtkWidget *widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
226
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
227 static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
228 GtkCellRenderer *cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
229
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
230 static void gtk_combo_box_menu_show (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
231 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
232 static void gtk_combo_box_menu_hide (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
233 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
234
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
235 static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
236 GtkWidget *popup);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
237 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
238 static void gtk_combo_box_menu_position_below (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
239 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
240 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
241 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
242 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
243 static void gtk_combo_box_menu_position_over (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
244 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
245 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
246 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
247 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
248 static void gtk_combo_box_menu_position (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
249 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
250 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
251 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
252 gpointer user_data);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
253 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
254
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
255 static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
256 GtkTreePath *path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
257 static void gtk_combo_box_remeasure (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
258
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
259 static void gtk_combo_box_unset_model (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
260
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
261 static void gtk_combo_box_size_request (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
262 GtkRequisition *requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
263 static void gtk_combo_box_size_allocate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
264 GtkAllocation *allocation);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
265 static void gtk_combo_box_forall (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
266 gboolean include_internals,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
267 GtkCallback callback,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
268 gpointer callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
269 static gboolean gtk_combo_box_expose_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
270 GdkEventExpose *event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
271 static gboolean gtk_combo_box_scroll_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
272 GdkEventScroll *event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
273 static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
274 gint index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
275 static gboolean gtk_combo_box_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
276 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
277 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
278
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
279 /* listening to the model */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
280 static void gtk_combo_box_model_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
281 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
282 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
283 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
284 static void gtk_combo_box_model_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
285 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
286 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
287 static void gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
288 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
289 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
290 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
291 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
292 static void gtk_combo_box_model_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
293 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
294 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
295 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
296
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
297 /* list */
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
298 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
299 static void gtk_combo_box_list_position (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
300 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
301 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
302 gint *width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
303 gint *height);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
304 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
305 static void gtk_combo_box_list_setup (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
306 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
307
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
308 static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
309
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
310 static gboolean gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
311 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
312 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
313 static gboolean gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
314 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
315 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
316 static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
317 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
318 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
319
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
320 static void gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
321 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
322 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
323 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
324
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
325 /* menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
326 static void gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
327 gboolean add_children);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
328 static void gtk_combo_box_menu_fill (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
329 static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
330
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
331 static void gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
332 gint index,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
333 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
334 gint *rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
335 static void gtk_combo_box_relayout_item (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
336 gint index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
337 static void gtk_combo_box_relayout (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
338
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
339 static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
340 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
341 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
342 static void gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
343 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
344 static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
345 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
346 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
347 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
348 static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
349 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
350 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
351 static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
352 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
353 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
354 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
355 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
356 static void gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
357 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
358 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
359 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
360 static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
361 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
362 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
363
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
364 /* cell layout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
365 static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
366 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
367 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
368 static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
369 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
370 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
371 static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
372 static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
373 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
374 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
375 gint column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
376 static void gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
377 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
378 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
379 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
380 GDestroyNotify destroy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
381 static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
382 GtkCellRenderer *cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
383 static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
384 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
385 gint position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
386 static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
387 gboolean group_cycling);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
388
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
389 static void cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
390 GtkCellView *cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
391
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
392 #if !GTK_CHECK_VERSION(2,4,0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
393 static void gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
394 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
395 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
396 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
397 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
398 guint bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
399 #endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
400
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
401 GType
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
402 gtk_combo_box_get_type (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
403 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
404 static GType combo_box_type = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
405
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
406 if (!combo_box_type)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
407 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
408 static const GTypeInfo combo_box_info =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
409 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
410 sizeof (GtkComboBoxClass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
411 NULL, /* base_init */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
412 NULL, /* base_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
413 (GClassInitFunc) gtk_combo_box_class_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
414 NULL, /* class_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
415 NULL, /* class_data */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
416 sizeof (GtkComboBox),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
417 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
418 (GInstanceInitFunc) gtk_combo_box_init
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
419 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
420
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
421 static const GInterfaceInfo cell_layout_info =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
422 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
423 (GInterfaceInitFunc) gtk_combo_box_cell_layout_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
424 NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
425 NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
426 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
427
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
428 combo_box_type = g_type_register_static (GTK_TYPE_BIN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
429 "GaimGtkComboBox",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
430 &combo_box_info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
431 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
432
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
433 g_type_add_interface_static (combo_box_type,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
434 GTK_TYPE_CELL_LAYOUT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
435 &cell_layout_info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
436 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
437
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
438 return combo_box_type;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
439 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
440
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
441 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
442 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
443 gtk_combo_box_class_init (GtkComboBoxClass *klass)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
444 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
445 GObjectClass *object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
446 GtkBindingSet *binding_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
447 GtkObjectClass *gtk_object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
448 GtkContainerClass *container_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
449 GtkWidgetClass *widget_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
450
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
451 binding_set = gtk_binding_set_by_class (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
452
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
453 container_class = (GtkContainerClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
454 container_class->forall = gtk_combo_box_forall;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
455 container_class->add = gtk_combo_box_add;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
456 container_class->remove = gtk_combo_box_remove;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
457
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
458 widget_class = (GtkWidgetClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
459 widget_class->size_allocate = gtk_combo_box_size_allocate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
460 widget_class->size_request = gtk_combo_box_size_request;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
461 widget_class->expose_event = gtk_combo_box_expose_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
462 widget_class->scroll_event = gtk_combo_box_scroll_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
463 widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
464 widget_class->style_set = gtk_combo_box_style_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
465 widget_class->state_changed = gtk_combo_box_state_changed;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
466
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
467 gtk_object_class = (GtkObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
468 gtk_object_class->destroy = gtk_combo_box_destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
469
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
470 object_class = (GObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
471 object_class->finalize = gtk_combo_box_finalize;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
472 object_class->set_property = gtk_combo_box_set_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
473 object_class->get_property = gtk_combo_box_get_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
474
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
475 parent_class = g_type_class_peek_parent (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
476
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
477 /* signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
478 combo_box_signals[CHANGED] =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
479 g_signal_new ("changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
480 G_OBJECT_CLASS_TYPE (klass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
481 G_SIGNAL_RUN_LAST,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
482 G_STRUCT_OFFSET (GtkComboBoxClass, changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
483 NULL, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
484 g_cclosure_marshal_VOID__VOID,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
485 G_TYPE_NONE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
486
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
487 /* properties */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
488 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
489 PROP_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
490 g_param_spec_object ("model",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
491 _("ComboBox model"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
492 _("The model for the combo box"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
493 GTK_TYPE_TREE_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
494 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
495
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
496 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
497 PROP_WRAP_WIDTH,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
498 g_param_spec_int ("wrap_width",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
499 _("Wrap width"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
500 _("Wrap width for layouting the items in a grid"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
501 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
502 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
503 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
504 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
505
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
506 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
507 PROP_ROW_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
508 g_param_spec_int ("row_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
509 _("Row span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
510 _("TreeModel column containing the row span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
511 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
512 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
513 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
514 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
515
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
516 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
517 PROP_COLUMN_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
518 g_param_spec_int ("column_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
519 _("Column span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
520
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
521 _("TreeModel column containing the column span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
522 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
523 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
524 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
525 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
526
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
527 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
528 PROP_ACTIVE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
529 g_param_spec_int ("active",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
530 _("Active item"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
531 _("The item which is currently active"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
532 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
533 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
534 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
535 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
536
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
537 gtk_widget_class_install_style_property (widget_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
538 g_param_spec_boolean ("appears-as-list",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
539 _("Appears as list"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
540 _("Whether combobox dropdowns should look like lists rather than menus"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
541 FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
542 G_PARAM_READABLE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
543 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
544
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
545 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
546 gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
547 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
548 iface->pack_start = gtk_combo_box_cell_layout_pack_start;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
549 iface->pack_end = gtk_combo_box_cell_layout_pack_end;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
550 iface->clear = gtk_combo_box_cell_layout_clear;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
551 iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
552 iface->set_cell_data_func = gtk_combo_box_cell_layout_set_cell_data_func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
553 iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
554 iface->reorder = gtk_combo_box_cell_layout_reorder;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
555 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
556
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
557 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
558 gtk_combo_box_init (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
559 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
560 combo_box->priv = g_new0(GtkComboBoxPrivate,1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
562 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
563 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
564 GTK_BIN (combo_box)->child = combo_box->priv->cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
565 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
566
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
567 combo_box->priv->width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
568 combo_box->priv->wrap_width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
569
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
570 combo_box->priv->active_item = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
571 combo_box->priv->col_column = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
572 combo_box->priv->row_column = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
573 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
574
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
575 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
576 gtk_combo_box_set_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
577 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
578 const GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
579 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
580 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
581 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
582
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
583 switch (prop_id)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
584 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
585 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
586 gtk_combo_box_set_model (combo_box, g_value_get_object (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
587 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
588
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
589 case PROP_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
590 gtk_combo_box_set_wrap_width (combo_box, g_value_get_int (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
591 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
592
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
593 case PROP_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
594 gtk_combo_box_set_row_span_column (combo_box, g_value_get_int (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
595 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
596
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
597 case PROP_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
598 gtk_combo_box_set_column_span_column (combo_box, g_value_get_int (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
599 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
600
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
601 case PROP_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
602 gtk_combo_box_set_active (combo_box, g_value_get_int (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
603 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
604
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
605 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
606 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
607 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
608 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
609
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
610 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
611 gtk_combo_box_get_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
612 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
613 GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
614 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
615 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
616 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
617
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
618 switch (prop_id)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
619 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
620 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
621 g_value_set_object (value, combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
622 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
623
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
624 case PROP_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
625 g_value_set_int (value, combo_box->priv->wrap_width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
626 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
627
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
628 case PROP_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
629 g_value_set_int (value, combo_box->priv->row_column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
630 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
631
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
632 case PROP_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
633 g_value_set_int (value, combo_box->priv->col_column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
634 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
635
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
636 case PROP_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
637 g_value_set_int (value, gtk_combo_box_get_active (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
638 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
639
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
640 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
641 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
642 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
643 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
644 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
645
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
646 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
647 gtk_combo_box_state_changed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
648 GtkStateType previous)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
649 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
650 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
651
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
652 if (GTK_WIDGET_REALIZED (widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
653 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
654 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
655 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
656 &widget->style->base[GTK_WIDGET_STATE (widget)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
657 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
658
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
659 gtk_widget_queue_draw (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
660 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
661
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
662 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
663 gtk_combo_box_check_appearance (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
664 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
665 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
666
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
667 /* if wrap_width > 0, then we are in grid-mode and forced to use
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
668 * unix style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
669 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
670 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
671 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
672 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
673 gtk_widget_style_get (GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
674 "appears-as-list", &appears_as_list,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
675 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
676
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
677 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
678 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
679 /* Destroy all the menu mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
680 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
681 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
682
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
683 /* Create the list mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
684 if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
685 gtk_combo_box_list_setup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
686 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
687 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
688 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
689 /* Destroy all the list mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
690 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
691 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
692
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
693 /* Create the menu mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
694 if (!GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
695 gtk_combo_box_menu_setup (combo_box, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
696 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
697 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
698
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
699 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
700 gtk_combo_box_style_set (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
701 GtkStyle *previous)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
702 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
703 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
704
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
705 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
706
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
707 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
708 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
709 &widget->style->base[GTK_WIDGET_STATE (widget)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
710 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
711
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
712 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
713 gtk_combo_box_button_toggled (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
714 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
715 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
716 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
717
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
718 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
719 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
720 if (!combo_box->priv->popup_in_progress)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
721 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
722 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
723 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
724 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
725 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
726
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
727 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
728 gtk_combo_box_add (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
729 GtkWidget *widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
730 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
731 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
732
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
733 if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
734 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
735 gtk_widget_unparent (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
736 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
737 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
738 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
739
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
740 gtk_widget_set_parent (widget, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
741 GTK_BIN (container)->child = widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
742
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
743 if (combo_box->priv->cell_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
744 widget != combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
745 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
746 /* since the cell_view was unparented, it's gone now */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
747 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
748
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
749 if (!combo_box->priv->tree_view && combo_box->priv->separator)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
750 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
751 gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
752 combo_box->priv->separator);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
753 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
754
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
755 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
756 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
757 else if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
758 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
759 gtk_widget_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
760 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
761 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
762 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
763 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
764
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
765 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
766 gtk_combo_box_remove (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
767 GtkWidget *widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
768 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
769 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
770 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
771
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
772 gtk_widget_unparent (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
773 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
774
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
775 if (combo_box->priv->destroying)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
776 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
777
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
778 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
779
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
780 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
781 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
782 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
783 appears_as_list = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
784
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
785 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
786 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
787 else if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
788 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
789 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
790 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
791 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
792 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
793
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
794 if (!combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
795 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
796 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
797 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
798 GTK_BIN (container)->child = combo_box->priv->cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
799
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
800 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
801 gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
802 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
803 cell_view_sync_cells (combo_box, GTK_CELL_VIEW (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
804 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
805
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
806
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
807 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
808 gtk_combo_box_list_setup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
809 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
810 gtk_combo_box_menu_setup (combo_box, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
811
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
812 gtk_combo_box_set_active_internal (combo_box, combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
813 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
814
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
815 static ComboCellInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
816 gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
817 GtkCellRenderer *cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
818 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
819 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
820
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
821 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
822 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
823 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
824
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
825 if (info && info->cell == cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
826 return info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
827 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
828
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
829 return NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
830 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
831
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
832 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
833 gtk_combo_box_menu_show (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
834 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
835 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
836 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
837
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
838 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
839 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
840 combo_box->priv->popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
841 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
842
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
843 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
844 gtk_combo_box_menu_hide (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
845 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
846 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
847 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
848
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
849 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
850 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
851 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
852
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
853 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
854 gtk_combo_box_detacher (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
855 GtkMenu *menu)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
856 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
857 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
858
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
859 g_return_if_fail (GTK_IS_COMBO_BOX (widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
860
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
861 combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
862 g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
863
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
864 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
865 gtk_combo_box_menu_show,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
866 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
867 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
868 gtk_combo_box_menu_hide,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
869 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
870
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
871 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
872 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
873
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
874 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
875 gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
876 GtkWidget *popup)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
877 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
878 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
879 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
880 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
881 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
882 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
883 else if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
884 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
885 gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
886 combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
887 g_object_unref (G_OBJECT (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
888 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
889 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
890
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
891 if (GTK_IS_MENU (popup))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
892 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
893 if (combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
894 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
895 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
896 combo_box->priv->popup_window = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
897 combo_box->priv->popup_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
898 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
899
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
900 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
901
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
902 g_signal_connect (popup, "show",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
903 G_CALLBACK (gtk_combo_box_menu_show), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
904 g_signal_connect (popup, "hide",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
905 G_CALLBACK (gtk_combo_box_menu_hide), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
906
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
907 gtk_menu_attach_to_widget (GTK_MENU (popup),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
908 GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
909 gtk_combo_box_detacher);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
910 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
911 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
912 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
913 if (!combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
914 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
915 combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
916 gtk_window_set_resizable (GTK_WINDOW (combo_box->priv->popup_window), FALSE);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
917 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
918 gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
919 gtk_widget_get_screen (GTK_WIDGET (combo_box)));
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
920 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
921
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
922 combo_box->priv->popup_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
923 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
924 GTK_SHADOW_ETCHED_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
925 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
926 combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
927
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
928 gtk_widget_show (combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
929 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
930
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
931 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
932 popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
933 gtk_widget_show (popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
934 g_object_ref (G_OBJECT (popup));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
935 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
936 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
937 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
938
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
939 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
940 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
941 gtk_combo_box_menu_position_below (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
942 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
943 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
944 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
945 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
946 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
947 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
948 gint sx, sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
949 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
950 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
951 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
952 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
953 GdkRectangle monitor;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
954
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
955 /* FIXME: is using the size request here broken? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
956 child = GTK_BIN (combo_box)->child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
957
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
958 gdk_window_get_origin (child->window, &sx, &sy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
959
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
960 if (GTK_WIDGET_NO_WINDOW (child))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
961 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
962 sx += child->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
963 sy += child->allocation.y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
964 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
965
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
966 gtk_widget_size_request (GTK_WIDGET (menu), &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
967
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
968 if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
969 *x = sx;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
970 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
971 *x = sx + child->allocation.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
972 *y = sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
973
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
974 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
975 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
976 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
977 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
978
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
979 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
980 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
981 else if (*x + req.width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
982 *x = monitor.x + monitor.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
983
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
984 if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
985 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
986 else if (*y - monitor.y >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
987 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
988 else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
989 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
990 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
991 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
992
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
993 *push_in = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
994 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
995
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
996 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
997 gtk_combo_box_menu_position_over (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
998 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
999 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1000 gboolean *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1001 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1002 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1003 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1004 GtkWidget *active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1005 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1006 GtkWidget *widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1007 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1008 GList *children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1009 gint screen_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1010 gint menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1011 gint menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1012 gint menu_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1013
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1014 g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1015
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1016 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1017 widget = GTK_WIDGET (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1018
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1019 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1020 menu_width = requisition.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1021
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1022 active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1023 gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1024
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1025 menu_xpos += widget->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1026 menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1027
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1028 if (active != NULL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1029 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1030 gtk_widget_get_child_requisition (active, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1031 menu_ypos -= requisition.height / 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1032 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1033
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1034 children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1035 while (children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1036 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1037 child = children->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1038
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1039 if (active == child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1040 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1041
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1042 if (GTK_WIDGET_VISIBLE (child))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1043 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1044 gtk_widget_get_child_requisition (child, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1045 menu_ypos -= requisition.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1046 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1047
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1048 children = children->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1049 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1050
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1051 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1052 menu_xpos = menu_xpos + widget->allocation.width - menu_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1053
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1054 /* Clamp the position on screen */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1055 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1056
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1057 if (menu_xpos < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1058 menu_xpos = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1059 else if ((menu_xpos + menu_width) > screen_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1060 menu_xpos -= ((menu_xpos + menu_width) - screen_width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1061
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1062 *x = menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1063 *y = menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1064
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1065 *push_in = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1066 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1067
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1068 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1069 gtk_combo_box_menu_position (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1070 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1071 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1072 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1073 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1074 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1075 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1076 GtkWidget *menu_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1077
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1078 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1079
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1080 if (combo_box->priv->wrap_width > 0 || combo_box->priv->cell_view == NULL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1081 gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1082 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1083 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1084 menu_item = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1085 if (menu_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1086 gtk_menu_shell_select_item (GTK_MENU_SHELL (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1087 menu_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1088
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1089 gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1090 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1091
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1092 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1093
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1094 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1095 gtk_combo_box_list_position (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1096 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1097 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1098 gint *width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1099 gint *height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1100 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1101 GtkWidget *sample;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1102 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1103 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1104 GdkRectangle monitor;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1105 GtkRequisition popup_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1106
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1107 sample = GTK_BIN (combo_box)->child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1108
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1109 *width = sample->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1110 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1111 *height = popup_req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1112
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1113 gdk_window_get_origin (sample->window, x, y);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1114
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1115 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1116 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1117 *x -= GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1118 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1119 *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1120 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1121 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1122
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1123 if (GTK_WIDGET_NO_WINDOW (sample))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1124 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1125 *x += sample->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1126 *y += sample->allocation.y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1127 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1128
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1129 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1130 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1131 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1132 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1133
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1134 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1135 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1136 else if (*x + *width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1137 *x = monitor.x + monitor.width - *width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1138
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1139 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1140 *y += sample->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1141 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1142 *y -= *height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1143 }
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1144 #endif /* Gtk 2.2 */
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1145
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1146 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1147 * gtk_combo_box_popup:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1148 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1149 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1150 * Pops up the menu or dropdown list of @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1151 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1152 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1153 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1154 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1155 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1156 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1157 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1158 gtk_combo_box_popup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1159 {
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1160 gint x, y, width;
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1161 #if GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1162 gint height;
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1163 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1164
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1165 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1166
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1167 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1168 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1169
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1170 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1171 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1172 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1173 combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1174
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1175 if (combo_box->priv->wrap_width == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1176 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1177 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1178
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1179 width = GTK_WIDGET (combo_box)->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1180 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1181
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1182 gtk_widget_set_size_request (combo_box->priv->popup_widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1183 MAX (width, requisition.width), -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1184 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1185
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1186 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1187 NULL, NULL,
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1188 #if GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1189 gtk_combo_box_menu_position,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1190 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1191 NULL,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1192 #endif
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1193 combo_box, 0, 0);
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1194 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1195 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1196
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1197 gtk_widget_show_all (combo_box->priv->popup_frame);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1198 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1199 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1200 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1201
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1202 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1203 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1204
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1205 /* popup */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1206 gtk_widget_show (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1207
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1208 gtk_widget_grab_focus (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1209 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1210 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1211
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1212 if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1213 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1214 gdk_keyboard_grab (combo_box->priv->popup_window->window,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1215 FALSE, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1216 gtk_widget_grab_focus (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1217 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1218
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1219 gtk_grab_add (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1220 gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1221 GDK_BUTTON_PRESS_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1222 GDK_BUTTON_RELEASE_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1223 GDK_POINTER_MOTION_MASK,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1224 NULL, NULL, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1225
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1226 gtk_grab_add (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1227 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1228
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1229 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1230 * gtk_combo_box_popdown:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1231 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1232 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1233 * Hides the menu or dropdown list of @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1234 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1235 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1236 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1237 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1238 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1239 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1240 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1241 gtk_combo_box_popdown (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1242 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1243 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1244
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1245 if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1246 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1247
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1248 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1249 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1250 gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1251 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1252 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1253
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1254 gtk_combo_box_list_remove_grabs (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1255 gtk_widget_hide_all (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1256 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1257 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1258 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1259
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1260 static gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1261 gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1262 GtkTreePath *path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1263 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1264 gint padding;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1265 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1266
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1267 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1268 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1269 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1270 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1271 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1272 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1273
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1274 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1275 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1276
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1277 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1278 gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1279 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1280 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1281 req.width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1282
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1283 return req.width + padding;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1284 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1285
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1286 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1287 gtk_combo_box_remeasure (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1288 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1289 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1290 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1291 gint padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1292
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1293 if (!combo_box->priv->model ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1294 !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1295 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1296
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1297 combo_box->priv->width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1298
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1299 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1300 path = gtk_tree_path_new_from_indices (0, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1301 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1302 path = gtk_tree_path_new_first();
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1303 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1304
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1305 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1306 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1307 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1308 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1309 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1310 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1311
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1312 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1313 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1314
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1315 do
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1316 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1317 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1318
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1319 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1320 gtk_cell_view_get_size_of_row (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1321 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1322 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1323 req.width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1324
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1325 combo_box->priv->width = MAX (combo_box->priv->width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1326 req.width + padding);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1327
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1328 gtk_tree_path_next (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1329 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1330 while (gtk_tree_model_iter_next (combo_box->priv->model, &iter));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1331
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1332 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1333 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1334
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1335 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1336 gtk_combo_box_size_request (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1337 GtkRequisition *requisition)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1338 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1339 gint width, height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1340 GtkRequisition bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1341
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1342 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1343
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1344 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1345 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1346 gtk_combo_box_remeasure (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1347 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1348
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1349 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1350
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1351 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1352 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1353 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1354
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1355 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1356 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1357 GtkRequisition button_req, sep_req, arrow_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1358 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1359
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1360 gtk_widget_size_request (combo_box->priv->button, &button_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1361 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1362 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1363 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1364
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1365 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1366
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1367 gtk_widget_size_request (combo_box->priv->separator, &sep_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1368 gtk_widget_size_request (combo_box->priv->arrow, &arrow_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1369
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1370 height = MAX (sep_req.height, arrow_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1371 height = MAX (height, bin_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1372
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1373 width = bin_req.width + sep_req.width + arrow_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1374
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1375 height += border_width + 1 + ythickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1376 width += border_width + 1 + xthickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1377
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1378 requisition->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1379 requisition->height = height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1380 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1381 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1382 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1383 GtkRequisition but_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1384
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1385 gtk_widget_size_request (combo_box->priv->button, &but_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1386
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1387 requisition->width = bin_req.width + but_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1388 requisition->height = MAX (bin_req.height, but_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1389 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1390 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1391 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1392 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1393 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1394 GtkRequisition button_req, frame_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1395
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1396 /* sample + frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1397 *requisition = bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1398
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1399 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1400 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1401 gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1402 requisition->width += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1403 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1404 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1405 requisition->height += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1406 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1407 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1408 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1409
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1410 /* the button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1411 gtk_widget_size_request (combo_box->priv->button, &button_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1412
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1413 requisition->height = MAX (requisition->height, button_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1414 requisition->width += button_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1415 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1416 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1417
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1418 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1419 gtk_combo_box_size_allocate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1420 GtkAllocation *allocation)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1421 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1422 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1423 GtkAllocation child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1424 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1425 gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1426
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1427 widget->allocation = *allocation;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1428
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1429 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1430
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1431 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1432 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1433 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1434 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1435 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1436 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1437
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1438 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1439 gtk_widget_size_allocate (combo_box->priv->button, allocation);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1440
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1441 /* set some things ready */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1442 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1443 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1444 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1445
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1446 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1447 child.y = allocation->y + border_width + 1 + ythickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1448
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1449 width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1450
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1451 /* handle the children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1452 gtk_widget_size_request (combo_box->priv->arrow, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1453 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1454 child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1455 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1456 child.x += width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1457 gtk_widget_size_allocate (combo_box->priv->arrow, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1458 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1459 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1460 gtk_widget_size_request (combo_box->priv->separator, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1461 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1462 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1463 child.x -= req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1464 gtk_widget_size_allocate (combo_box->priv->separator, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1465
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1466 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1467 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1468 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1469 child.width = MAX(1, allocation->x + allocation->width
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1470 - (border_width + 1 + xthickness + 2) - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1471 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1472 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1473 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1474 child.width = child.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1475 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1476 child.width = MAX(1, child.width - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1477 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1478
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1479 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1480 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1481 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1482 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1483 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1484 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1485 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1486 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1487 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1488 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1489 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1490 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1491 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1492
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1493 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1494 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1495 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1496 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1497 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1498 child.width = MAX(1, allocation->width - req.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1499 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1500 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1501 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1502 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1503 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1504 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1505
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1506 /* button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1507 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1508 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1509 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1510 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1511 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1512 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1513 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1514 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1515 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1516
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1517 /* frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1518 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1519 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1520 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1521 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1522 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1523 child.width = MAX (1, allocation->width - req.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1524 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1525
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1526 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1527 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1528 gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1529
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1530 /* the sample */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1531 child.x +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1532 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1533 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1534 child.y +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1535 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1536 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1537 child.width -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1538 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1539 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1540 child.width = MAX(1,child.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1541 child.height -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1542 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1543 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1544 child.height = MAX(1,child.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1545 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1546
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1547 gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1548 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1549 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1550
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1551 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1552 gtk_combo_box_unset_model (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1553 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1554 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1555 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1556 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1557 combo_box->priv->inserted_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1558 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1559 combo_box->priv->deleted_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1560 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1561 combo_box->priv->reordered_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1562 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1563 combo_box->priv->changed_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1564 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1565
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1566 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1567 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1568 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1569 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1570 gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1571 (GtkCallback)gtk_widget_destroy, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1572 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1573
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1574 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1575 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1576 g_object_unref (G_OBJECT (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1577 combo_box->priv->model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1578 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1579
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1580 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1581 gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1582 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1583
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1584 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1585 gtk_combo_box_forall (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1586 gboolean include_internals,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1587 GtkCallback callback,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1588 gpointer callback_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1589 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1590 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1591
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1592 if (include_internals)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1593 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1594 if (combo_box->priv->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1595 (* callback) (combo_box->priv->button, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1596 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1597 (* callback) (combo_box->priv->cell_view_frame, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1598 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1599
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1600 if (GTK_BIN (container)->child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1601 (* callback) (GTK_BIN (container)->child, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1602 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1603
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1604 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1605 gtk_combo_box_expose_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1606 GdkEventExpose *event)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1607 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1608 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1609
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1610 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1611 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1612 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1613 combo_box->priv->button, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1614 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1615 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1616 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1617 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1618 combo_box->priv->button, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1619
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1620 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1621 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1622 combo_box->priv->cell_view_frame, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1623 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1624
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1625 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1626 GTK_BIN (widget)->child, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1627
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1628 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1629 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1630
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1631 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1632 gtk_combo_box_scroll_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1633 GdkEventScroll *event)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1634 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1635 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1636 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1637 gint items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1638
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1639 index = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1640
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1641 if (index != -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1642 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1643 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1644
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1645 if (event->direction == GDK_SCROLL_UP)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1646 index--;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1647 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1648 index++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1649
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1650 gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1651 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1652
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1653 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1654 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1655
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1656 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1657 * menu style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1658 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1659
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1660 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1661 cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1662 GtkCellView *cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1663 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1664 GSList *k;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1665
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1666 for (k = combo_box->priv->cells; k; k = k->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1667 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1668 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1669 ComboCellInfo *info = (ComboCellInfo *)k->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1670
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1671 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1672 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1673 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1674 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1675 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1676 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1677
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1678 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1679 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1680 info->func, info->func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1681
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1682 for (j = info->attributes; j; j = j->next->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1683 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1684 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1685 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1686 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1687 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1688 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1689 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1690 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1691
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1692 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1693 gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1694 gboolean add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1695 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1696 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1697
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1698 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1699 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1700 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1701 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1702 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1703 g_signal_connect_after (combo_box->priv->button, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1704 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1705 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1706 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1707
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1708 combo_box->priv->box = gtk_hbox_new (FALSE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1709 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1710 combo_box->priv->box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1711
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1712 combo_box->priv->separator = gtk_vseparator_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1713 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1714 combo_box->priv->separator);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1715
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1716 combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1717 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1718 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1719
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1720 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1721 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1722 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1723 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1724 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1725 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1726 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1727 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1728 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1729 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1730 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1731
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1732 combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1733 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1734 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1735 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1736 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1737
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1738 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1739 G_CALLBACK (gtk_combo_box_menu_button_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1740 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1741
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1742 /* create our funky menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1743 menu = gtk_menu_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1744 g_signal_connect (menu, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1745 G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1746 gtk_combo_box_set_popup_widget (combo_box, menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1747
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1748 /* add items */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1749 if (add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1750 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1751
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1752 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1753
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1754 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1755 gtk_combo_box_menu_fill (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1756 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1757 gint i, items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1758 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1759 GtkWidget *tmp;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1760
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1761 if (!combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1762 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1763
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1764 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1765 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1766
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1767 for (i = 0; i < items; i++)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1768 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1769 GtkTreePath *path;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1770 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1771 path = gtk_tree_path_new_from_indices (i, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1772 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1773 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1774 g_snprintf(buf, sizeof(buf), "%d", i);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1775 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1776 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1777 tmp = gtk_cell_view_menu_item_new_from_model (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1778 path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1779 g_signal_connect (tmp, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1780 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1781 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1782
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1783 cell_view_sync_cells (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1784 GTK_CELL_VIEW (GTK_BIN (tmp)->child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1785
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1786 gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1787
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1788 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1789 gtk_combo_box_relayout_item (combo_box, i);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1790
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1791 gtk_widget_show (tmp);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1792
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1793 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1794 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1795 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1796
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1797 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1798 gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1799 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1800 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1801 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1802 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1803 gtk_combo_box_menu_button_press, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1804
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1805 /* unparent will remove our latest ref */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1806 gtk_widget_unparent (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1807
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1808 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1809 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1810 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1811 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1812
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1813 /* changing the popup window will unref the menu and the children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1814 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1815
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1816 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1817 * grid
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1818 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1819
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1820 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1821 gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1822 gint index_,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1823 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1824 gint *rows)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1825 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1826 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1827
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1828 gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter, NULL, index_);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1829
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1830 if (cols)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1831 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1832 if (combo_box->priv->col_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1833 *cols = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1834 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1835 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1836 combo_box->priv->col_column, cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1837 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1838 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1839
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1840 if (rows)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1841 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1842 if (combo_box->priv->row_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1843 *rows = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1844 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1845 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1846 combo_box->priv->row_column, rows,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1847 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1848 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1849 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1850
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1851 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1852 menu_occupied (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1853 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1854 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1855 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1856 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1857 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1858 GList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1859
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1860 g_return_val_if_fail (GTK_IS_MENU (menu), TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1861 g_return_val_if_fail (left_attach < right_attach, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1862 g_return_val_if_fail (top_attach < bottom_attach, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1863
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1864 for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1865 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1866 guint l, r, b, t;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1867 gboolean h_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1868 gboolean v_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1869
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1870 gtk_container_child_get (GTK_CONTAINER (menu), i->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1871 "left_attach", &l,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1872 "right_attach", &r,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1873 "bottom_attach", &b,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1874 "top_attach", &t,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1875 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1876
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1877 /* look if this item intersects with the given coordinates */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1878 h_intersect = left_attach <= l && l <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1879 h_intersect &= left_attach <= r && r <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1880
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1881 v_intersect = top_attach <= t && t <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1882 v_intersect &= top_attach <= b && b <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1883
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1884 if (h_intersect && v_intersect)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1885 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1886 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1887
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1888 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1889 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1890
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1891 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1892 gtk_combo_box_relayout_item (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1893 gint index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1894 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1895 gint current_col = 0, current_row = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1896 gint rows, cols;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1897 GList *list, *nth;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1898 GtkWidget *item, *last;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1899 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1900
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1901 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1902 if (!GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1903 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1904
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1905 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1906 nth = g_list_nth (list, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1907 item = nth->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1908 if (nth->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1909 last = nth->prev->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1910 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1911 last = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1912 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1913
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1914 gtk_combo_box_item_get_size (combo_box, index, &cols, &rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1915
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1916 if (combo_box->priv->col_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1917 combo_box->priv->row_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1918 last)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1919 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1920 gtk_container_child_get (GTK_CONTAINER (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1921 last,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1922 "right_attach", &current_col,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1923 "top_attach", &current_row,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1924 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1925 if (current_col + cols > combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1926 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1927 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1928 current_row++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1929 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1930 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1931 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1932 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1933 /* look for a good spot */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1934 while (1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1935 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1936 if (current_col + cols > combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1937 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1938 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1939 current_row++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1940 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1941
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1942 if (!menu_occupied (GTK_MENU (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1943 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1944 current_row, current_row + rows))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1945 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1946
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1947 current_col++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1948 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1949 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1950
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1951 /* set attach props */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1952 gtk_menu_attach (GTK_MENU (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1953 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1954 current_row, current_row + rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1955 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1956
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1957 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1958 gtk_combo_box_relayout (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1959 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1960 GList *list, *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1961 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1962
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1963 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1964
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1965 /* do nothing unless we are in menu style and realized */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1966 if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1967 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1968
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1969 /* get rid of all children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1970 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1971
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1972 for (j = g_list_last (list); j; j = j->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1973 gtk_container_remove (GTK_CONTAINER (menu), j->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1974
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1975 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1976
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1977 /* and relayout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1978 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1979 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1980
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1981 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1982 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1983 gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1984 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1985 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1986 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1987 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1988
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1989 if (! GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1990 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1991
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1992 if (event->type == GDK_BUTTON_PRESS && event->button == 1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1993 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1994 combo_box->priv->popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1995
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1996 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1997 combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1998
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1999 if (combo_box->priv->wrap_width == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2000 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2001 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2002 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2003
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2004 width = GTK_WIDGET (combo_box)->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2005 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2006
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2007 gtk_widget_set_size_request (combo_box->priv->popup_widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2008 MAX (width, requisition.width), -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2009 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2010
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2011 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2012 NULL, NULL,
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2013 #if GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2014 gtk_combo_box_menu_position,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2015 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2016 NULL,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2017 #endif
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2018 combo_box, event->button, event->time);
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2019
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2020 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2021 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2022
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2023 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2024 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2025
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2026 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2027 gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2028 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2029 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2030 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2031 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2032 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2033
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2034 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2035 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2036
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2037 index = g_list_index (GTK_MENU_SHELL (menu)->children, item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2038
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2039 gtk_combo_box_set_active (combo_box, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2040 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2041
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2042 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2043 gtk_combo_box_model_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2044 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2045 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2046 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2047 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2048 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2049 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2050
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2051 if (combo_box->priv->active_item >= index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2052 combo_box->priv->active_item++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2053
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2054 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2055 gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2056 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2057
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2058 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2059 gtk_combo_box_model_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2060 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2061 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2062 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2063 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2064 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2065
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2066 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2067 gtk_combo_box_menu_row_deleted (model, path, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2068
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2069 if (index == combo_box->priv->active_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2070 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2071 gint items = gtk_tree_model_iter_n_children (model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2072
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2073 if (items == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2074 gtk_combo_box_set_active_internal (combo_box, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2075 else if (index == items)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2076 gtk_combo_box_set_active_internal (combo_box, index - 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2077 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2078 gtk_combo_box_set_active_internal (combo_box, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2079 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2080 else if (combo_box->priv->active_item > index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2081 combo_box->priv->active_item--;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2082 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2083
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2084 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2085 gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2086 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2087 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2088 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2089 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2090 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2091 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2092 gint items = gtk_tree_model_iter_n_children (model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2093 gint i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2094
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2095 for (i = 0; i < items; i++)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2096 if (new_order[i] == combo_box->priv->active_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2097 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2098 combo_box->priv->active_item = i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2099 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2100 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2101
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2102 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2103 gtk_combo_box_menu_rows_reordered (model, path, iter, new_order, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2104 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2105
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2106 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2107 gtk_combo_box_model_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2108 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2109 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2110 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2111 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2112 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2113 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2114
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2115 if (index == combo_box->priv->active_item &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2116 combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2117 gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2118
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2119 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2120 gtk_combo_box_list_row_changed (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2121 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2122 gtk_combo_box_menu_row_changed (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2123 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2124
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2125
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2126 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2127 gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2128 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2129 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2130 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2131 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2132 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2133 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2134 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2135
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2136 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2137 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2138
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2139 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2140 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2141
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2142 item = gtk_cell_view_menu_item_new_from_model (model, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2143 g_signal_connect (item, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2144 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2145 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2146
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2147 cell_view_sync_cells (combo_box, GTK_CELL_VIEW (GTK_BIN (item)->child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2148
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2149 gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2150 gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2151 gtk_widget_show (item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2152 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2153
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2154 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2155 gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2156 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2157 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2158 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2159 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2160 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2161 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2162 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2163
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2164 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2165 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2166
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2167 index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2168
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2169 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2170 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2171
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2172 item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2173 g_return_if_fail (GTK_IS_MENU_ITEM (item));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2174
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2175 gtk_container_remove (GTK_CONTAINER (menu), item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2176 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2177
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2178 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2179 gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2180 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2181 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2182 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2183 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2184 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2185 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2186
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2187 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2188 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2189
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2190 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2191 gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2192 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2193 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2194 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2195 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2196 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2197 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2198
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2199 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2200 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2201
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2202 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2203 gtk_combo_box_relayout_item (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2204 gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2205
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2206 width = gtk_combo_box_calc_requested_width (combo_box, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2207
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2208 if (width > combo_box->priv->width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2209 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2210 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2211 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2212 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2213 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2214 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2215 combo_box->priv->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2216 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2217 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2218
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2219 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2220 * list style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2221 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2222
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2223 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2224 gtk_combo_box_list_setup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2225 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2226 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2227 GtkTreeSelection *sel;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2228
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2229 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2230 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2231 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2232 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2233 G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2234 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2235 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2236 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2237 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2238
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2239 combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2240 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2241 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2242 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2243 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2244
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2245 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2246 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2247 combo_box->priv->cell_view_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2248 gtk_widget_set_parent (combo_box->priv->cell_view_frame,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2249 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2250 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->cell_view_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2251 GTK_SHADOW_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2252
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2253 gtk_cell_view_set_background_color (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2254 &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2255
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2256 combo_box->priv->box = gtk_event_box_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2257 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2258 gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2259 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2260 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2261
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2262 gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2263 combo_box->priv->box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2264
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2265 gtk_widget_show_all (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2266
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2267 g_signal_connect (combo_box->priv->box, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2268 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2269 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2270 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2271
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2272 combo_box->priv->tree_view = gtk_tree_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2273 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2274 gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2275 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2276 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2277 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2278 _gtk_tree_view_set_hover_selection (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2279 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2280 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2281 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2282 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2283 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2284
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2285 g_signal_connect (combo_box->priv->tree_view, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2286 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2287 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2288 g_signal_connect (combo_box->priv->tree_view, "button_release_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2289 G_CALLBACK (gtk_combo_box_list_button_released),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2290 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2291 g_signal_connect (combo_box->priv->tree_view, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2292 G_CALLBACK (gtk_combo_box_list_key_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2293 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2294
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2295 combo_box->priv->column = gtk_tree_view_column_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2296 gtk_tree_view_append_column (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2297 combo_box->priv->column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2298
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2299 /* sync up */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2300 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2301 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2302 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2303 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2304
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2305 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2306 gtk_tree_view_column_pack_start (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2307 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2308 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2309 gtk_tree_view_column_pack_end (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2310 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2311
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2312 for (j = info->attributes; j; j = j->next->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2313 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2314 gtk_tree_view_column_add_attribute (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2315 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2316 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2317 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2318 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2319 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2320
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2321 if (combo_box->priv->active_item != -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2322 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2323 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2324
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2325 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2326 path = gtk_tree_path_new_from_indices (combo_box->priv->active_item, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2327 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2328 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2329 g_snprintf(buf, sizeof(buf), "%d", combo_box->priv->active_item);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2330 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2331 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2332 if (path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2333 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2334 gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2335 path, NULL, FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2336 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2337 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2338 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2339
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2340 /* set sample/popup widgets */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2341 gtk_combo_box_set_popup_widget (combo_box, combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2342
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2343 gtk_widget_show (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2344 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2345
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2346 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2347 gtk_combo_box_list_destroy (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2348 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2349 /* disconnect signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2350 g_signal_handlers_disconnect_matched (combo_box->priv->tree_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2351 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2352 0, 0, NULL, NULL, combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2353 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2354 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2355 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2356 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2357 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2358 if (combo_box->priv->box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2359 g_signal_handlers_disconnect_matched (combo_box->priv->box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2360 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2361 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2362 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2363 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2364
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2365 /* destroy things (unparent will kill the latest ref from us)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2366 * last unref on button will destroy the arrow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2367 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2368 gtk_widget_unparent (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2369 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2370 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2371
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2372 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2373 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2374 g_object_set (G_OBJECT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2375 "background_set", FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2376 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2377 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2378
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2379 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2380 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2381 gtk_widget_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2382 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2383 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2384 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2385
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2386 gtk_widget_destroy (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2387
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2388 combo_box->priv->tree_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2389 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2390 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2391
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2392 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2393 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2394 gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2395 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2396 if (combo_box->priv->tree_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2397 GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2398 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2399 gtk_grab_remove (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2400 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2401
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2402 if (combo_box->priv->popup_window &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2403 GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2404 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2405 gtk_grab_remove (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2406 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2407 gdk_pointer_ungrab (GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2408 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2409 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2410
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2411 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2412 gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2413 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2414 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2415 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2416 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2417
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2418 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2419
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2420 if (ewidget == combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2421 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2422
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2423 if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2424 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2425 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2426
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2427 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2428
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2429 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2430 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2431
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2432 combo_box->priv->popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2433
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2434 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2435 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2436
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2437 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2438 gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2439 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2440 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2441 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2442 gboolean ret;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2443 GtkTreePath *path = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2444
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2445 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2446
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2447 gboolean popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2448
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2449 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2450
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2451 if (combo_box->priv->popup_in_progress)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2452 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2453 popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2454 combo_box->priv->popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2455 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2456
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2457 if (ewidget != combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2458 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2459 if (ewidget == combo_box->priv->button &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2460 !popup_in_progress &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2461 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2462 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2463 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2464 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2465 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2466
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2467 /* released outside treeview */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2468 if (ewidget != combo_box->priv->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2469 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2470 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2471
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2472 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2473 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2474
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2475 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2476 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2477
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2478 /* select something cool */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2479 ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2480 event->x, event->y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2481 &path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2482 NULL, NULL, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2483
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2484 if (!ret)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2485 return TRUE; /* clicked outside window? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2486
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2487 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2488 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2489
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2490 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2491
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2492 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2493 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2494
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2495 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2496 gtk_combo_box_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2497 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2498 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2499 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2500 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2501 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2502 gint items = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2503 gint index = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2504 gint new_index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2505
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2506 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2507 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2508
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2509 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2510 state == GDK_MOD1_MASK)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2511 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2512 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2513
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2514 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2515 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2516
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2517 switch (event->keyval)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2518 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2519 case GDK_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2520 case GDK_KP_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2521 new_index = index + 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2522 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2523 case GDK_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2524 case GDK_KP_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2525 new_index = index - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2526 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2527 case GDK_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2528 case GDK_KP_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2529 case GDK_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2530 case GDK_KP_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2531 new_index = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2532 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2533 case GDK_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2534 case GDK_KP_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2535 case GDK_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2536 case GDK_KP_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2537 new_index = items - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2538 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2539 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2540 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2541 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2542
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2543 if (items > 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2544 gtk_combo_box_set_active (combo_box, CLAMP (new_index, 0, items - 1));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2545
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2546 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2547 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2548
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2549 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2550 gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2551 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2552 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2553 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2554 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2555 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2556
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2557 if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2558 state == GDK_MOD1_MASK)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2559 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2560 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2562 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2563 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2564
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2565 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2566 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2567
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2568 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2569 gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2570 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2571 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2572 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2573 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2574 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2575
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2576 if (event->keyval == GDK_Escape ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2577 ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2578 state == GDK_MOD1_MASK))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2579 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2580 /* reset active item -- this is incredibly lame and ugly */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2581 gtk_combo_box_set_active (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2582 gtk_combo_box_get_active (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2583
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2584 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2585
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2586 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2587 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2588
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2589 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2590 event->keyval == GDK_space || event->keyval == GDK_KP_Space)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2591 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2592 gboolean ret = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2593 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2594 GtkTreeModel *model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2595
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2596 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2597 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2598 GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2599
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2600 ret = gtk_tree_selection_get_selected (sel, &model, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2601 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2602 if (ret)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2603 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2604 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2605
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2606 path = gtk_tree_model_get_path (model, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2607 if (path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2608 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2609 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2610 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2611 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2612 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2613
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2614 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2615
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2616 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2617 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2618
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2619 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2620 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2621
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2622 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2623 gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2624 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2625 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2626 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2627 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2628 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2629 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2630
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2631 width = gtk_combo_box_calc_requested_width (combo_box, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2632
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2633 if (width > combo_box->priv->width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2634 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2635 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2636 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2637 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2638 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2639 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2640 combo_box->priv->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2641 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2642 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2643
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2644 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2645 * GtkCellLayout implementation
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2646 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2647 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2648 gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2649 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2650 gboolean expand)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2651 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2652 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2653 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2654 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2655
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2656 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2657 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2658
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2659 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2660
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2661 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2662 gtk_object_sink (GTK_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2663
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2664 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2665 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2666 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2667 info->pack = GTK_PACK_START;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2668
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2669 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2670
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2671 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2672 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2673 cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2674
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2675 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2676 gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2677
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2678 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2679 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2680 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2681 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2682
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2683 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2684 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2685 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2686 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2687
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2688 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2689 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2690 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2691 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2692
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2693 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2694 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2695 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2696 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2697 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2698
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2699 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2700 gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2701 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2702 gboolean expand)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2703 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2704 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2705 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2706 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2707
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2708 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2709 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2710
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2711 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2712
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2713 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2714 gtk_object_sink (GTK_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2715
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2716 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2717 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2718 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2719 info->pack = GTK_PACK_END;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2720
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2721 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2722
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2723 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2724 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2725 cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2726
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2727 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2728 gtk_tree_view_column_pack_end (combo_box->priv->column, cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2729
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2730 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2731 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2732 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2733 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2734
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2735 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2736 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2737 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2738 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2739
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2740 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2741 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2742 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2743 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2744
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2745 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2746 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2747 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2748 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2749 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2750
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2751 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2752 gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2753 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2754 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2755 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2756 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2757
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2758 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2759
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2760 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2761
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2762 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2763 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2764
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2765 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2766 gtk_tree_view_column_clear (combo_box->priv->column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2767
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2768 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2769 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2770 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2771
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2772 gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2773 g_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2774 g_free (info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2775 i->data = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2776 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2777 g_slist_free (combo_box->priv->cells);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2778 combo_box->priv->cells = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2779
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2780 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2781 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2782 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2783 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2784
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2785 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2786 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2787 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2788 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2789
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2790 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2791 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2792 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2793 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2794
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2795 gtk_cell_layout_clear (GTK_CELL_LAYOUT (view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2796 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2797 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2798 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2799 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2800
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2801 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2802 gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2803 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2804 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2805 gint column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2806 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2807 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2808 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2809 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2810
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2811 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2812 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2813
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2814 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2815
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2816 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2817
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2818 info->attributes = g_slist_prepend (info->attributes,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2819 GINT_TO_POINTER (column));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2820 info->attributes = g_slist_prepend (info->attributes,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2821 g_strdup (attribute));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2822
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2823 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2824 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2825 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2826
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2827 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2828 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2829 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2830
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2831 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2832 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2833 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2834 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2835
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2836 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2837 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2838 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2839 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2840
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2841 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2842 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2843 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2844 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2845
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2846 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2847 attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2848 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2849 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2850 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2851
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2852 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2853 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2854
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2855 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2856 gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2857 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2858 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2859 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2860 GDestroyNotify destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2861 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2862 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2863 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2864 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2865
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2866 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2867
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2868 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2869
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2870 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2871 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2872
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2873 if (info->destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2874 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2875 GDestroyNotify d = info->destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2876
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2877 info->destroy = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2878 d (info->func_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2879 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2880
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2881 info->func = func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2882 info->func_data = func_data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2883 info->destroy = destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2884
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2885 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2886 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell, func, func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2887
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2888 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2889 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box->priv->column), cell, func, func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2890
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2891 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2892 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2893 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2894 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2895
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2896 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2897 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2898 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2899 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2900
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2901 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2902 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2903 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2904 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2905
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2906 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2907 func, func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2908 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2909 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2910 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2911
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2912 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2913 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2914
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2915 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2916 gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2917 GtkCellRenderer *cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2918 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2919 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2920 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2921 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2922 GSList *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2923
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2924 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2925 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2926
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2927 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2928
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2929 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2930 if (info)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2931 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2932 list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2933 while (list && list->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2934 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2935 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2936 list = list->next->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2937 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2938 g_slist_free (info->attributes);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2939 info->attributes = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2940 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2941
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2942 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2943 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->cell_view), cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2944
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2945 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2946 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (combo_box->priv->column), cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2947
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2948 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2949 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2950 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2951 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2952
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2953 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2954 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2955 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2956 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2957
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2958 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2959 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2960 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2961 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2962
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2963 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2964 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2965 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2966 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2967
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2968 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2969 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2970
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2971 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2972 gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2973 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2974 gint position)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2975 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2976 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2977 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2978 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2979 GSList *link;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2980
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2981 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2982 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2983
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2984 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2985
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2986 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2987
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2988 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2989 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2990
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2991 link = g_slist_find (combo_box->priv->cells, info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2992
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2993 g_return_if_fail (link != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2994
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2995 combo_box->priv->cells = g_slist_remove_link (combo_box->priv->cells, link);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2996 combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2997 position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2998
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2999 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3000 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3001 cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3002
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3003 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3004 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3005 cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3006
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3007 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3008 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3009 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3010 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3011
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3012 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3013 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3014 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3015 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3016
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3017 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3018 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3019 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3020 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3021
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3022 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3023 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3024 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3025 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3026
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3027 gtk_widget_queue_draw (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3028 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3029
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3030 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3031 * public API
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3032 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3033
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3034 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3035 * gtk_combo_box_new:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3036 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3037 * Creates a new empty #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3038 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3039 * Return value: A new #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3040 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3041 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3042 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3043 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3044 gtk_combo_box_new (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3045 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3046 return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3047 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3048
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3049 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3050 * gtk_combo_box_new_with_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3051 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3052 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3053 * Creates a new #GtkComboBox with the model initialized to @model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3054 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3055 * Return value: A new #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3056 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3057 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3058 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3059 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3060 gtk_combo_box_new_with_model (GtkTreeModel *model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3061 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3062 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3063
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3064 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3065
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3066 combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3067 "model", model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3068 NULL));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3069
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3070 return GTK_WIDGET (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3071 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3072
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3073 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3074 * gtk_combo_box_set_wrap_width:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3075 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3076 * @width: Preferred number of columns.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3077 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3078 * Sets the wrap width of @combo_box to be @width. The wrap width is basically
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3079 * the preferred number of columns when you want to the popup to be layed out
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3080 * in a table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3081 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3082 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3083 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3084 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3085 gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3086 gint width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3087 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3088 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3089 g_return_if_fail (width >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3090
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3091 if (width != combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3092 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3093 combo_box->priv->wrap_width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3094
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3095 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3096 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3097
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3098 g_object_notify (G_OBJECT (combo_box), "wrap_width");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3099 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3100 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3101
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3102 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3103 * gtk_combo_box_set_row_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3104 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3105 * @row_span: A column in the model passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3106 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3107 * Sets the column with row span information for @combo_box to be @row_span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3108 * The row span column contains integers which indicate how many rows
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3109 * an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3110 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3111 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3112 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3113 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3114 gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3115 gint row_span)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3116 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3117 gint col;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3118
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3119 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3120
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3121 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3122 g_return_if_fail (row_span >= 0 && row_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3123
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3124 if (row_span != combo_box->priv->row_column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3125 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3126 combo_box->priv->row_column = row_span;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3127
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3128 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3129
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3130 g_object_notify (G_OBJECT (combo_box), "row_span_column");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3131 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3132 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3133
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3134 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3135 * gtk_combo_box_set_column_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3136 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3137 * @column_span: A column in the model passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3138 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3139 * Sets the column with column span information for @combo_box to be
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3140 * @column_span. The column span column contains integers which indicate
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3141 * how many columns an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3142 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3143 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3144 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3145 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3146 gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3147 gint column_span)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3148 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3149 gint col;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3150
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3151 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3152
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3153 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3154 g_return_if_fail (column_span >= 0 && column_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3155
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3156 if (column_span != combo_box->priv->col_column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3157 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3158 combo_box->priv->col_column = column_span;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3159
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3160 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3161
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3162 g_object_notify (G_OBJECT (combo_box), "column_span_column");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3163 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3164 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3165
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3166 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3167 * gtk_combo_box_get_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3168 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3169 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3170 * Returns the index of the currently active item, or -1 if there's no
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3171 * active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3172 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3173 * Return value: An integer which is the index of the currently active item, or
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3174 * -1 if there's no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3175 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3176 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3177 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3178 gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3179 gtk_combo_box_get_active (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3180 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3181 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3182
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3183 return combo_box->priv->active_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3184 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3185
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3186 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3187 * gtk_combo_box_set_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3188 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3189 * @index_: An index in the model passed during construction, or -1 to have
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3190 * no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3191 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3192 * Sets the active item of @combo_box to be the item at @index.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3193 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3194 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3195 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3196 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3197 gtk_combo_box_set_active (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3198 gint index_)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3199 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3200 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3201 /* -1 means "no item selected" */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3202 g_return_if_fail (index_ >= -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3203
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3204 if (combo_box->priv->active_item == index_)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3205 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3206
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3207 gtk_combo_box_set_active_internal (combo_box, index_);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3208 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3209
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3210 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3211 gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3212 gint index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3213 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3214 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3215
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3216 combo_box->priv->active_item = index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3217
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3218 if (index == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3219 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3220 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3221 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (GTK_TREE_VIEW (combo_box->priv->tree_view)));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3222 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3223 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3224 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3225
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3226 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3227 gtk_menu_set_active (menu, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3228 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3229
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3230 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3231 gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3232 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3233 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3234 {
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3235 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3236 path = gtk_tree_path_new_from_indices (index, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3237 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3238 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3239 g_snprintf(buf, sizeof(buf), "%d", index);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3240 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3241 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3242
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3243 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3244 gtk_tree_view_set_cursor (GTK_TREE_VIEW (combo_box->priv->tree_view), path, NULL, FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3245 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3246 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3247 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3248
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3249 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3250 gtk_menu_set_active (GTK_MENU (menu), index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3251 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3252
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3253 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3254 gtk_cell_view_set_displayed_row (GTK_CELL_VIEW (combo_box->priv->cell_view), path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3255
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3256 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3257 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3258
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3259 g_signal_emit_by_name (combo_box, "changed", NULL, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3260 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3261
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3262
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3263 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3264 * gtk_combo_box_get_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3265 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3266 * @iter: The uninitialized #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3267 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3268 * Sets @iter to point to the current active item, if it exists.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3269 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3270 * Return value: %TRUE, if @iter was set
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3271 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3272 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3273 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3274 gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3275 gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3276 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3277 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3278 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3279 gint active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3280 gboolean retval;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3281 #if !GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3282 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3283 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3284
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3285 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3286
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3287 active = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3288 if (active < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3289 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3290
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3291 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3292 path = gtk_tree_path_new_from_indices (active, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3293 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3294 g_snprintf(buf, sizeof(buf), "%d", active);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3295 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3296 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3297 retval = gtk_tree_model_get_iter (gtk_combo_box_get_model (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3298 iter, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3299 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3300
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3301 return retval;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3302 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3303
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3304 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3305 * gtk_combo_box_set_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3306 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3307 * @iter: The #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3308 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3309 * Sets the current active item to be the one referenced by @iter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3310 * @iter must correspond to a path of depth one.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3311 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3312 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3313 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3314 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3315 gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3316 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3317 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3318 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3319
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3320 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3321
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3322 path = gtk_tree_model_get_path (gtk_combo_box_get_model (combo_box), iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3323 g_return_if_fail (path != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3324 g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3325
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3326 gtk_combo_box_set_active (combo_box, gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3327 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3328 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3329
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3330 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3331 * gtk_combo_box_set_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3332 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3333 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3334 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3335 * Sets the model used by @combo_box to be @model. Will unset a previously set
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3336 * model (if applicable). If @model is %NULL, then it will unset the model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3337 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3338 * Note that this function does not clear the cell renderers, you have to
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3339 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3340 * different cell renderers for the new model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3341 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3342 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3343 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3344 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3345 gtk_combo_box_set_model (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3346 GtkTreeModel *model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3347 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3348 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3349
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3350 if (!model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3351 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3352 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3353 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3354 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3355
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3356 g_return_if_fail (GTK_IS_TREE_MODEL (model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3357
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3358 if (model == combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3359 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3360
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3361 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3362 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3363
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3364 combo_box->priv->model = model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3365 g_object_ref (G_OBJECT (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3366
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3367 combo_box->priv->inserted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3368 g_signal_connect (combo_box->priv->model, "row_inserted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3369 G_CALLBACK (gtk_combo_box_model_row_inserted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3370 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3371 combo_box->priv->deleted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3372 g_signal_connect (combo_box->priv->model, "row_deleted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3373 G_CALLBACK (gtk_combo_box_model_row_deleted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3374 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3375 combo_box->priv->reordered_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3376 g_signal_connect (combo_box->priv->model, "rows_reordered",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3377 G_CALLBACK (gtk_combo_box_model_rows_reordered),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3378 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3379 combo_box->priv->changed_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3380 g_signal_connect (combo_box->priv->model, "row_changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3381 G_CALLBACK (gtk_combo_box_model_row_changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3382 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3383
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3384 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3385 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3386 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3387 gtk_tree_view_set_model (GTK_TREE_VIEW (combo_box->priv->tree_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3388 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3389 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3390 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3391 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3392 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3393 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3394 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3395
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3396 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3397
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3398 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3399 gtk_cell_view_set_model (GTK_CELL_VIEW (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3400 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3401 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3402
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3403 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3404 * gtk_combo_box_get_model
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3405 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3406 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3407 * Returns the #GtkTreeModel which is acting as data source for @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3408 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3409 * Return value: A #GtkTreeModel which was passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3410 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3411 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3412 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3413 GtkTreeModel *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3414 gtk_combo_box_get_model (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3415 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3416 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3417
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3418 return combo_box->priv->model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3419 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3420
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3421
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3422 /* convenience API for simple text combos */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3423
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3424 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3425 * gtk_combo_box_new_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3426 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3427 * Convenience function which constructs a new text combo box, which is a
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3428 * #GtkComboBox just displaying strings. If you use this function to create
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3429 * a text combo box, you should only manipulate its data source with the
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3430 * following convenience functions: gtk_combo_box_append_text(),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3431 * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3432 * gtk_combo_box_remove_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3433 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3434 * Return value: A new text combo box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3435 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3436 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3437 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3438 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3439 gtk_combo_box_new_text (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3440 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3441 GtkWidget *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3442 GtkCellRenderer *cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3443 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3444
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3445 store = gtk_list_store_new (1, G_TYPE_STRING);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3446 combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3447 g_object_unref (store);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3448
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3449 cell = gtk_cell_renderer_text_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3450 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3451 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3452 "text", 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3453 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3454
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3455 return combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3456 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3457
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3458 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3459 * gtk_combo_box_append_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3460 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3461 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3462 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3463 * Appends @string to the list of strings stored in @combo_box. Note that
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3464 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3465 * gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3466 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3467 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3468 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3469 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3470 gtk_combo_box_append_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3471 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3472 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3473 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3474 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3475
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3476 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3477 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3478 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3479
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3480 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3481
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3482 gtk_list_store_append (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3483 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3484 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3485
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3486 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3487 * gtk_combo_box_insert_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3488 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3489 * @position: An index to insert @text.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3490 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3491 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3492 * Inserts @string at @position in the list of strings stored in @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3493 * Note that you can only use this function with combo boxes constructed
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3494 * with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3495 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3496 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3497 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3498 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3499 gtk_combo_box_insert_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3500 gint position,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3501 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3502 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3503 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3504 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3505
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3506 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3507 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3508 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3509 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3510
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3511 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3512
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3513 gtk_list_store_insert (store, &iter, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3514 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3515 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3516
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3517 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3518 * gtk_combo_box_prepend_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3519 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3520 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3521 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3522 * Prepends @string to the list of strings stored in @combo_box. Note that
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3523 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3524 * gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3525 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3526 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3527 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3528 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3529 gtk_combo_box_prepend_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3530 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3531 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3532 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3533 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3534
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3535 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3536 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3537 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3538
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3539 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3540
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3541 gtk_list_store_prepend (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3542 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3543 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3544
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3545 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3546 * gtk_combo_box_remove_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3547 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3548 * @position: Index of the item to remove.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3549 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3550 * Removes the string at @position from @combo_box. Note that you can only use
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3551 * this function with combo boxes constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3552 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3553 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3554 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3555 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3556 gtk_combo_box_remove_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3557 gint position)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3558 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3559 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3560 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3562 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3563 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3564 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3565
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3566 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3567
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3568 if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3569 NULL, position))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3570 gtk_list_store_remove (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3571 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3572
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3573
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3574 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3575 gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3576 gboolean group_cycling)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3577 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3578 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3579
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3580 gtk_widget_grab_focus (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3581
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3582 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3583 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3584
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3585 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3586 gtk_combo_box_destroy (GtkObject *object)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3587 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3588 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3589
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3590 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3591
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3592 combo_box->priv->destroying = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3593
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3594 GTK_OBJECT_CLASS (parent_class)->destroy (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3595 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3596
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3597 combo_box->priv->destroying = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3598 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3599
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3600 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3601 gtk_combo_box_finalize (GObject *object)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3602 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3603 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3604 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3605
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3606 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3607 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3608 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3609 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3610 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3611 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3612
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3613 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3614 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3615
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3616 if (combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3617 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3618
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3619 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3620
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3621 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3622 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3623 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3624 GSList *list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3625
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3626 if (info->destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3627 info->destroy (info->func_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3628
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3629 while (list && list->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3630 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3631 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3632 list = list->next->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3633 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3634 g_slist_free (info->attributes);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3635
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3636 g_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3637 g_free (info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3638 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3639 g_slist_free (combo_box->priv->cells);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3640
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3641 g_free (combo_box->priv);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3642
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3643 G_OBJECT_CLASS (parent_class)->finalize (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3644 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3645
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3646
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3647 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3648 * Code below this point has been pulled in from gtkmenu.c in 2.4.14
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3649 * and is needed to provide gtk_menu_attach()
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3650 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3651
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3652 typedef struct
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3653 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3654 gint left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3655 gint right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3656 gint top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3657 gint bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3658 gint effective_left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3659 gint effective_right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3660 gint effective_top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3661 gint effective_bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3662 } AttachInfo;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3663
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3664 #define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3665
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3666 static AttachInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3667 get_attach_info (GtkWidget *child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3668 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3669 GObject *object = G_OBJECT (child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3670 AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3671
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3672 if (!ai)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3673 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3674 ai = g_new0 (AttachInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3675 g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3676 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3677
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3678 return ai;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3679 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3680
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3681 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3682 * gtk_menu_attach:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3683 * @menu: a #GtkMenu.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3684 * @child: a #GtkMenuItem.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3685 * @left_attach: The column number to attach the left side of the item to.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3686 * @right_attach: The column number to attach the right side of the item to.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3687 * @top_attach: The row number to attach the top of the item to.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3688 * @bottom_attach: The row number to attach the bottom of the item to.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3689 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3690 * Adds a new #GtkMenuItem to a (table) menu. The number of 'cells' that
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3691 * an item will occupy is specified by @left_attach, @right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3692 * @top_attach and @bottom_attach. These each represent the leftmost,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3693 * rightmost, uppermost and lower column and row numbers of the table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3694 * (Columns and rows are indexed from zero).
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3695 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3696 * Note that this function is not related to gtk_menu_detach().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3697 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3698 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3699 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3700 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3701 gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3702 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3703 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3704 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3705 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3706 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3707 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3708 GtkMenuShell *menu_shell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3709
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3710 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3711 g_return_if_fail (GTK_IS_MENU_ITEM (child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3712 g_return_if_fail (child->parent == NULL ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3713 child->parent == GTK_WIDGET (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3714 g_return_if_fail (left_attach < right_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3715 g_return_if_fail (top_attach < bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3716
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3717 menu_shell = GTK_MENU_SHELL (menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3718
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3719 if (!child->parent)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3720 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3721 AttachInfo *ai = get_attach_info (child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3722
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3723 ai->left_attach = left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3724 ai->right_attach = right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3725 ai->top_attach = top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3726 ai->bottom_attach = bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3727
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3728 menu_shell->children = g_list_append (menu_shell->children, child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3729
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3730 gtk_widget_set_parent (child, GTK_WIDGET (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3731
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3732 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3733 menu_queue_resize (menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3734 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3735 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3736 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3737 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3738 gtk_container_child_set (GTK_CONTAINER (child->parent), child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3739 "left_attach", left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3740 "right_attach", right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3741 "top_attach", top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3742 "bottom_attach", bottom_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3743 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3744 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3745 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3746 #endif /* Gtk 2.4 */