annotate src/gtkcombobox.c @ 13186:7df94dba7ab8

[gaim-migrate @ 15549] This stuff doesn't belong in here, as this should be building from a make dist'ed tree, right? committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 08 Feb 2006 20:57:17 +0000
parents 1ee0a397157f
children 7ab959eb857e
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 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
298 static void gtk_combo_box_list_position (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
299 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
300 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
301 gint *width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
302 gint *height);
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
303
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
304 static void gtk_combo_box_list_setup (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
305 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
306
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
307 static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
308
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
309 static gboolean gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
310 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
311 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
312 static gboolean gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
313 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
314 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
315 static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
316 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
317 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
318
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
319 static void gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
320 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
321 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
322 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
323
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
324 /* menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
325 static void gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
326 gboolean add_children);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
327 static void gtk_combo_box_menu_fill (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
328 static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
329
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
330 static void gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
331 gint index,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
332 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
333 gint *rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
334 static void gtk_combo_box_relayout_item (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
335 gint index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
336 static void gtk_combo_box_relayout (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
337
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
338 static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
339 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
340 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
341 static void gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
342 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
343 static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
344 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
345 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
346 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
347 static void gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
348 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
349 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
350 static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
351 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
352 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
353 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
354 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
355 static void gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
356 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
357 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
358 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
359 static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
360 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
361 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
362
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
363 /* cell layout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
364 static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
365 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
366 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
367 static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
368 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
369 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
370 static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
371 static void gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
372 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
373 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
374 gint column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
375 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
376 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
377 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
378 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
379 GDestroyNotify destroy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
380 static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
381 GtkCellRenderer *cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
382 static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
383 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
384 gint position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
385 static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
386 gboolean group_cycling);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
387
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
388 static void cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
389 GtkCellView *cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
390
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
391 #if !GTK_CHECK_VERSION(2,4,0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
392 static void gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
393 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
394 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
395 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
396 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
397 guint bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
398 #endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
399
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
400 GType
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
401 gtk_combo_box_get_type (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
402 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
403 static GType combo_box_type = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
404
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
405 if (!combo_box_type)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
406 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
407 static const GTypeInfo combo_box_info =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
408 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
409 sizeof (GtkComboBoxClass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
410 NULL, /* base_init */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
411 NULL, /* base_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
412 (GClassInitFunc) gtk_combo_box_class_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
413 NULL, /* class_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
414 NULL, /* class_data */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
415 sizeof (GtkComboBox),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
416 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
417 (GInstanceInitFunc) gtk_combo_box_init
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
418 };
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 static const GInterfaceInfo cell_layout_info =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
421 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
422 (GInterfaceInitFunc) gtk_combo_box_cell_layout_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
423 NULL,
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 };
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 combo_box_type = g_type_register_static (GTK_TYPE_BIN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
428 "GaimGtkComboBox",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
429 &combo_box_info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
430 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
431
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
432 g_type_add_interface_static (combo_box_type,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
433 GTK_TYPE_CELL_LAYOUT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
434 &cell_layout_info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
435 }
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 return combo_box_type;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
438 }
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 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
441 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
442 gtk_combo_box_class_init (GtkComboBoxClass *klass)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
443 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
444 GObjectClass *object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
445 GtkBindingSet *binding_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
446 GtkObjectClass *gtk_object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
447 GtkContainerClass *container_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
448 GtkWidgetClass *widget_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
449
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
450 binding_set = gtk_binding_set_by_class (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
451
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
452 container_class = (GtkContainerClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
453 container_class->forall = gtk_combo_box_forall;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
454 container_class->add = gtk_combo_box_add;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
455 container_class->remove = gtk_combo_box_remove;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
456
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
457 widget_class = (GtkWidgetClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
458 widget_class->size_allocate = gtk_combo_box_size_allocate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
459 widget_class->size_request = gtk_combo_box_size_request;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
460 widget_class->expose_event = gtk_combo_box_expose_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
461 widget_class->scroll_event = gtk_combo_box_scroll_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
462 widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
463 widget_class->style_set = gtk_combo_box_style_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
464 widget_class->state_changed = gtk_combo_box_state_changed;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
465
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
466 gtk_object_class = (GtkObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
467 gtk_object_class->destroy = gtk_combo_box_destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
468
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
469 object_class = (GObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
470 object_class->finalize = gtk_combo_box_finalize;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
471 object_class->set_property = gtk_combo_box_set_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
472 object_class->get_property = gtk_combo_box_get_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
473
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
474 parent_class = g_type_class_peek_parent (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
475
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
476 /* signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
477 combo_box_signals[CHANGED] =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
478 g_signal_new ("changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
479 G_OBJECT_CLASS_TYPE (klass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
480 G_SIGNAL_RUN_LAST,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
481 G_STRUCT_OFFSET (GtkComboBoxClass, changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
482 NULL, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
483 g_cclosure_marshal_VOID__VOID,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
484 G_TYPE_NONE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
485
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
486 /* properties */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
487 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
488 PROP_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
489 g_param_spec_object ("model",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
490 _("ComboBox model"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
491 _("The model for the combo box"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
492 GTK_TYPE_TREE_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
493 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
494
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
495 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
496 PROP_WRAP_WIDTH,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
497 g_param_spec_int ("wrap_width",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
498 _("Wrap width"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
499 _("Wrap width for layouting the items in a grid"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
500 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
501 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
502 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
503 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
504
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
505 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
506 PROP_ROW_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
507 g_param_spec_int ("row_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
508 _("Row span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
509 _("TreeModel column containing the row span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
510 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
511 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
512 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
513 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
514
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
515 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
516 PROP_COLUMN_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
517 g_param_spec_int ("column_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
518 _("Column span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
519
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
520 _("TreeModel column containing the column span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
521 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
522 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
523 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
524 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
525
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
526 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
527 PROP_ACTIVE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
528 g_param_spec_int ("active",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
529 _("Active item"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
530 _("The item which is currently active"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
531 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
532 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
533 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
534 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
535
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
536 gtk_widget_class_install_style_property (widget_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
537 g_param_spec_boolean ("appears-as-list",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
538 _("Appears as list"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
539 _("Whether combobox dropdowns should look like lists rather than menus"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
540 FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
541 G_PARAM_READABLE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
542 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
545 gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
546 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
547 iface->pack_start = gtk_combo_box_cell_layout_pack_start;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
548 iface->pack_end = gtk_combo_box_cell_layout_pack_end;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
549 iface->clear = gtk_combo_box_cell_layout_clear;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
550 iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
551 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
552 iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
553 iface->reorder = gtk_combo_box_cell_layout_reorder;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
554 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
557 gtk_combo_box_init (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
558 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
559 combo_box->priv = g_new0(GtkComboBoxPrivate,1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
560
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
561 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
562 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
563 GTK_BIN (combo_box)->child = combo_box->priv->cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
564 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
565
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
566 combo_box->priv->width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
567 combo_box->priv->wrap_width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
568
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
569 combo_box->priv->active_item = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
570 combo_box->priv->col_column = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
571 combo_box->priv->row_column = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
572 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
575 gtk_combo_box_set_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
576 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
577 const GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
578 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
579 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
580 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
581
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
582 switch (prop_id)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
583 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
584 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
585 gtk_combo_box_set_model (combo_box, g_value_get_object (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
586 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
587
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
588 case PROP_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
589 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
590 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
591
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
592 case PROP_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
593 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
594 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
595
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
596 case PROP_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
597 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
598 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
599
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
600 case PROP_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
601 gtk_combo_box_set_active (combo_box, g_value_get_int (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
602 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
603
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
604 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
605 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
606 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
610 gtk_combo_box_get_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
611 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
612 GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
613 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
614 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
615 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
616
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
617 switch (prop_id)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
618 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
619 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
620 g_value_set_object (value, combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
621 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
622
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
623 case PROP_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
624 g_value_set_int (value, combo_box->priv->wrap_width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
625 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
626
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
627 case PROP_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
628 g_value_set_int (value, combo_box->priv->row_column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
629 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
630
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
631 case PROP_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
632 g_value_set_int (value, combo_box->priv->col_column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
633 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
634
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
635 case PROP_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
636 g_value_set_int (value, gtk_combo_box_get_active (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
637 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
638
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
639 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
640 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
641 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
642 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
646 gtk_combo_box_state_changed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
647 GtkStateType previous)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
648 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
649 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
650
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
651 if (GTK_WIDGET_REALIZED (widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
652 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
653 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
654 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
655 &widget->style->base[GTK_WIDGET_STATE (widget)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
656 }
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 gtk_widget_queue_draw (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
659 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
662 gtk_combo_box_check_appearance (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
663 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
664 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
665
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
666 /* 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
667 * unix style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
668 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
669 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
670 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
671 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
672 gtk_widget_style_get (GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
673 "appears-as-list", &appears_as_list,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
674 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
675
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
676 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
677 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
678 /* Destroy all the menu mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
679 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
680 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
681
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
682 /* Create the list mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
683 if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
684 gtk_combo_box_list_setup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
685 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
686 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
687 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
688 /* Destroy all the list mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
689 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
690 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
691
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
692 /* Create the menu mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
693 if (!GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
694 gtk_combo_box_menu_setup (combo_box, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
695 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
699 gtk_combo_box_style_set (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
700 GtkStyle *previous)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
701 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
702 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
703
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
704 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
705
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
706 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
707 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
708 &widget->style->base[GTK_WIDGET_STATE (widget)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
709 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
712 gtk_combo_box_button_toggled (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
713 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
714 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
715 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
716
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
717 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
718 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
719 if (!combo_box->priv->popup_in_progress)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
720 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
721 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
722 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
723 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
724 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
727 gtk_combo_box_add (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
728 GtkWidget *widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
729 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
730 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
731
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
732 if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
733 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
734 gtk_widget_unparent (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
735 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
736 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
737 }
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 gtk_widget_set_parent (widget, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
740 GTK_BIN (container)->child = widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
741
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
742 if (combo_box->priv->cell_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
743 widget != combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
744 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
745 /* since the cell_view was unparented, it's gone now */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
746 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
747
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
748 if (!combo_box->priv->tree_view && combo_box->priv->separator)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
749 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
750 gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
751 combo_box->priv->separator);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
752 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
753
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
754 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
755 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
756 else if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
757 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
758 gtk_widget_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
759 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
760 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
765 gtk_combo_box_remove (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
766 GtkWidget *widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
767 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
768 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
769 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
770
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
771 gtk_widget_unparent (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
772 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
773
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
774 if (combo_box->priv->destroying)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
775 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
776
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
777 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
778
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
779 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
780 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
781 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
782 appears_as_list = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
783
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
784 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
785 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
786 else if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
787 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
788 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
789 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
790 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
791 }
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 if (!combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
794 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
795 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
796 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
797 GTK_BIN (container)->child = combo_box->priv->cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
798
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
799 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
800 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
801 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
802 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
803 }
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 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
807 gtk_combo_box_list_setup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
808 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
809 gtk_combo_box_menu_setup (combo_box, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
810
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
811 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
812 }
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 static ComboCellInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
815 gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
816 GtkCellRenderer *cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
817 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
818 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
819
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
820 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
821 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
822 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
823
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
824 if (info && info->cell == cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
825 return info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
826 }
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 return NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
829 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
832 gtk_combo_box_menu_show (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
833 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
834 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
835 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
836
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
837 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
838 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
839 combo_box->priv->popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
840 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
843 gtk_combo_box_menu_hide (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
844 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
845 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
846 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
847
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
848 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
849 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
850 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
853 gtk_combo_box_detacher (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
854 GtkMenu *menu)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
855 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
856 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
857
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
858 g_return_if_fail (GTK_IS_COMBO_BOX (widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
859
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
860 combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
861 g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
862
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
863 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
864 gtk_combo_box_menu_show,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
865 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
866 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
867 gtk_combo_box_menu_hide,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
868 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
869
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
870 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
871 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
874 gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
875 GtkWidget *popup)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
876 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
877 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
878 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
879 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
880 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
881 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
882 else if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
883 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
884 gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
885 combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
886 g_object_unref (G_OBJECT (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
887 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
888 }
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 if (GTK_IS_MENU (popup))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
891 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
892 if (combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
893 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
894 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
895 combo_box->priv->popup_window = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
896 combo_box->priv->popup_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
897 }
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 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
900
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
901 g_signal_connect (popup, "show",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
902 G_CALLBACK (gtk_combo_box_menu_show), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
903 g_signal_connect (popup, "hide",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
904 G_CALLBACK (gtk_combo_box_menu_hide), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
905
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
906 gtk_menu_attach_to_widget (GTK_MENU (popup),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
907 GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
908 gtk_combo_box_detacher);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
909 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
910 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
911 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
912 if (!combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
913 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
914 combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
915 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
916 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
917 gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
918 gtk_widget_get_screen (GTK_WIDGET (combo_box)));
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
919 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
920
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
921 combo_box->priv->popup_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
922 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
923 GTK_SHADOW_ETCHED_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
924 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
925 combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
926
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
927 gtk_widget_show (combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
928 }
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 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
931 popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
932 gtk_widget_show (popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
933 g_object_ref (G_OBJECT (popup));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
934 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
935 }
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
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
938 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
939 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
940 gtk_combo_box_menu_position_below (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
941 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
942 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
943 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
944 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
945 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
946 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
947 gint sx, sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
948 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
949 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
950 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
951 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
952 GdkRectangle monitor;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
953
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
954 /* FIXME: is using the size request here broken? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
955 child = GTK_BIN (combo_box)->child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
956
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
957 gdk_window_get_origin (child->window, &sx, &sy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
958
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
959 if (GTK_WIDGET_NO_WINDOW (child))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
960 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
961 sx += child->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
962 sy += child->allocation.y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
963 }
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 gtk_widget_size_request (GTK_WIDGET (menu), &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
966
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
967 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
968 *x = sx;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
969 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
970 *x = sx + child->allocation.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
971 *y = sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
972
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
973 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
974 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
975 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
976 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
977
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
978 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
979 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
980 else if (*x + req.width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
981 *x = monitor.x + monitor.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
982
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
983 if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
984 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
985 else if (*y - monitor.y >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
986 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
987 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
988 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
989 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
990 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
991
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
992 *push_in = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
993 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
996 gtk_combo_box_menu_position_over (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
997 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
998 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
999 gboolean *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1000 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1001 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1002 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1003 GtkWidget *active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1004 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1005 GtkWidget *widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1006 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1007 GList *children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1008 gint screen_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1009 gint menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1010 gint menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1011 gint menu_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1012
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1013 g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1014
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1015 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1016 widget = GTK_WIDGET (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1017
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1018 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1019 menu_width = requisition.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1020
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1021 active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1022 gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1023
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1024 menu_xpos += widget->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1025 menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1026
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1027 if (active != NULL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1028 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1029 gtk_widget_get_child_requisition (active, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1030 menu_ypos -= requisition.height / 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1031 }
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 children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1034 while (children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1035 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1036 child = children->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1037
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1038 if (active == child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1039 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1040
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1041 if (GTK_WIDGET_VISIBLE (child))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1042 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1043 gtk_widget_get_child_requisition (child, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1044 menu_ypos -= requisition.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1045 }
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 children = children->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1048 }
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 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1051 menu_xpos = menu_xpos + widget->allocation.width - menu_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1052
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1053 /* Clamp the position on screen */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1054 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1055
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1056 if (menu_xpos < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1057 menu_xpos = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1058 else if ((menu_xpos + menu_width) > screen_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1059 menu_xpos -= ((menu_xpos + menu_width) - screen_width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1060
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1061 *x = menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1062 *y = menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1063
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1064 *push_in = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1065 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1068 gtk_combo_box_menu_position (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1069 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1070 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1071 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1072 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1073 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1074 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1075 GtkWidget *menu_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1076
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1077 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1078
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1079 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
1080 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
1081 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1082 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1083 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
1084 if (menu_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1085 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
1086 menu_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1087
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1088 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
1089 }
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 }
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1092 #endif /* Gtk 2.2 */
10708
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;
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1102 GtkRequisition popup_req;
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1103 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1104 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1105 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1106 GdkRectangle monitor;
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1107 #endif
10708
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 sample = GTK_BIN (combo_box)->child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1110
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1111 *width = sample->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1112 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1113 *height = popup_req.height;
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 gdk_window_get_origin (sample->window, x, y);
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 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1118 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1119 *x -= 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 *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1122 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1123 }
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 if (GTK_WIDGET_NO_WINDOW (sample))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1126 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1127 *x += sample->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1128 *y += sample->allocation.y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1129 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1130
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1131 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1132 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1133 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1134 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1135 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1136
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1137 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1138 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1139 else if (*x + *width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1140 *x = monitor.x + monitor.width - *width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1141
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1142 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1143 *y += sample->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1144 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1145 *y -= *height;
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1146 #endif /* Gtk 2.2 */
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1147 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1148
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 * gtk_combo_box_popup:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1151 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1152 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1153 * Pops up the menu or dropdown list of @combo_box.
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 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1156 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1157 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1158 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1159 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1160 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1161 gtk_combo_box_popup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1162 {
12505
1ee0a397157f [gaim-migrate @ 14817]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
1163 gint x, y, width, height;
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);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1198 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1199
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1200 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1201 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1202
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1203 /* popup */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1204 gtk_widget_show (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1205
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1206 gtk_widget_grab_focus (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1207 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1208 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1209
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1210 if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view))
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 gdk_keyboard_grab (combo_box->priv->popup_window->window,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1213 FALSE, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1214 gtk_widget_grab_focus (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1215 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1216
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1217 gtk_grab_add (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1218 gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1219 GDK_BUTTON_PRESS_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1220 GDK_BUTTON_RELEASE_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1221 GDK_POINTER_MOTION_MASK,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1222 NULL, NULL, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1223
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1224 gtk_grab_add (combo_box->priv->tree_view);
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
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 * gtk_combo_box_popdown:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1229 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1230 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1231 * Hides the menu or dropdown list of @combo_box.
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 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1234 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1235 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1236 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1239 gtk_combo_box_popdown (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1240 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1241 g_return_if_fail (GTK_IS_COMBO_BOX (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 if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1244 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1245
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1246 if (GTK_IS_MENU (combo_box->priv->popup_widget))
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 gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1249 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1250 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1251
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1252 gtk_combo_box_list_remove_grabs (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1253 gtk_widget_hide_all (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1254 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1255 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1256 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1257
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1258 static gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1259 gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1260 GtkTreePath *path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1261 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1262 gint padding;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1263 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1264
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1265 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1266 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1267 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1268 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1269 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1270 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1271
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1272 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1273 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1274
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1275 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1276 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
1277 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1278 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1279 req.width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1280
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1281 return req.width + padding;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1284 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1285 gtk_combo_box_remeasure (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1286 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1287 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1288 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1289 gint padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1290
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1291 if (!combo_box->priv->model ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1292 !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1293 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1294
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1295 combo_box->priv->width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1296
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1297 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1298 path = gtk_tree_path_new_from_indices (0, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1299 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1300 path = gtk_tree_path_new_first();
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1301 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1302
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1303 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1304 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1305 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1306 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1307 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1308 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1309
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1310 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1311 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1312
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1313 do
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 GtkRequisition req;
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1318 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
1319 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1320 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1321 req.width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1322
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1323 combo_box->priv->width = MAX (combo_box->priv->width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1324 req.width + padding);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1325
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1326 gtk_tree_path_next (path);
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 while (gtk_tree_model_iter_next (combo_box->priv->model, &iter));
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 gtk_tree_path_free (path);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1333 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1334 gtk_combo_box_size_request (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1335 GtkRequisition *requisition)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1336 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1337 gint width, height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1338 GtkRequisition bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1339
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1340 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
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 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1343 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1344 gtk_combo_box_remeasure (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1345 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1346
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1347 gtk_combo_box_check_appearance (combo_box);
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 if (!combo_box->priv->tree_view)
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 /* menu mode */
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 if (combo_box->priv->cell_view)
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 GtkRequisition button_req, sep_req, arrow_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1356 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1357
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1358 gtk_widget_size_request (combo_box->priv->button, &button_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1359 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1360 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1361 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1362
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1363 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
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 gtk_widget_size_request (combo_box->priv->separator, &sep_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1366 gtk_widget_size_request (combo_box->priv->arrow, &arrow_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1367
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1368 height = MAX (sep_req.height, arrow_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1369 height = MAX (height, bin_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1370
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1371 width = bin_req.width + sep_req.width + arrow_req.width;
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 height += border_width + 1 + ythickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1374 width += border_width + 1 + xthickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1375
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1376 requisition->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1377 requisition->height = height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1378 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1379 else
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 GtkRequisition but_req;
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 gtk_widget_size_request (combo_box->priv->button, &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 requisition->width = bin_req.width + but_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1386 requisition->height = MAX (bin_req.height, but_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1387 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1388 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1389 else
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 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1392 GtkRequisition button_req, frame_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1393
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1394 /* sample + frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1395 *requisition = bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1396
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1397 if (combo_box->priv->cell_view_frame)
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 gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1400 requisition->width += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1401 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1402 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1403 requisition->height += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1404 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1405 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1406 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1407
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1408 /* the button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1409 gtk_widget_size_request (combo_box->priv->button, &button_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1410
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1411 requisition->height = MAX (requisition->height, button_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1412 requisition->width += button_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1413 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1414 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1417 gtk_combo_box_size_allocate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1418 GtkAllocation *allocation)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1419 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1420 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1421 GtkAllocation child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1422 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1423 gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1424
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1425 widget->allocation = *allocation;
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 gtk_combo_box_check_appearance (combo_box);
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 if (!combo_box->priv->tree_view)
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->cell_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 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1434 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1435
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1436 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1437 gtk_widget_size_allocate (combo_box->priv->button, allocation);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1438
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1439 /* set some things ready */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1440 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1441 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1442 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1443
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1444 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1445 child.y = allocation->y + border_width + 1 + ythickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1446
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1447 width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4));
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 /* handle the children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1450 gtk_widget_size_request (combo_box->priv->arrow, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1451 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1452 child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1453 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1454 child.x += width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1455 gtk_widget_size_allocate (combo_box->priv->arrow, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1456 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1457 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1458 gtk_widget_size_request (combo_box->priv->separator, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1459 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1460 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1461 child.x -= req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1462 gtk_widget_size_allocate (combo_box->priv->separator, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1463
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1464 if (is_rtl)
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 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1467 child.width = MAX(1, allocation->x + allocation->width
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1468 - (border_width + 1 + xthickness + 2) - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1469 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1470 else
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 child.width = child.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1473 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1474 child.width = MAX(1, child.width - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1475 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1476
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1477 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
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 else
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 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1482 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1483 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1484 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1485 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1486 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1487 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1488 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1489 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1490
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1491 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1492 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1493 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1494 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1495 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1496 child.width = MAX(1, allocation->width - req.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1497 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1498 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1499 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1500 else
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 /* list mode */
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 /* button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1505 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1506 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1507 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1508 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1509 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1510 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1511 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1512 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1513 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1514
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1515 /* frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1516 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1517 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1518 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1519 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1520 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1521 child.width = MAX (1, allocation->width - req.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1522 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1523
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1524 if (combo_box->priv->cell_view_frame)
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 gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child);
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 /* the sample */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1529 child.x +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1530 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1531 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1532 child.y +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1533 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1534 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1535 child.width -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1536 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1537 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1538 child.width = MAX(1,child.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1539 child.height -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1540 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1541 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1542 child.height = MAX(1,child.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1543 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1544
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1545 gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child);
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 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1550 gtk_combo_box_unset_model (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1551 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1552 if (combo_box->priv->model)
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 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1555 combo_box->priv->inserted_id);
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->deleted_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->reordered_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->changed_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1562 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1563
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1564 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1565 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1566 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1567 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1568 gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1569 (GtkCallback)gtk_widget_destroy, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1570 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1571
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1572 if (combo_box->priv->model)
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 g_object_unref (G_OBJECT (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1575 combo_box->priv->model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1576 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1577
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1578 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1579 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
1580 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1581
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1582 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1583 gtk_combo_box_forall (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1584 gboolean include_internals,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1585 GtkCallback callback,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1586 gpointer callback_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1587 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1588 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
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 if (include_internals)
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 (combo_box->priv->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1593 (* callback) (combo_box->priv->button, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1594 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1595 (* callback) (combo_box->priv->cell_view_frame, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1596 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1597
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1598 if (GTK_BIN (container)->child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1599 (* callback) (GTK_BIN (container)->child, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1600 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1601
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1602 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1603 gtk_combo_box_expose_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1604 GdkEventExpose *event)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1605 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1606 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
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 if (!combo_box->priv->tree_view)
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 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1611 combo_box->priv->button, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1612 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1613 else
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 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1616 combo_box->priv->button, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1617
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1618 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1619 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1620 combo_box->priv->cell_view_frame, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1621 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1622
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1623 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1624 GTK_BIN (widget)->child, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1625
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1626 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1629 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1630 gtk_combo_box_scroll_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1631 GdkEventScroll *event)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1632 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1633 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1634 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1635 gint items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1636
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1637 index = gtk_combo_box_get_active (combo_box);
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 if (index != -1)
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 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
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 if (event->direction == GDK_SCROLL_UP)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1644 index--;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1645 else
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1648 gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1651 return TRUE;
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
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 * menu style
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1658 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1659 cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1660 GtkCellView *cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1661 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1662 GSList *k;
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 for (k = combo_box->priv->cells; k; k = k->next)
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 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1667 ComboCellInfo *info = (ComboCellInfo *)k->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1668
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1669 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1670 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1671 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1672 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1673 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1674 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1675
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1676 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1677 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1678 info->func, info->func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1679
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1680 for (j = info->attributes; j; j = j->next->next)
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 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1683 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1684 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1685 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1686 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1687 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1691 gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1692 gboolean add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1693 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1694 GtkWidget *menu;
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 if (combo_box->priv->cell_view)
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 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1699 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1700 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1701 g_signal_connect_after (combo_box->priv->button, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1702 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1703 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1704 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1705
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1706 combo_box->priv->box = gtk_hbox_new (FALSE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1707 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1708 combo_box->priv->box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1709
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1710 combo_box->priv->separator = gtk_vseparator_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1711 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1712 combo_box->priv->separator);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1713
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1714 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
1715 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1716 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1717
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1718 gtk_widget_show_all (combo_box->priv->button);
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 else
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 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1723 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1724 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1725 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1726 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1727 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1728 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1729
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1730 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
1731 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1732 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1733 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1734 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1735
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1736 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1737 G_CALLBACK (gtk_combo_box_menu_button_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1738 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1739
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1740 /* create our funky menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1741 menu = gtk_menu_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1742 g_signal_connect (menu, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1743 G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1744 gtk_combo_box_set_popup_widget (combo_box, menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1745
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1746 /* add items */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1747 if (add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1748 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1749
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1750 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1753 gtk_combo_box_menu_fill (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1754 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1755 gint i, items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1756 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1757 GtkWidget *tmp;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1758
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1759 if (!combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1760 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1761
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1762 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1763 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1764
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1765 for (i = 0; i < items; i++)
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 GtkTreePath *path;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1768 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1769 path = gtk_tree_path_new_from_indices (i, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1770 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1771 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1772 g_snprintf(buf, sizeof(buf), "%d", i);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1773 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
1774 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1775 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
1776 path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1777 g_signal_connect (tmp, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1778 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1779 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1780
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1781 cell_view_sync_cells (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1782 GTK_CELL_VIEW (GTK_BIN (tmp)->child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1783
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1784 gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp);
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 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1787 gtk_combo_box_relayout_item (combo_box, i);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1788
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1789 gtk_widget_show (tmp);
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_tree_path_free (path);
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 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1796 gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1797 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1798 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1799 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1800 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1801 gtk_combo_box_menu_button_press, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1802
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1803 /* unparent will remove our latest ref */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1804 gtk_widget_unparent (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1805
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1806 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1807 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1808 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1809 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1810
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1811 /* changing the popup window will unref the menu and the children */
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
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 * grid
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1818 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1819 gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1820 gint index_,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1821 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1822 gint *rows)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1823 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1824 GtkTreeIter iter;
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 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
1827
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1828 if (cols)
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 (combo_box->priv->col_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1831 *cols = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1832 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1833 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1834 combo_box->priv->col_column, cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1835 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1836 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1837
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1838 if (rows)
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 (combo_box->priv->row_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1841 *rows = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1842 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1843 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1844 combo_box->priv->row_column, rows,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1845 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1846 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1847 }
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1850 menu_occupied (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1851 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1852 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1853 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1854 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1855 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1856 GList *i;
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 g_return_val_if_fail (GTK_IS_MENU (menu), TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1859 g_return_val_if_fail (left_attach < right_attach, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1860 g_return_val_if_fail (top_attach < bottom_attach, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1861
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1862 for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
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 guint l, r, b, t;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1865 gboolean h_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1866 gboolean v_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1867
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1868 gtk_container_child_get (GTK_CONTAINER (menu), i->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1869 "left_attach", &l,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1870 "right_attach", &r,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1871 "bottom_attach", &b,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1872 "top_attach", &t,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1873 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1874
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1875 /* look if this item intersects with the given coordinates */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1876 h_intersect = left_attach <= l && l <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1877 h_intersect &= left_attach <= r && r <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1878
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1879 v_intersect = top_attach <= t && t <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1880 v_intersect &= top_attach <= b && b <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1881
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1882 if (h_intersect && v_intersect)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1883 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1884 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1885
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1886 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1889 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1890 gtk_combo_box_relayout_item (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1891 gint index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1892 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1893 gint current_col = 0, current_row = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1894 gint rows, cols;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1895 GList *list, *nth;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1896 GtkWidget *item, *last;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1897 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1898
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1899 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1900 if (!GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1901 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1902
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1903 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1904 nth = g_list_nth (list, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1905 item = nth->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1906 if (nth->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1907 last = nth->prev->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1908 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1909 last = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1910 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1911
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1912 gtk_combo_box_item_get_size (combo_box, index, &cols, &rows);
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 if (combo_box->priv->col_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1915 combo_box->priv->row_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1916 last)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1917 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1918 gtk_container_child_get (GTK_CONTAINER (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1919 last,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1920 "right_attach", &current_col,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1921 "top_attach", &current_row,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1922 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1923 if (current_col + cols > combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1924 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1925 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1926 current_row++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1927 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1928 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1929 else
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 /* look for a good spot */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1932 while (1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1933 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1934 if (current_col + cols > combo_box->priv->wrap_width)
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 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1937 current_row++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1938 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1939
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1940 if (!menu_occupied (GTK_MENU (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1941 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1942 current_row, current_row + rows))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1943 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1944
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1945 current_col++;
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 }
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 /* set attach props */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1950 gtk_menu_attach (GTK_MENU (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1951 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1952 current_row, current_row + rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1953 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1954
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1955 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1956 gtk_combo_box_relayout (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1957 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1958 GList *list, *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1959 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1960
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1961 menu = combo_box->priv->popup_widget;
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 /* do nothing unless we are in menu style and realized */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1964 if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1965 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1966
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1967 /* get rid of all children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1968 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1969
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1970 for (j = g_list_last (list); j; j = j->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1971 gtk_container_remove (GTK_CONTAINER (menu), j->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1972
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1973 g_list_free (list);
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 /* and relayout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1976 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1977 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1978
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1979 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1980 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1981 gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1982 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1983 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1984 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1985 GtkComboBox *combo_box = GTK_COMBO_BOX (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 if (! GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1988 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1989
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1990 if (event->type == GDK_BUTTON_PRESS && event->button == 1)
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 combo_box->priv->popup_in_progress = TRUE;
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 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1995 combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1996
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1997 if (combo_box->priv->wrap_width == 0)
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 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2000 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2001
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2002 width = GTK_WIDGET (combo_box)->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2003 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2004
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2005 gtk_widget_set_size_request (combo_box->priv->popup_widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2006 MAX (width, requisition.width), -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2007 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2008
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2009 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2010 NULL, NULL,
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2011 #if GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2012 gtk_combo_box_menu_position,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2013 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2014 NULL,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2015 #endif
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2016 combo_box, event->button, event->time);
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2017
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2018 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2021 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2024 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2025 gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2026 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2027 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2028 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2029 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2030 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2031
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2032 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2033 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2034
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2035 index = g_list_index (GTK_MENU_SHELL (menu)->children, item);
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 gtk_combo_box_set_active (combo_box, index);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2040 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2041 gtk_combo_box_model_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2042 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2043 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2044 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2045 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2046 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2047 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2048
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2049 if (combo_box->priv->active_item >= index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2050 combo_box->priv->active_item++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2051
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2052 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2053 gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2054 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2055
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2056 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2057 gtk_combo_box_model_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2058 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2059 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2060 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2061 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2062 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2063
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2064 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2065 gtk_combo_box_menu_row_deleted (model, path, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2066
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2067 if (index == combo_box->priv->active_item)
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 gint items = gtk_tree_model_iter_n_children (model, NULL);
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 if (items == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2072 gtk_combo_box_set_active_internal (combo_box, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2073 else if (index == items)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2074 gtk_combo_box_set_active_internal (combo_box, index - 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2075 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2076 gtk_combo_box_set_active_internal (combo_box, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2077 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2078 else if (combo_box->priv->active_item > index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2079 combo_box->priv->active_item--;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2080 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2081
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2082 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2083 gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2084 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2085 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2086 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2087 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2088 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2089 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2090 gint items = gtk_tree_model_iter_n_children (model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2091 gint i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2092
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2093 for (i = 0; i < items; i++)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2094 if (new_order[i] == combo_box->priv->active_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2095 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2096 combo_box->priv->active_item = i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2097 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2098 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2099
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2100 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2101 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
2102 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2103
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2104 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2105 gtk_combo_box_model_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2106 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2107 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2108 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2109 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2110 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2111 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2112
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2113 if (index == combo_box->priv->active_item &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2114 combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2115 gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2116
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2117 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2118 gtk_combo_box_list_row_changed (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2119 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2120 gtk_combo_box_menu_row_changed (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2121 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2122
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2125 gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2126 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2127 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2128 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2129 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2130 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2131 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2132 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2133
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2134 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2135 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2136
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2137 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2138 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2139
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2140 item = gtk_cell_view_menu_item_new_from_model (model, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2141 g_signal_connect (item, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2142 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2143 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2144
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2145 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
2146
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2147 gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2148 gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2149 gtk_widget_show (item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2150 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2151
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2152 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2153 gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2154 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2155 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2156 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2157 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2158 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2159 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2160 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2161
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2162 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2163 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2164
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2165 index = gtk_tree_path_get_indices (path)[0];
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 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2168 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2169
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2170 item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2171 g_return_if_fail (GTK_IS_MENU_ITEM (item));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2172
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2173 gtk_container_remove (GTK_CONTAINER (menu), 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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2176 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2177 gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2178 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2179 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2180 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2181 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2182 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2183 GtkComboBox *combo_box = GTK_COMBO_BOX (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 gtk_combo_box_relayout (combo_box);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2188 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2189 gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2190 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2191 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2192 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2193 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2194 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2195 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2196
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2197 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2198 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2199
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2200 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2201 gtk_combo_box_relayout_item (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2202 gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2203
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2204 width = gtk_combo_box_calc_requested_width (combo_box, path);
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 if (width > combo_box->priv->width)
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 (combo_box->priv->cell_view)
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 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2211 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2212 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2213 combo_box->priv->width = width;
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 }
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 * list style
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2221 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2222 gtk_combo_box_list_setup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2223 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2224 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2225 GtkTreeSelection *sel;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2226
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2227 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2228 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2229 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2230 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2231 G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2232 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2233 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2234 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2235 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2236
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2237 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
2238 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2239 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2240 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2241 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2242
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2243 if (combo_box->priv->cell_view)
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 combo_box->priv->cell_view_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2246 gtk_widget_set_parent (combo_box->priv->cell_view_frame,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2247 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2248 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
2249 GTK_SHADOW_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2250
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2251 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
2252 &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2253
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2254 combo_box->priv->box = gtk_event_box_new ();
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 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
2257 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2258 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2259
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2260 gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2261 combo_box->priv->box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2262
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2263 gtk_widget_show_all (combo_box->priv->cell_view_frame);
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 g_signal_connect (combo_box->priv->box, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2266 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2267 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2268 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2269
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2270 combo_box->priv->tree_view = gtk_tree_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2271 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
2272 gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2273 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
2274 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2275 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2276 _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
2277 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2278 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2279 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2280 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
2281 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2282
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2283 g_signal_connect (combo_box->priv->tree_view, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2284 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2285 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2286 g_signal_connect (combo_box->priv->tree_view, "button_release_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2287 G_CALLBACK (gtk_combo_box_list_button_released),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2288 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2289 g_signal_connect (combo_box->priv->tree_view, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2290 G_CALLBACK (gtk_combo_box_list_key_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2291 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2292
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2293 combo_box->priv->column = gtk_tree_view_column_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2294 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
2295 combo_box->priv->column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2296
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2297 /* sync up */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2298 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2299 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2300 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2301 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2302
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2303 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2304 gtk_tree_view_column_pack_start (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2305 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2306 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2307 gtk_tree_view_column_pack_end (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2308 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2309
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2310 for (j = info->attributes; j; j = j->next->next)
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 gtk_tree_view_column_add_attribute (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2313 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2314 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2315 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2316 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2317 }
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 if (combo_box->priv->active_item != -1)
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 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2322
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2323 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2324 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
2325 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2326 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2327 g_snprintf(buf, sizeof(buf), "%d", combo_box->priv->active_item);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2328 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
2329 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2330 if (path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2331 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2332 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
2333 path, NULL, FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2334 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2335 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2336 }
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 /* set sample/popup widgets */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2339 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
2340
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2341 gtk_widget_show (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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2344 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2345 gtk_combo_box_list_destroy (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2346 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2347 /* disconnect signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2348 g_signal_handlers_disconnect_matched (combo_box->priv->tree_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2349 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2350 0, 0, NULL, NULL, combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2351 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2352 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2353 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2354 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2355 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2356 if (combo_box->priv->box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2357 g_signal_handlers_disconnect_matched (combo_box->priv->box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2358 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2359 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2360 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2361 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2362
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2363 /* destroy things (unparent will kill the latest ref from us)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2364 * last unref on button will destroy the arrow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2365 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2366 gtk_widget_unparent (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2367 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2368 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2369
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2370 if (combo_box->priv->cell_view)
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 g_object_set (G_OBJECT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2373 "background_set", FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2374 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2375 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2376
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2377 if (combo_box->priv->cell_view_frame)
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 gtk_widget_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2380 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2381 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2382 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2383
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2384 gtk_widget_destroy (combo_box->priv->tree_view);
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 combo_box->priv->tree_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2387 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2388 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2389
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2390 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2391 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2392 gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2393 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2394 if (combo_box->priv->tree_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2395 GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2396 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2397 gtk_grab_remove (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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2400 if (combo_box->priv->popup_window &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2401 GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2402 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2403 gtk_grab_remove (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2404 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2405 gdk_pointer_ungrab (GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2406 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2407 }
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2410 gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2411 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2412 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2413 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2414 GtkComboBox *combo_box = GTK_COMBO_BOX (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 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
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 if (ewidget == combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2419 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2420
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2421 if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2422 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2423 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2424
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2425 gtk_combo_box_popup (combo_box);
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_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2428 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2429
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2430 combo_box->priv->popup_in_progress = 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 return 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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2435 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2436 gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2437 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2438 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2439 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2440 gboolean ret;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2441 GtkTreePath *path = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2442
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2443 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
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 gboolean popup_in_progress = FALSE;
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 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
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 if (combo_box->priv->popup_in_progress)
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 popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2452 combo_box->priv->popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2453 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2454
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2455 if (ewidget != combo_box->priv->tree_view)
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->button &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2458 !popup_in_progress &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2459 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2460 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2461 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2462 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2463 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2464
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2465 /* released outside treeview */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2466 if (ewidget != combo_box->priv->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2467 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2468 gtk_combo_box_popdown (combo_box);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2473 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2476 /* select something cool */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2477 ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2478 event->x, event->y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2479 &path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2480 NULL, NULL, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2481
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2482 if (!ret)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2483 return TRUE; /* clicked outside window? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2484
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2485 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
2486 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2487
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2488 gtk_tree_path_free (path);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2493 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2494 gtk_combo_box_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2495 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2496 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2497 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2498 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2499 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2500 gint items = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2501 gint index = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2502 gint new_index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2503
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2504 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2505 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2506
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2507 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2508 state == GDK_MOD1_MASK)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2509 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2510 gtk_combo_box_popup (combo_box);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2515 switch (event->keyval)
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 case GDK_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2518 case GDK_KP_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2519 new_index = index + 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2520 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2521 case GDK_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2522 case GDK_KP_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2523 new_index = index - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2524 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2525 case GDK_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2526 case GDK_KP_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2527 case GDK_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2528 case GDK_KP_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2529 new_index = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2530 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2531 case GDK_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2532 case GDK_KP_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2533 case GDK_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2534 case GDK_KP_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2535 new_index = items - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2536 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2537 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2538 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2539 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2540
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2541 if (items > 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2542 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
2543
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2544 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2547 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2548 gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2549 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2550 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2551 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2552 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2553 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2554
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2555 if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2556 state == GDK_MOD1_MASK)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2557 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2558 gtk_combo_box_popdown (combo_box);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2563 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2566 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2567 gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2568 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2569 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2570 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2571 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2572 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2573
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2574 if (event->keyval == GDK_Escape ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2575 ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2576 state == GDK_MOD1_MASK))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2577 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2578 /* reset active item -- this is incredibly lame and ugly */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2579 gtk_combo_box_set_active (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2580 gtk_combo_box_get_active (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2581
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2582 gtk_combo_box_popdown (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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2587 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2588 event->keyval == GDK_space || event->keyval == GDK_KP_Space)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2589 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2590 gboolean ret = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2591 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2592 GtkTreeModel *model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2593
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2594 if (combo_box->priv->model)
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 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
2597
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2598 ret = gtk_tree_selection_get_selected (sel, &model, &iter);
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 if (ret)
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 GtkTreePath *path;
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 path = gtk_tree_model_get_path (model, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2605 if (path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2606 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2607 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
2608 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2609 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2610 }
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 gtk_combo_box_popdown (combo_box);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2617 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2620 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2621 gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2622 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2623 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2624 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2625 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2626 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2627 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2628
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2629 width = gtk_combo_box_calc_requested_width (combo_box, path);
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 if (width > combo_box->priv->width)
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 (combo_box->priv->cell_view)
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 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2636 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2637 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2638 combo_box->priv->width = width;
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 }
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 * GtkCellLayout implementation
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2646 gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2647 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2648 gboolean expand)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2649 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2650 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2651 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2652 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2653
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2654 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2655 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2656
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2657 combo_box = GTK_COMBO_BOX (layout);
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 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2660 gtk_object_sink (GTK_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2661
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2662 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2663 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2664 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2665 info->pack = GTK_PACK_START;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2666
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2667 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2670 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
2671 cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2672
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2673 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2674 gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2675
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2676 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2677 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2678 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2679 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2682 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2683 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2684 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2687 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2688 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2689 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2690
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2691 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand);
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 g_list_free (list);
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 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2698 gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2699 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2700 gboolean expand)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2701 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2702 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2703 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2704 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2705
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2706 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2707 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2709 combo_box = GTK_COMBO_BOX (layout);
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 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2712 gtk_object_sink (GTK_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2713
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2714 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2715 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2716 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2717 info->pack = GTK_PACK_END;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2718
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2719 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2722 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
2723 cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2724
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2725 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2726 gtk_tree_view_column_pack_end (combo_box->priv->column, cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2727
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2728 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2729 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2730 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2731 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2734 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2735 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2736 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2739 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2740 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2741 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2742
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2743 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand);
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 g_list_free (list);
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 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2750 gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2751 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2752 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2753 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2754 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2755
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2756 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
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 combo_box = GTK_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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2761 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2762
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2763 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2764 gtk_tree_view_column_clear (combo_box->priv->column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2765
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2766 for (i = combo_box->priv->cells; i; i = i->next)
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 ComboCellInfo *info = (ComboCellInfo *)i->data;
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 gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2771 g_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2772 g_free (info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2773 i->data = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2774 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2775 g_slist_free (combo_box->priv->cells);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2776 combo_box->priv->cells = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2777
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2778 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2779 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2780 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2781 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2784 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2785 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2786 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2789 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2790 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2791 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2792
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2793 gtk_cell_layout_clear (GTK_CELL_LAYOUT (view));
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 g_list_free (list);
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 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2800 gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2801 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2802 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2803 gint column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2804 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2805 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2806 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2807 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2808
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2809 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2810 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2811
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2812 combo_box = GTK_COMBO_BOX (layout);
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 info = gtk_combo_box_get_cell_info (combo_box, cell);
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->attributes = g_slist_prepend (info->attributes,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2817 GINT_TO_POINTER (column));
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 g_strdup (attribute));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2820
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2821 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2822 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
2823 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2824
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2825 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2826 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2827 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2828
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2829 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2830 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2831 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2832 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2835 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2836 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2837 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2840 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2841 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2842 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2843
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2844 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2845 attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2846 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2847 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2850 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2853 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2854 gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2855 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2856 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2857 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2858 GDestroyNotify destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2859 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2860 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2861 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2862 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2863
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2864 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
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 combo_box = GTK_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 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2869 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2870
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2871 if (info->destroy)
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 GDestroyNotify d = 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 info->destroy = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2876 d (info->func_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2877 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2878
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2879 info->func = func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2880 info->func_data = func_data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2881 info->destroy = destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2882
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2883 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2884 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
2885
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2886 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2887 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
2888
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2889 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2890 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2891 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2892 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2895 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2896 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2897 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2900 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2901 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2902 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2903
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2904 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2905 func, func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2906 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2907 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2910 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2913 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2914 gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2915 GtkCellRenderer *cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2916 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2917 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2918 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2919 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2920 GSList *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2921
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2922 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2923 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2924
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2925 combo_box = GTK_COMBO_BOX (layout);
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 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2928 if (info)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2929 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2930 list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2931 while (list && list->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2932 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2933 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2934 list = list->next->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2935 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2936 g_slist_free (info->attributes);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2937 info->attributes = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2938 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2939
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2940 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2941 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
2942
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2943 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2944 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
2945
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2946 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2947 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2948 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2949 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2952 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2953 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2954 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2957 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2958 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2959 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2960
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2961 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell);
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 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2966 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2969 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2970 gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2971 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2972 gint position)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2973 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2974 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2975 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2976 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2977 GSList *link;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2978
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2979 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2980 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2981
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2982 combo_box = GTK_COMBO_BOX (layout);
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 info = gtk_combo_box_get_cell_info (combo_box, cell);
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 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2987 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2988
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2989 link = g_slist_find (combo_box->priv->cells, info);
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 g_return_if_fail (link != NULL);
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 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
2994 combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2995 position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2996
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2997 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2998 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2999 cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3000
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3001 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3002 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3003 cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3004
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3005 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3006 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3007 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3008 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3011 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3012 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3013 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3016 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3017 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3018 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3019
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3020 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position);
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 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3025 gtk_widget_queue_draw (GTK_WIDGET (combo_box));
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
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 * public API
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
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 * gtk_combo_box_new:
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 * Creates a new empty #GtkComboBox.
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 * Return value: A new #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 * Since: 2.4
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 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3042 gtk_combo_box_new (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3043 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3044 return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL));
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
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 * gtk_combo_box_new_with_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3049 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3050 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3051 * Creates a new #GtkComboBox with the model initialized to @model.
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 * Return value: A new #GtkComboBox.
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 * Since: 2.4
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 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3058 gtk_combo_box_new_with_model (GtkTreeModel *model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3059 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3060 GtkComboBox *combo_box;
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 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
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 combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3065 "model", model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3066 NULL));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3067
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3068 return GTK_WIDGET (combo_box);
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
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 * gtk_combo_box_set_wrap_width:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3073 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3074 * @width: Preferred number of columns.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3075 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3076 * 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
3077 * 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
3078 * in a table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3079 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3080 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3083 gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3084 gint width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3085 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3086 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3087 g_return_if_fail (width >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3088
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3089 if (width != combo_box->priv->wrap_width)
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 combo_box->priv->wrap_width = 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 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3094 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3095
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3096 g_object_notify (G_OBJECT (combo_box), "wrap_width");
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 }
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 * gtk_combo_box_set_row_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3102 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3103 * @row_span: A column in the model passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3104 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3105 * 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
3106 * The row span column contains integers which indicate how many rows
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3107 * an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3108 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3109 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3112 gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3113 gint row_span)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3114 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3115 gint col;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3120 g_return_if_fail (row_span >= 0 && row_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3121
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3122 if (row_span != combo_box->priv->row_column)
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 combo_box->priv->row_column = row_span;
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 gtk_combo_box_relayout (combo_box);
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 g_object_notify (G_OBJECT (combo_box), "row_span_column");
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 }
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 * gtk_combo_box_set_column_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3134 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3135 * @column_span: A column in the model passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3136 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3137 * Sets the column with column span information for @combo_box to be
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3138 * @column_span. The column span column contains integers which indicate
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3139 * how many columns an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3140 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3141 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3144 gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3145 gint column_span)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3146 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3147 gint col;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3152 g_return_if_fail (column_span >= 0 && column_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3153
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3154 if (column_span != combo_box->priv->col_column)
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 combo_box->priv->col_column = column_span;
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 gtk_combo_box_relayout (combo_box);
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 g_object_notify (G_OBJECT (combo_box), "column_span_column");
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 }
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 * gtk_combo_box_get_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3166 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3167 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3168 * 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
3169 * active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3170 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3171 * 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
3172 * -1 if there's no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3173 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3174 * Since: 2.4
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 gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3177 gtk_combo_box_get_active (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3178 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3179 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
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 return combo_box->priv->active_item;
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
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 * gtk_combo_box_set_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3186 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3187 * @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
3188 * no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3189 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3190 * 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
3191 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3192 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3195 gtk_combo_box_set_active (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3196 gint index_)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3197 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3198 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3199 /* -1 means "no item selected" */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3200 g_return_if_fail (index_ >= -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3201
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3202 if (combo_box->priv->active_item == index_)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3203 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3204
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3205 gtk_combo_box_set_active_internal (combo_box, index_);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3208 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3209 gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3210 gint index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3211 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3212 GtkTreePath *path;
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 combo_box->priv->active_item = index;
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 if (index == -1)
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 (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3219 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
3220 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3221 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3222 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
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 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3225 gtk_menu_set_active (menu, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3226 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3227
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3228 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3229 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
3230 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3231 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3232 {
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3233 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3234 path = gtk_tree_path_new_from_indices (index, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3235 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3236 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3237 g_snprintf(buf, sizeof(buf), "%d", index);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3238 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3239 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3240
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3241 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3242 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
3243 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3244 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3245 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
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 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3248 gtk_menu_set_active (GTK_MENU (menu), index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3249 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3250
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3251 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3252 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
3253
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3254 gtk_tree_path_free (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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3257 g_signal_emit_by_name (combo_box, "changed", NULL, NULL);
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
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 * gtk_combo_box_get_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3263 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3264 * @iter: The uninitialized #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3265 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3266 * Sets @iter to point to the current active item, if it exists.
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 * Return value: %TRUE, if @iter was set
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 * Since: 2.4
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 gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3273 gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3274 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3275 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3276 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3277 gint active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3278 gboolean retval;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3279 #if !GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3280 char buf[32];
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3281 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3282
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3283 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
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 active = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3286 if (active < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3287 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3288
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3289 #if GTK_CHECK_VERSION(2,2,0)
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3290 path = gtk_tree_path_new_from_indices (active, -1);
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3291 #else
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3292 g_snprintf(buf, sizeof(buf), "%d", active);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3293 path = gtk_tree_path_new_from_string(buf);
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10708
diff changeset
3294 #endif
10708
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3295 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
3296 iter, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3297 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3298
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3299 return retval;
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
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 * gtk_combo_box_set_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3304 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3305 * @iter: The #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3306 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3307 * Sets the current active item to be the one referenced by @iter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3308 * @iter must correspond to a path of depth one.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3309 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3310 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3313 gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3314 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3315 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3316 GtkTreePath *path;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 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
3321 g_return_if_fail (path != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3322 g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3323
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3324 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
3325 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3326 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3327
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 * gtk_combo_box_set_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3330 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3331 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3332 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3333 * 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
3334 * 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
3335 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3336 * 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
3337 * 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
3338 * different cell renderers for the new model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3339 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3340 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3343 gtk_combo_box_set_model (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3344 GtkTreeModel *model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3345 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3346 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 if (!model)
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 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3351 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3352 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3353
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3354 g_return_if_fail (GTK_IS_TREE_MODEL (model));
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 if (model == combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3357 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3358
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3359 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3360 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3361
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3362 combo_box->priv->model = model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3363 g_object_ref (G_OBJECT (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3364
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3365 combo_box->priv->inserted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3366 g_signal_connect (combo_box->priv->model, "row_inserted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3367 G_CALLBACK (gtk_combo_box_model_row_inserted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3368 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3369 combo_box->priv->deleted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3370 g_signal_connect (combo_box->priv->model, "row_deleted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3371 G_CALLBACK (gtk_combo_box_model_row_deleted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3372 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3373 combo_box->priv->reordered_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3374 g_signal_connect (combo_box->priv->model, "rows_reordered",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3375 G_CALLBACK (gtk_combo_box_model_rows_reordered),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3376 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3377 combo_box->priv->changed_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3378 g_signal_connect (combo_box->priv->model, "row_changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3379 G_CALLBACK (gtk_combo_box_model_row_changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3380 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3381
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3382 if (combo_box->priv->tree_view)
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 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3385 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
3386 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3387 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3388 else
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 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3391 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3392 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3393
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3394 }
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3397 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
3398 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3399 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3400
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 * gtk_combo_box_get_model
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3403 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3404 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3405 * Returns the #GtkTreeModel which is acting as data source for @combo_box.
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 * Return value: A #GtkTreeModel which was passed during construction.
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 * Since: 2.4
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 GtkTreeModel *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3412 gtk_combo_box_get_model (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3413 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3414 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
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 return combo_box->priv->model;
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
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 /* convenience API for simple text combos */
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3423 * gtk_combo_box_new_text:
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 * Convenience function which constructs a new text combo box, which is a
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3426 * #GtkComboBox just displaying strings. If you use this function to create
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3427 * 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
3428 * following convenience functions: gtk_combo_box_append_text(),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3429 * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3430 * gtk_combo_box_remove_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3431 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3432 * Return value: A new text combo box.
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 * Since: 2.4
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 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3437 gtk_combo_box_new_text (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3438 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3439 GtkWidget *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3440 GtkCellRenderer *cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3441 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3442
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3443 store = gtk_list_store_new (1, G_TYPE_STRING);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3444 combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3445 g_object_unref (store);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3446
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3447 cell = gtk_cell_renderer_text_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3448 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3449 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3450 "text", 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3451 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3452
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3453 return combo_box;
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
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 * gtk_combo_box_append_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3458 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3459 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3460 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3461 * 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
3462 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3463 * gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3464 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3465 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3468 gtk_combo_box_append_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3469 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3470 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3471 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3472 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3473
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3474 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3475 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3476 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3477
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3478 store = GTK_LIST_STORE (combo_box->priv->model);
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 gtk_list_store_append (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3481 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3482 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3483
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 * gtk_combo_box_insert_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3486 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3487 * @position: An index to insert @text.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3488 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3489 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3490 * 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
3491 * Note that you can only use this function with combo boxes constructed
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3492 * with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3493 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3494 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3497 gtk_combo_box_insert_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3498 gint position,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3499 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3500 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3501 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3502 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3503
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3504 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3505 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3506 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3507 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3508
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3509 store = GTK_LIST_STORE (combo_box->priv->model);
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 gtk_list_store_insert (store, &iter, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3512 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3513 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3514
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 * gtk_combo_box_prepend_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3517 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3518 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3519 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3520 * 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
3521 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3522 * gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3523 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3524 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3527 gtk_combo_box_prepend_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3528 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3529 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3530 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3531 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3532
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3533 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3534 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3535 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3536
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3537 store = GTK_LIST_STORE (combo_box->priv->model);
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 gtk_list_store_prepend (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3540 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3541 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3542
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 * gtk_combo_box_remove_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3545 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3546 * @position: Index of the item to remove.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3547 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3548 * 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
3549 * this function with combo boxes constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3550 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3551 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3554 gtk_combo_box_remove_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3555 gint position)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3556 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3557 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3558 GtkListStore *store;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3559
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3560 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3561 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3562 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3563
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3564 store = GTK_LIST_STORE (combo_box->priv->model);
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 if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3567 NULL, position))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3568 gtk_list_store_remove (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3569 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3570
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3573 gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3574 gboolean group_cycling)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3575 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3576 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
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 gtk_widget_grab_focus (combo_box->priv->button);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3583 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3584 gtk_combo_box_destroy (GtkObject *object)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3585 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3586 GtkComboBox *combo_box = GTK_COMBO_BOX (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 gtk_combo_box_popdown (combo_box);
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 combo_box->priv->destroying = 1;
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 GTK_OBJECT_CLASS (parent_class)->destroy (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3593 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3594
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3595 combo_box->priv->destroying = 0;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3598 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3599 gtk_combo_box_finalize (GObject *object)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3600 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3601 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3602 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3603
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3604 if (GTK_IS_MENU (combo_box->priv->popup_widget))
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 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3607 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3608 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3609 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3610
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3611 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3612 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3613
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3614 if (combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3615 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3616
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3617 gtk_combo_box_unset_model (combo_box);
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 for (i = combo_box->priv->cells; i; i = i->next)
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 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3622 GSList *list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3623
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3624 if (info->destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3625 info->destroy (info->func_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3626
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3627 while (list && list->next)
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 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3630 list = list->next->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3631 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3632 g_slist_free (info->attributes);
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_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3635 g_free (info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3636 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3637 g_slist_free (combo_box->priv->cells);
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_free (combo_box->priv);
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_OBJECT_CLASS (parent_class)->finalize (object);
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
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 * 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
3647 * and is needed to provide gtk_menu_attach()
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3648 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3649
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3650 typedef struct
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 gint left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3653 gint right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3654 gint top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3655 gint bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3656 gint effective_left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3657 gint effective_right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3658 gint effective_top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3659 gint effective_bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3660 } AttachInfo;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3661
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3662 #define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
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 static AttachInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3665 get_attach_info (GtkWidget *child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3666 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3667 GObject *object = G_OBJECT (child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3668 AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3669
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3670 if (!ai)
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 ai = g_new0 (AttachInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3673 g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3674 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3675
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3676 return ai;
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
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 * gtk_menu_attach:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3681 * @menu: a #GtkMenu.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3682 * @child: a #GtkMenuItem.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3683 * @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
3684 * @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
3685 * @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
3686 * @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
3687 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3688 * 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
3689 * an item will occupy is specified by @left_attach, @right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3690 * @top_attach and @bottom_attach. These each represent the leftmost,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3691 * rightmost, uppermost and lower column and row numbers of the table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3692 * (Columns and rows are indexed from zero).
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3693 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3694 * Note that this function is not related to gtk_menu_detach().
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 * Since: 2.4
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3699 gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3700 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3701 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3702 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3703 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3704 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3705 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3706 GtkMenuShell *menu_shell;
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 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3709 g_return_if_fail (GTK_IS_MENU_ITEM (child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3710 g_return_if_fail (child->parent == NULL ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3711 child->parent == GTK_WIDGET (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3712 g_return_if_fail (left_attach < right_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3713 g_return_if_fail (top_attach < bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3714
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3715 menu_shell = GTK_MENU_SHELL (menu);
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 if (!child->parent)
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 AttachInfo *ai = get_attach_info (child);
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 ai->left_attach = left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3722 ai->right_attach = right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3723 ai->top_attach = top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3724 ai->bottom_attach = bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3725
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3726 menu_shell->children = g_list_append (menu_shell->children, child);
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 gtk_widget_set_parent (child, GTK_WIDGET (menu));
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 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3731 menu_queue_resize (menu);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3734 else
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 gtk_container_child_set (GTK_CONTAINER (child->parent), child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3737 "left_attach", left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3738 "right_attach", right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3739 "top_attach", top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3740 "bottom_attach", bottom_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3741 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3742 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3743 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3744 #endif /* Gtk 2.4 */