annotate src/gtkcombobox.c @ 11642:58bc500cf226

[gaim-migrate @ 13919] sf patch #1324285, from Casey Harkins fix "sounds while away" in HEAD This patch adds a GaimAccount as a parameter to the sound playing functions, allowing the caller to specify the account the sound is related to. If the account is not NULL and the while_away preference is not set, then the account is checked to see if it is away, if so, the sound is not played. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 12 Oct 2005 02:27:32 +0000
parents d0d1d631ed49
children 8cb75ba77f9d
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>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
46
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
47 #include <gdk/gdkkeysyms.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
48
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
49 #include <gobject/gvaluecollector.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
50
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
51 #include <string.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
52 #include <stdarg.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
53
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
54 #ifdef ENABLE_NLS
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
55 # include <libintl.h>
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
56 # define _(x) gettext(x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
57 # ifdef gettext_noop
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
58 # define N_(String) gettext_noop (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
59 # else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
60 # define N_(String) (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
61 # endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
62 #else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
63 # define N_(String) (String)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
64 # define _(x) (x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
65 #endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
66
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
67 /* WELCOME, to THE house of evil code */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
68
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
69 typedef struct _ComboCellInfo ComboCellInfo;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
70 struct _ComboCellInfo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
71 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
72 GtkCellRenderer *cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
73 GSList *attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
74
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
75 GtkCellLayoutDataFunc func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
76 gpointer func_data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
77 GDestroyNotify destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
78
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
79 guint expand : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
80 guint pack : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
81 };
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 struct _GtkComboBoxPrivate
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
84 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
85 GtkTreeModel *model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
86
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
87 gint col_column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
88 gint row_column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
89
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
90 gint wrap_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
91
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
92 gint active_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
93
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
94 GtkWidget *tree_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
95 GtkTreeViewColumn *column;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
96
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
97 GtkWidget *cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
98 GtkWidget *cell_view_frame;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
99
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
100 GtkWidget *button;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
101 GtkWidget *box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
102 GtkWidget *arrow;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
103 GtkWidget *separator;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
104
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
105 GtkWidget *popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
106 GtkWidget *popup_window;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
107 GtkWidget *popup_frame;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
108
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
109 guint inserted_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
110 guint deleted_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
111 guint reordered_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
112 guint changed_id;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
113
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
114 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
115 GSList *cells;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
116
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
117 guint popup_in_progress : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
118 guint destroying : 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
119 };
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 /* While debugging this evil code, I have learned that
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
122 * there are actually 4 modes to this widget, which can
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
123 * be characterized as follows
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
124 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
125 * 1) menu mode, no child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
126 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
127 * tree_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
128 * cell_view -> GtkCellView, regular child
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
129 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
130 * button -> GtkToggleButton set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
131 * box -> child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
132 * arrow -> child of box
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
133 * separator -> child of box
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
134 * popup_widget -> GtkMenu
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
135 * popup_window -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
136 * popup_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
137 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
138 * 2) menu mode, child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
139 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
140 * tree_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
141 * cell_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
142 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
143 * button -> GtkToggleButton set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
144 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
145 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
146 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
147 * popup_widget -> GtkMenu
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
148 * popup_window -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
149 * popup_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
150 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
151 * 3) list mode, no child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
152 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
153 * tree_view -> GtkTreeView, child of popup_frame
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
154 * cell_view -> GtkCellView, regular child
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
155 * cell_view_frame -> GtkFrame, set parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
156 * button -> GtkToggleButton, set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
157 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
158 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
159 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
160 * popup_widget -> tree_view
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
161 * popup_window -> GtkWindow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
162 * popup_frame -> GtkFrame, child of popup_window
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
163 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
164 * 4) list mode, child added
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
165 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
166 * tree_view -> GtkTreeView, child of popup_frame
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
167 * cell_view -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
168 * cell_view_frame -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
169 * button -> GtkToggleButton, set_parent to combo
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
170 * box -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
171 * arrow -> GtkArrow, child of button
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
172 * separator -> NULL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
173 * popup_widget -> tree_view
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
174 * popup_window -> GtkWindow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
175 * popup_frame -> GtkFrame, child of popup_window
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
176 *
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 enum {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
180 CHANGED,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
181 LAST_SIGNAL
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
182 };
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 enum {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
185 PROP_0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
186 PROP_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
187 PROP_WRAP_WIDTH,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
188 PROP_ROW_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
189 PROP_COLUMN_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
190 PROP_ACTIVE
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
191 };
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 static GtkBinClass *parent_class = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
194 static guint combo_box_signals[LAST_SIGNAL] = {0,};
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
195
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
196 #define BONUS_PADDING 4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
197
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 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
200 static void gtk_combo_box_class_init (GtkComboBoxClass *klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
201 static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
202 static void gtk_combo_box_init (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
203 static void gtk_combo_box_finalize (GObject *object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
204 static void gtk_combo_box_destroy (GtkObject *object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
205
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
206 static void gtk_combo_box_set_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
207 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
208 const GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
209 GParamSpec *spec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
210 static void gtk_combo_box_get_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
211 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
212 GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
213 GParamSpec *spec);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
214
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
215 static void gtk_combo_box_state_changed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
216 GtkStateType previous);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
217 static void gtk_combo_box_style_set (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
218 GtkStyle *previous);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
219 static void gtk_combo_box_button_toggled (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
220 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
221 static void gtk_combo_box_add (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
222 GtkWidget *widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
223 static void gtk_combo_box_remove (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
224 GtkWidget *widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
225
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
226 static ComboCellInfo *gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
227 GtkCellRenderer *cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
228
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
229 static void gtk_combo_box_menu_show (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
230 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
231 static void gtk_combo_box_menu_hide (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
232 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
233
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
234 static void gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
235 GtkWidget *popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
236 static void gtk_combo_box_menu_position_below (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
237 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
238 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
239 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
240 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
241 static void gtk_combo_box_menu_position_over (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
242 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
243 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
244 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
245 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
246 static void gtk_combo_box_menu_position (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
247 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
248 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
249 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
250 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
251
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
252 static gint gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
253 GtkTreePath *path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
254 static void gtk_combo_box_remeasure (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
255
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
256 static void gtk_combo_box_unset_model (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
257
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
258 static void gtk_combo_box_size_request (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
259 GtkRequisition *requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
260 static void gtk_combo_box_size_allocate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
261 GtkAllocation *allocation);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
262 static void gtk_combo_box_forall (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
263 gboolean include_internals,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
264 GtkCallback callback,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
265 gpointer callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
266 static gboolean gtk_combo_box_expose_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
267 GdkEventExpose *event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
268 static gboolean gtk_combo_box_scroll_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
269 GdkEventScroll *event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
270 static void gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
271 gint index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
272 static gboolean gtk_combo_box_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
273 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
274 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
275
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
276 /* listening to the model */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
277 static void gtk_combo_box_model_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
278 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
279 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
280 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
281 static void gtk_combo_box_model_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
282 GtkTreePath *path,
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_rows_reordered (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 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
287 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
288 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
289 static void gtk_combo_box_model_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
290 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
291 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
292 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
293
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
294 /* list */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
295 static void gtk_combo_box_list_position (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
296 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
297 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
298 gint *width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
299 gint *height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
300 static void gtk_combo_box_list_setup (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
301 static void gtk_combo_box_list_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
302
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
303 static void gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
304
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
305 static gboolean gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
306 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
307 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
308 static gboolean gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
309 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
310 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
311 static gboolean gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
312 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
313 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
314
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
315 static void gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
316 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
317 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
318 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
319
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
320 /* menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
321 static void gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
322 gboolean add_children);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
323 static void gtk_combo_box_menu_fill (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
324 static void gtk_combo_box_menu_destroy (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
325
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
326 static void gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
327 gint index,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
328 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
329 gint *rows);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
330 static void gtk_combo_box_relayout_item (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 static void gtk_combo_box_relayout (GtkComboBox *combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
333
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
334 static gboolean gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
335 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
336 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
337 static void gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
338 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
339 static void gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
340 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
341 GtkTreeIter *iter,
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_deleted (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 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
346 static void gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
347 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
348 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
349 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
350 gpointer user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
351 static void gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
352 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
353 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
354 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
355 static gboolean gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
356 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
357 gpointer data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
358
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
359 /* cell layout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
360 static void gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
361 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
362 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
363 static void gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
364 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
365 gboolean expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
366 static void gtk_combo_box_cell_layout_clear (GtkCellLayout *layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
367 static void gtk_combo_box_cell_layout_add_attribute (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 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
370 gint column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
371 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
372 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
373 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
374 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
375 GDestroyNotify destroy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
376 static void gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
377 GtkCellRenderer *cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
378 static void gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
379 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
380 gint position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
381 static gboolean gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
382 gboolean group_cycling);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
383
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
384 static void cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
385 GtkCellView *cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
386
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
387 #if !GTK_CHECK_VERSION(2,4,0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
388 static void gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
389 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
390 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
391 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
392 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
393 guint bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
394 #endif
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
395
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
396 GType
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
397 gtk_combo_box_get_type (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
398 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
399 static GType combo_box_type = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
400
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
401 if (!combo_box_type)
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 const GTypeInfo combo_box_info =
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 sizeof (GtkComboBoxClass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
406 NULL, /* base_init */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
407 NULL, /* base_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
408 (GClassInitFunc) gtk_combo_box_class_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
409 NULL, /* class_finalize */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
410 NULL, /* class_data */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
411 sizeof (GtkComboBox),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
412 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
413 (GInstanceInitFunc) gtk_combo_box_init
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
414 };
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
415
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
416 static const GInterfaceInfo cell_layout_info =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
417 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
418 (GInterfaceInitFunc) gtk_combo_box_cell_layout_init,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
419 NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
420 NULL
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
423 combo_box_type = g_type_register_static (GTK_TYPE_BIN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
424 "GaimGtkComboBox",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
425 &combo_box_info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
426 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
427
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
428 g_type_add_interface_static (combo_box_type,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
429 GTK_TYPE_CELL_LAYOUT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
430 &cell_layout_info);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
433 return combo_box_type;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
434 }
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 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
437 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
438 gtk_combo_box_class_init (GtkComboBoxClass *klass)
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 GObjectClass *object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
441 GtkBindingSet *binding_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
442 GtkObjectClass *gtk_object_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
443 GtkContainerClass *container_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
444 GtkWidgetClass *widget_class;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
445
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
446 binding_set = gtk_binding_set_by_class (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
447
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
448 container_class = (GtkContainerClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
449 container_class->forall = gtk_combo_box_forall;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
450 container_class->add = gtk_combo_box_add;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
451 container_class->remove = gtk_combo_box_remove;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
452
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
453 widget_class = (GtkWidgetClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
454 widget_class->size_allocate = gtk_combo_box_size_allocate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
455 widget_class->size_request = gtk_combo_box_size_request;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
456 widget_class->expose_event = gtk_combo_box_expose_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
457 widget_class->scroll_event = gtk_combo_box_scroll_event;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
458 widget_class->mnemonic_activate = gtk_combo_box_mnemonic_activate;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
459 widget_class->style_set = gtk_combo_box_style_set;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
460 widget_class->state_changed = gtk_combo_box_state_changed;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
461
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
462 gtk_object_class = (GtkObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
463 gtk_object_class->destroy = gtk_combo_box_destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
464
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
465 object_class = (GObjectClass *)klass;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
466 object_class->finalize = gtk_combo_box_finalize;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
467 object_class->set_property = gtk_combo_box_set_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
468 object_class->get_property = gtk_combo_box_get_property;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
469
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
470 parent_class = g_type_class_peek_parent (klass);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
471
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
472 /* signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
473 combo_box_signals[CHANGED] =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
474 g_signal_new ("changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
475 G_OBJECT_CLASS_TYPE (klass),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
476 G_SIGNAL_RUN_LAST,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
477 G_STRUCT_OFFSET (GtkComboBoxClass, changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
478 NULL, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
479 g_cclosure_marshal_VOID__VOID,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
480 G_TYPE_NONE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
481
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
482 /* properties */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
483 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
484 PROP_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
485 g_param_spec_object ("model",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
486 _("ComboBox model"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
487 _("The model for the combo box"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
488 GTK_TYPE_TREE_MODEL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
489 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
490
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
491 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
492 PROP_WRAP_WIDTH,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
493 g_param_spec_int ("wrap_width",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
494 _("Wrap width"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
495 _("Wrap width for layouting the items in a grid"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
496 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
497 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
498 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
499 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
500
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
501 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
502 PROP_ROW_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
503 g_param_spec_int ("row_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
504 _("Row span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
505 _("TreeModel column containing the row span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
506 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
507 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
508 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
509 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
510
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
511 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
512 PROP_COLUMN_SPAN_COLUMN,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
513 g_param_spec_int ("column_span_column",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
514 _("Column span column"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
515
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
516 _("TreeModel column containing the column span values"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
517 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
518 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
519 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
520 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
521
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
522 g_object_class_install_property (object_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
523 PROP_ACTIVE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
524 g_param_spec_int ("active",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
525 _("Active item"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
526 _("The item which is currently active"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
527 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
528 G_MAXINT,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
529 -1,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
530 G_PARAM_READWRITE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
531
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
532 gtk_widget_class_install_style_property (widget_class,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
533 g_param_spec_boolean ("appears-as-list",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
534 _("Appears as list"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
535 _("Whether combobox dropdowns should look like lists rather than menus"),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
536 FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
537 G_PARAM_READABLE));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
538 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
539
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
540 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
541 gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface)
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 iface->pack_start = gtk_combo_box_cell_layout_pack_start;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
544 iface->pack_end = gtk_combo_box_cell_layout_pack_end;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
545 iface->clear = gtk_combo_box_cell_layout_clear;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
546 iface->add_attribute = gtk_combo_box_cell_layout_add_attribute;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
547 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
548 iface->clear_attributes = gtk_combo_box_cell_layout_clear_attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
549 iface->reorder = gtk_combo_box_cell_layout_reorder;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
550 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
551
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
552 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
553 gtk_combo_box_init (GtkComboBox *combo_box)
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 combo_box->priv = g_new0(GtkComboBoxPrivate,1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
556
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
557 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
558 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
559 GTK_BIN (combo_box)->child = combo_box->priv->cell_view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
560 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
562 combo_box->priv->width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
563 combo_box->priv->wrap_width = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
564
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
565 combo_box->priv->active_item = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
566 combo_box->priv->col_column = -1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
567 combo_box->priv->row_column = -1;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
570 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
571 gtk_combo_box_set_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
572 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
573 const GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
574 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
575 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
576 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
577
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
578 switch (prop_id)
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 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
581 gtk_combo_box_set_model (combo_box, g_value_get_object (value));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
582 break;
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_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
585 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
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_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
589 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
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_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
593 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
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_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
597 gtk_combo_box_set_active (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 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
601 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
602 }
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
605 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
606 gtk_combo_box_get_property (GObject *object,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
607 guint prop_id,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
608 GValue *value,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
609 GParamSpec *pspec)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
610 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
611 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
612
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
613 switch (prop_id)
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 case PROP_MODEL:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
616 g_value_set_object (value, combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
617 break;
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_WRAP_WIDTH:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
620 g_value_set_int (value, combo_box->priv->wrap_width);
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_ROW_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
624 g_value_set_int (value, combo_box->priv->row_column);
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_COLUMN_SPAN_COLUMN:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
628 g_value_set_int (value, combo_box->priv->col_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_ACTIVE:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
632 g_value_set_int (value, gtk_combo_box_get_active (combo_box));
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 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
636 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
640
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
641 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
642 gtk_combo_box_state_changed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
643 GtkStateType previous)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
646
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
647 if (GTK_WIDGET_REALIZED (widget))
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 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
650 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
651 &widget->style->base[GTK_WIDGET_STATE (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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
654 gtk_widget_queue_draw (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
655 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
658 gtk_combo_box_check_appearance (GtkComboBox *combo_box)
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 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
661
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
662 /* 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
663 * unix style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
664 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
665 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
666 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
667 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
668 gtk_widget_style_get (GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
669 "appears-as-list", &appears_as_list,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
670 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
671
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
672 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
673 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
674 /* Destroy all the menu mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
675 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
676 gtk_combo_box_menu_destroy (combo_box);
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 /* Create the list mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
679 if (!GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
680 gtk_combo_box_list_setup (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 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
683 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
684 /* Destroy all the list mode widgets, if they exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
685 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
686 gtk_combo_box_list_destroy (combo_box);
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 /* Create the menu mode widgets, if they don't already exist. */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
689 if (!GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
690 gtk_combo_box_menu_setup (combo_box, TRUE);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
693
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
694 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
695 gtk_combo_box_style_set (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
696 GtkStyle *previous)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
699
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
700 gtk_combo_box_check_appearance (combo_box);
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 if (combo_box->priv->tree_view && combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
703 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
704 &widget->style->base[GTK_WIDGET_STATE (widget)]);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
707 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
708 gtk_combo_box_button_toggled (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
709 gpointer data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
712
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
713 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
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 if (!combo_box->priv->popup_in_progress)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
716 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
717 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
718 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
719 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
720 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
723 gtk_combo_box_add (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
724 GtkWidget *widget)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
727
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
728 if (combo_box->priv->cell_view && combo_box->priv->cell_view->parent)
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 gtk_widget_unparent (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
731 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
732 gtk_widget_queue_resize (GTK_WIDGET (container));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
735 gtk_widget_set_parent (widget, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
736 GTK_BIN (container)->child = widget;
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 if (combo_box->priv->cell_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
739 widget != combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
740 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
741 /* since the cell_view was unparented, it's gone now */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
742 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
743
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
744 if (!combo_box->priv->tree_view && combo_box->priv->separator)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
745 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
746 gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
747 combo_box->priv->separator);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
748 combo_box->priv->separator = NULL;
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_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
751 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
752 else if (combo_box->priv->cell_view_frame)
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_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
755 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
756 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
757 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
758 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
759
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
760 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
761 gtk_combo_box_remove (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
762 GtkWidget *widget)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
765 gboolean appears_as_list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
766
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
767 gtk_widget_unparent (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
768 GTK_BIN (container)->child = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
769
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
770 if (combo_box->priv->destroying)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
771 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
772
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
773 gtk_widget_queue_resize (GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
774
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
775 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
776 appears_as_list = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
777 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
778 appears_as_list = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
779
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
780 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
781 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
782 else if (GTK_IS_MENU (combo_box->priv->popup_widget))
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 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
785 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
786 combo_box->priv->popup_widget = NULL;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
789 if (!combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
790 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
791 combo_box->priv->cell_view = gtk_cell_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
792 gtk_widget_set_parent (combo_box->priv->cell_view, GTK_WIDGET (container));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
793 GTK_BIN (container)->child = 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 gtk_widget_show (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
796 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
797 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
798 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
799 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
800
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
801
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
802 if (appears_as_list)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
803 gtk_combo_box_list_setup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
804 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
805 gtk_combo_box_menu_setup (combo_box, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
806
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
807 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
808 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
809
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
810 static ComboCellInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
811 gtk_combo_box_get_cell_info (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
812 GtkCellRenderer *cell)
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 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
815
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
816 for (i = combo_box->priv->cells; i; i = i->next)
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 ComboCellInfo *info = (ComboCellInfo *)i->data;
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 if (info && info->cell == cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
821 return info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
822 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
823
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
824 return NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
825 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
828 gtk_combo_box_menu_show (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
829 gpointer user_data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
832
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
833 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
834 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
835 combo_box->priv->popup_in_progress = FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
838 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
839 gtk_combo_box_menu_hide (GtkWidget *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
840 gpointer user_data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
843
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
844 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
845 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
846 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
847
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
848 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
849 gtk_combo_box_detacher (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
850 GtkMenu *menu)
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 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
853
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
854 g_return_if_fail (GTK_IS_COMBO_BOX (widget));
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 combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
857 g_return_if_fail (combo_box->priv->popup_widget == (GtkWidget*) menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
858
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
859 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
860 gtk_combo_box_menu_show,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
861 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
862 g_signal_handlers_disconnect_by_func (menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
863 gtk_combo_box_menu_hide,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
864 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
865
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
866 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
867 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
868
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
869 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
870 gtk_combo_box_set_popup_widget (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
871 GtkWidget *popup)
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 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
874 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
875 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
876 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
877 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
878 else if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
879 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
880 gtk_container_remove (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
881 combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
882 g_object_unref (G_OBJECT (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
883 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
884 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
885
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
886 if (GTK_IS_MENU (popup))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
887 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
888 if (combo_box->priv->popup_window)
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 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
891 combo_box->priv->popup_window = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
892 combo_box->priv->popup_frame = NULL;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
895 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
896
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
897 g_signal_connect (popup, "show",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
898 G_CALLBACK (gtk_combo_box_menu_show), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
899 g_signal_connect (popup, "hide",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
900 G_CALLBACK (gtk_combo_box_menu_hide), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
901
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
902 gtk_menu_attach_to_widget (GTK_MENU (popup),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
903 GTK_WIDGET (combo_box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
904 gtk_combo_box_detacher);
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 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
907 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
908 if (!combo_box->priv->popup_window)
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 combo_box->priv->popup_window = gtk_window_new (GTK_WINDOW_POPUP);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
911 gtk_window_set_resizable (GTK_WINDOW (combo_box->priv->popup_window), FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
912 gtk_window_set_screen (GTK_WINDOW (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
913 gtk_widget_get_screen (GTK_WIDGET (combo_box)));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
914
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
915 combo_box->priv->popup_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
916 gtk_frame_set_shadow_type (GTK_FRAME (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
917 GTK_SHADOW_ETCHED_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
918 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_window),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
919 combo_box->priv->popup_frame);
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 gtk_widget_show (combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
922 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
923
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
924 gtk_container_add (GTK_CONTAINER (combo_box->priv->popup_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
925 popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
926 gtk_widget_show (popup);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
927 g_object_ref (G_OBJECT (popup));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
928 combo_box->priv->popup_widget = popup;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
929 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
930 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
931
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
932 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
933 gtk_combo_box_menu_position_below (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
934 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
935 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
936 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
937 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
938 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
939 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
940 gint sx, sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
941 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
942 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
943 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
944 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
945 GdkRectangle monitor;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
946
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
947 /* FIXME: is using the size request here broken? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
948 child = GTK_BIN (combo_box)->child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
949
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
950 gdk_window_get_origin (child->window, &sx, &sy);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
951
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
952 if (GTK_WIDGET_NO_WINDOW (child))
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 sx += child->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
955 sy += child->allocation.y;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
958 gtk_widget_size_request (GTK_WIDGET (menu), &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
959
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
960 if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
961 *x = sx;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
962 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
963 *x = sx + child->allocation.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
964 *y = sy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
965
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
966 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
967 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
968 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
969 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
970
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
971 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
972 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
973 else if (*x + req.width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
974 *x = monitor.x + monitor.width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
975
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
976 if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
977 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
978 else if (*y - monitor.y >= req.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
979 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
980 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
981 *y += child->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
982 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
983 *y -= req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
984
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
985 *push_in = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
986 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
987
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
988 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
989 gtk_combo_box_menu_position_over (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
990 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
991 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
992 gboolean *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
993 gpointer user_data)
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 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
996 GtkWidget *active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
997 GtkWidget *child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
998 GtkWidget *widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
999 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1000 GList *children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1001 gint screen_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1002 gint menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1003 gint menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1004 gint menu_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1005
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1006 g_return_if_fail (GTK_IS_COMBO_BOX (user_data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1007
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1008 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1009 widget = GTK_WIDGET (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1010
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1011 gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1012 menu_width = requisition.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1013
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1014 active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1015 gdk_window_get_origin (widget->window, &menu_xpos, &menu_ypos);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1016
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1017 menu_xpos += widget->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1018 menu_ypos += widget->allocation.y + widget->allocation.height / 2 - 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1019
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1020 if (active != NULL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1021 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1022 gtk_widget_get_child_requisition (active, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1023 menu_ypos -= requisition.height / 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1024 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1025
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1026 children = GTK_MENU_SHELL (combo_box->priv->popup_widget)->children;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1027 while (children)
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 child = children->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1030
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1031 if (active == child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1032 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1033
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1034 if (GTK_WIDGET_VISIBLE (child))
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 gtk_widget_get_child_requisition (child, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1037 menu_ypos -= requisition.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1038 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1039
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1040 children = children->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1041 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1042
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1043 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1044 menu_xpos = menu_xpos + widget->allocation.width - menu_width;
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 /* Clamp the position on screen */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1047 screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
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 if (menu_xpos < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1050 menu_xpos = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1051 else if ((menu_xpos + menu_width) > screen_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1052 menu_xpos -= ((menu_xpos + menu_width) - screen_width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1053
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1054 *x = menu_xpos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1055 *y = menu_ypos;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1056
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1057 *push_in = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1058 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1059
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1060 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1061 gtk_combo_box_menu_position (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1062 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1063 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1064 gint *push_in,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1065 gpointer user_data)
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 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1068 GtkWidget *menu_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1069
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1070 combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1071
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1072 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
1073 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
1074 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1075 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1076 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
1077 if (menu_item)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1078 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
1079 menu_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1080
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1081 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
1082 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1083
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1084 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1085
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1086 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1087 gtk_combo_box_list_position (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1088 gint *x,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1089 gint *y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1090 gint *width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1091 gint *height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1092 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1093 GtkWidget *sample;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1094 GdkScreen *screen;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1095 gint monitor_num;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1096 GdkRectangle monitor;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1097 GtkRequisition popup_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1098
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1099 sample = GTK_BIN (combo_box)->child;
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 *width = sample->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1102 gtk_widget_size_request (combo_box->priv->popup_window, &popup_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1103 *height = popup_req.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1104
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1105 gdk_window_get_origin (sample->window, x, y);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1106
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1107 if (combo_box->priv->cell_view_frame)
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 *x -= GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1110 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1111 *width += 2 * (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1112 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1113 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1114
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1115 if (GTK_WIDGET_NO_WINDOW (sample))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1116 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1117 *x += sample->allocation.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1118 *y += sample->allocation.y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1119 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1120
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1121 screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1122 monitor_num = gdk_screen_get_monitor_at_window (screen,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1123 GTK_WIDGET (combo_box)->window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1124 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1125
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1126 if (*x < monitor.x)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1127 *x = monitor.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1128 else if (*x + *width > monitor.x + monitor.width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1129 *x = monitor.x + monitor.width - *width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1130
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1131 if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1132 *y += sample->allocation.height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1133 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1134 *y -= *height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1135 }
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1138 * gtk_combo_box_popup:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1139 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1140 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1141 * Pops up the menu or dropdown list of @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1142 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1143 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1144 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1145 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1146 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1149 gtk_combo_box_popup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1150 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1151 gint x, y, width, height;
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 g_return_if_fail (GTK_IS_COMBO_BOX (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 if (GTK_WIDGET_MAPPED (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1156 return;
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 if (GTK_IS_MENU (combo_box->priv->popup_widget))
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 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1161 combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1162
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1163 if (combo_box->priv->wrap_width == 0)
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 GtkRequisition requisition;
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 width = GTK_WIDGET (combo_box)->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1168 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
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 gtk_widget_set_size_request (combo_box->priv->popup_widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1171 MAX (width, requisition.width), -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1172 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1173
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1174 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1175 NULL, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1176 gtk_combo_box_menu_position, combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1177 0, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1178 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1179 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1180
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1181 gtk_widget_show_all (combo_box->priv->popup_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1182 gtk_combo_box_list_position (combo_box, &x, &y, &width, &height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1183
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1184 gtk_widget_set_size_request (combo_box->priv->popup_window, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1185 gtk_window_move (GTK_WINDOW (combo_box->priv->popup_window), x, y);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1186
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1187 /* popup */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1188 gtk_widget_show (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1189
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1190 gtk_widget_grab_focus (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1191 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1192 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1193
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1194 if (!GTK_WIDGET_HAS_FOCUS (combo_box->priv->tree_view))
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 gdk_keyboard_grab (combo_box->priv->popup_window->window,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1197 FALSE, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1198 gtk_widget_grab_focus (combo_box->priv->tree_view);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1201 gtk_grab_add (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1202 gdk_pointer_grab (combo_box->priv->popup_window->window, TRUE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1203 GDK_BUTTON_PRESS_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1204 GDK_BUTTON_RELEASE_MASK |
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1205 GDK_POINTER_MOTION_MASK,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1206 NULL, NULL, GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1207
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1208 gtk_grab_add (combo_box->priv->tree_view);
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
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 * gtk_combo_box_popdown:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1213 * @combo_box: a #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1214 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1215 * Hides the menu or dropdown list of @combo_box.
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 * This function is mostly intended for use by accessibility technologies;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1218 * applications should have little use for it.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1219 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1220 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1221 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1222 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1223 gtk_combo_box_popdown (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1224 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1225 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 if (!GTK_WIDGET_REALIZED (GTK_WIDGET (combo_box)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1228 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1229
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1230 if (GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1231 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1232 gtk_menu_popdown (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1233 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1234 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1235
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1236 gtk_combo_box_list_remove_grabs (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1237 gtk_widget_hide_all (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1238 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1239 FALSE);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1242 static gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1243 gtk_combo_box_calc_requested_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1244 GtkTreePath *path)
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 gint padding;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1247 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1248
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1249 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1250 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1251 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1252 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1253 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1254 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1255
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1256 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1257 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1258
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1259 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1260 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
1261 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1262 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1263 req.width = 0;
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 return req.width + padding;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1266 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1267
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1268 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1269 gtk_combo_box_remeasure (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1270 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1271 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1272 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1273 gint padding = 0;
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->model ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1276 !gtk_tree_model_get_iter_first (combo_box->priv->model, &iter))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1277 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1278
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1279 combo_box->priv->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 path = gtk_tree_path_new_from_indices (0, -1);
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1284 gtk_widget_style_get (combo_box->priv->cell_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1285 "focus-line-width", &padding,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1286 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1287 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1288 padding = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1289
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1290 /* add some pixels for good measure */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1291 padding += BONUS_PADDING;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1292
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1293 do
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 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1296
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1297 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1298 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
1299 path, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1300 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1301 req.width = 0;
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 combo_box->priv->width = MAX (combo_box->priv->width,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1304 req.width + padding);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1305
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1306 gtk_tree_path_next (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1307 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1308 while (gtk_tree_model_iter_next (combo_box->priv->model, &iter));
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 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1311 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1312
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1313 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1314 gtk_combo_box_size_request (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1315 GtkRequisition *requisition)
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 gint width, height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1318 GtkRequisition bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1319
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1320 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1321
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1322 /* common */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1323 gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1324 gtk_combo_box_remeasure (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1325 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1326
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1327 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1328
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1329 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1330 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1331 /* menu mode */
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1334 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1335 GtkRequisition button_req, sep_req, arrow_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1336 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1337
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1338 gtk_widget_size_request (combo_box->priv->button, &button_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1339 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1340 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1341 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1342
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1343 bin_req.width = MAX (bin_req.width, combo_box->priv->width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1344
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1345 gtk_widget_size_request (combo_box->priv->separator, &sep_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1346 gtk_widget_size_request (combo_box->priv->arrow, &arrow_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1347
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1348 height = MAX (sep_req.height, arrow_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1349 height = MAX (height, bin_req.height);
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 width = bin_req.width + sep_req.width + arrow_req.width;
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 height += border_width + 1 + ythickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1354 width += border_width + 1 + xthickness * 2 + 4;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1355
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1356 requisition->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1357 requisition->height = height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1358 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1359 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1360 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1361 GtkRequisition but_req;
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 gtk_widget_size_request (combo_box->priv->button, &but_req);
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 requisition->width = bin_req.width + but_req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1366 requisition->height = MAX (bin_req.height, but_req.height);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1369 else
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 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1372 GtkRequisition button_req, frame_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1373
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1374 /* sample + frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1375 *requisition = bin_req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1376
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1377 if (combo_box->priv->cell_view_frame)
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 gtk_widget_size_request (combo_box->priv->cell_view_frame, &frame_req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1380 requisition->width += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1381 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1382 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1383 requisition->height += 2 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1384 (GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1385 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1386 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1387
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1388 /* the button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1389 gtk_widget_size_request (combo_box->priv->button, &button_req);
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 requisition->height = MAX (requisition->height, button_req.height);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1392 requisition->width += button_req.width;
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1395
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1396 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1397 gtk_combo_box_size_allocate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1398 GtkAllocation *allocation)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1399 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1400 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1401 GtkAllocation child;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1402 GtkRequisition req;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1403 gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1404
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1405 widget->allocation = *allocation;
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 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1408
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1409 if (!combo_box->priv->tree_view)
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1412 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1413 gint border_width, xthickness, ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1414 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1415
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1416 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1417 gtk_widget_size_allocate (combo_box->priv->button, allocation);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1418
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1419 /* set some things ready */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1420 border_width = GTK_CONTAINER (combo_box->priv->button)->border_width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1421 xthickness = combo_box->priv->button->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1422 ythickness = combo_box->priv->button->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1423
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1424 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1425 child.y = allocation->y + border_width + 1 + ythickness + 2;
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 width = MAX(1, allocation->width - (border_width + 1 + xthickness * 2 + 4));
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 /* handle the children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1430 gtk_widget_size_request (combo_box->priv->arrow, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1431 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1432 child.height = MAX(1, allocation->height - 2 * (child.y - allocation->y));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1433 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1434 child.x += width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1435 gtk_widget_size_allocate (combo_box->priv->arrow, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1436 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1437 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1438 gtk_widget_size_request (combo_box->priv->separator, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1439 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1440 if (!is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1441 child.x -= req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1442 gtk_widget_size_allocate (combo_box->priv->separator, &child);
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 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1445 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1446 child.x += req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1447 child.width = MAX(1, allocation->x + allocation->width
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1448 - (border_width + 1 + xthickness + 2) - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1449 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1450 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1451 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1452 child.width = child.x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1453 child.x = allocation->x + border_width + 1 + xthickness + 2;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1454 child.width = MAX(1, child.width - child.x);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1455 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1456
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1457 gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1458 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1459 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1460 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1461 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1462 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1463 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1464 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1465 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1466 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1467 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1468 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1469 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1470
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1471 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1472 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1473 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1474 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1475 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1476 child.width = MAX(1, allocation->width - req.width);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1480 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1481 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1482 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1483
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1484 /* button */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1485 gtk_widget_size_request (combo_box->priv->button, &req);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1486 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1487 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1488 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1489 child.x = allocation->x + allocation->width - req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1490 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1491 child.width = req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1492 child.height = allocation->height;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1493 gtk_widget_size_allocate (combo_box->priv->button, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1494
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1495 /* frame */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1496 if (is_rtl)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1497 child.x = allocation->x + req.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1498 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1499 child.x = allocation->x;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1500 child.y = allocation->y;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1501 child.width = MAX (1, allocation->width - req.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1502 child.height = allocation->height;
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 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1505 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1506 gtk_widget_size_allocate (combo_box->priv->cell_view_frame, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1507
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1508 /* the sample */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1509 child.x +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1510 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1511 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1512 child.y +=
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1513 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1514 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1515 child.width -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1516 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1517 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->xthickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1518 child.width = MAX(1,child.width);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1519 child.height -= 2 * (
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1520 GTK_CONTAINER (combo_box->priv->cell_view_frame)->border_width +
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1521 GTK_WIDGET (combo_box->priv->cell_view_frame)->style->ythickness);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1522 child.height = MAX(1,child.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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1525 gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1526 }
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1529 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1530 gtk_combo_box_unset_model (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1531 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1532 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1533 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1534 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1535 combo_box->priv->inserted_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1536 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1537 combo_box->priv->deleted_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1538 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1539 combo_box->priv->reordered_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1540 g_signal_handler_disconnect (combo_box->priv->model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1541 combo_box->priv->changed_id);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1542 }
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 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1545 if (!combo_box->priv->tree_view)
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 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1548 gtk_container_foreach (GTK_CONTAINER (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1549 (GtkCallback)gtk_widget_destroy, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1550 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1551
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_object_unref (G_OBJECT (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1555 combo_box->priv->model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1556 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1557
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1558 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1559 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
1560 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1562 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1563 gtk_combo_box_forall (GtkContainer *container,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1564 gboolean include_internals,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1565 GtkCallback callback,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1566 gpointer callback_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1567 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1568 GtkComboBox *combo_box = GTK_COMBO_BOX (container);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1569
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1570 if (include_internals)
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->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1573 (* callback) (combo_box->priv->button, callback_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1574 if (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1575 (* callback) (combo_box->priv->cell_view_frame, callback_data);
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 (GTK_BIN (container)->child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1579 (* callback) (GTK_BIN (container)->child, callback_data);
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 gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1583 gtk_combo_box_expose_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1584 GdkEventExpose *event)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1585 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1586 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
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 if (!combo_box->priv->tree_view)
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 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1591 combo_box->priv->button, event);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1592 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1593 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1594 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1595 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1596 combo_box->priv->button, event);
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 (combo_box->priv->cell_view_frame)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1599 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1600 combo_box->priv->cell_view_frame, event);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1603 gtk_container_propagate_expose (GTK_CONTAINER (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1604 GTK_BIN (widget)->child, 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 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1609 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1610 gtk_combo_box_scroll_event (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1611 GdkEventScroll *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 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1614 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1615 gint items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1616
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1617 index = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1618
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1619 if (index != -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1620 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1621 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
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 if (event->direction == GDK_SCROLL_UP)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1624 index--;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1625 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1626 index++;
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 gtk_combo_box_set_active (combo_box, CLAMP (index, 0, items - 1));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1629 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1630
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1631 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1634 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1635 * menu style
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1638 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1639 cell_view_sync_cells (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1640 GtkCellView *cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1641 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1642 GSList *k;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1643
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1644 for (k = combo_box->priv->cells; k; k = k->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1645 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1646 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1647 ComboCellInfo *info = (ComboCellInfo *)k->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1648
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1649 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1650 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1651 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1652 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1653 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1654 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1655
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1656 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1657 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1658 info->func, info->func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1659
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1660 for (j = info->attributes; j; j = j->next->next)
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 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1663 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1664 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1665 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1666 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1667 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1668 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1669
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1670 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1671 gtk_combo_box_menu_setup (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1672 gboolean add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1673 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1674 GtkWidget *menu;
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1677 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1678 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1679 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1680 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1681 g_signal_connect_after (combo_box->priv->button, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1682 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1683 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1684 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1685
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1686 combo_box->priv->box = gtk_hbox_new (FALSE, 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1687 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1688 combo_box->priv->box);
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 combo_box->priv->separator = gtk_vseparator_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1691 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1692 combo_box->priv->separator);
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 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
1695 gtk_container_add (GTK_CONTAINER (combo_box->priv->box),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1696 combo_box->priv->arrow);
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 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1699 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1700 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1701 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1702 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1703 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1704 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1705 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1706 G_CALLBACK (gtk_combo_box_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1707 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1708 GTK_BIN (combo_box)->child->parent);
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->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1711 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1712 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1713 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1714 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1715
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1716 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1717 G_CALLBACK (gtk_combo_box_menu_button_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1718 combo_box);
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 /* create our funky menu */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1721 menu = gtk_menu_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1722 g_signal_connect (menu, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1723 G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1724 gtk_combo_box_set_popup_widget (combo_box, menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1725
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1726 /* add items */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1727 if (add_children)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1728 gtk_combo_box_menu_fill (combo_box);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1731
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1732 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1733 gtk_combo_box_menu_fill (GtkComboBox *combo_box)
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 gint i, items;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1736 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1737 GtkWidget *tmp;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1738
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1739 if (!combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1740 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1741
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1742 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1743 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1744
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1745 for (i = 0; i < items; i++)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1746 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1747 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1748
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1749 path = gtk_tree_path_new_from_indices (i, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1750 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
1751 path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1752 g_signal_connect (tmp, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1753 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1754 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1755
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1756 cell_view_sync_cells (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1757 GTK_CELL_VIEW (GTK_BIN (tmp)->child));
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 gtk_menu_shell_append (GTK_MENU_SHELL (menu), tmp);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1760
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1761 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1762 gtk_combo_box_relayout_item (combo_box, i);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1763
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1764 gtk_widget_show (tmp);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1765
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1766 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1767 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1768 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1769
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1770 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1771 gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1772 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1773 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1774 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1775 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1776 gtk_combo_box_menu_button_press, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1777
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1778 /* unparent will remove our latest ref */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1779 gtk_widget_unparent (combo_box->priv->button);
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 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1782 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1783 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1784 combo_box->priv->separator = NULL;
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 /* changing the popup window will unref the menu and the children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1787 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1788
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1789 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1790 * grid
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1791 */
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1794 gtk_combo_box_item_get_size (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1795 gint index_,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1796 gint *cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1797 gint *rows)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1798 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1799 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1800
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1801 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
1802
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1803 if (cols)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1804 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1805 if (combo_box->priv->col_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1806 *cols = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1807 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1808 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1809 combo_box->priv->col_column, cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1810 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1811 }
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 if (rows)
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 if (combo_box->priv->row_column == -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1816 *rows = 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1817 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1818 gtk_tree_model_get (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1819 combo_box->priv->row_column, rows,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1820 -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1821 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1822 }
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1825 menu_occupied (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1826 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1827 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1828 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1829 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1830 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1831 GList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1832
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1833 g_return_val_if_fail (GTK_IS_MENU (menu), TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1834 g_return_val_if_fail (left_attach < right_attach, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1835 g_return_val_if_fail (top_attach < bottom_attach, TRUE);
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 for (i = GTK_MENU_SHELL (menu)->children; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1838 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1839 guint l, r, b, t;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1840 gboolean h_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1841 gboolean v_intersect = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1842
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1843 gtk_container_child_get (GTK_CONTAINER (menu), i->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1844 "left_attach", &l,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1845 "right_attach", &r,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1846 "bottom_attach", &b,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1847 "top_attach", &t,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1848 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1849
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1850 /* look if this item intersects with the given coordinates */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1851 h_intersect = left_attach <= l && l <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1852 h_intersect &= left_attach <= r && r <= right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1853
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1854 v_intersect = top_attach <= t && t <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1855 v_intersect &= top_attach <= b && b <= bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1856
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1857 if (h_intersect && v_intersect)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1858 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1859 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1860
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1861 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1862 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1865 gtk_combo_box_relayout_item (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1866 gint index)
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 gint current_col = 0, current_row = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1869 gint rows, cols;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1870 GList *list, *nth;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1871 GtkWidget *item, *last;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1872 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1873
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1874 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1875 if (!GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1876 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1877
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1878 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1879 nth = g_list_nth (list, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1880 item = nth->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1881 if (nth->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1882 last = nth->prev->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1883 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1884 last = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1885 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1886
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1887 gtk_combo_box_item_get_size (combo_box, index, &cols, &rows);
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 if (combo_box->priv->col_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1890 combo_box->priv->row_column == -1 &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1891 last)
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 gtk_container_child_get (GTK_CONTAINER (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1894 last,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1895 "right_attach", &current_col,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1896 "top_attach", &current_row,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1897 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1898 if (current_col + cols > combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1899 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1900 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1901 current_row++;
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1904 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1905 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1906 /* look for a good spot */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1907 while (1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1908 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1909 if (current_col + cols > combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1910 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1911 current_col = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1912 current_row++;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1915 if (!menu_occupied (GTK_MENU (menu),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1916 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1917 current_row, current_row + rows))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1918 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1919
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1920 current_col++;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1921 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1922 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1923
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1924 /* set attach props */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1925 gtk_menu_attach (GTK_MENU (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1926 current_col, current_col + cols,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1927 current_row, current_row + rows);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1930 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1931 gtk_combo_box_relayout (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1932 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1933 GList *list, *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1934 GtkWidget *menu;
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 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1937
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1938 /* do nothing unless we are in menu style and realized */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1939 if (combo_box->priv->tree_view || !GTK_IS_MENU_SHELL (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1940 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1941
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1942 /* get rid of all children */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1943 list = gtk_container_get_children (GTK_CONTAINER (menu));
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 for (j = g_list_last (list); j; j = j->prev)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1946 gtk_container_remove (GTK_CONTAINER (menu), j->data);
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 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1949
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1950 /* and relayout */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1951 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1952 }
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 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1955 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1956 gtk_combo_box_menu_button_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1957 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1958 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1959 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1960 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1961
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1962 if (! GTK_IS_MENU (combo_box->priv->popup_widget))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1963 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1964
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1965 if (event->type == GDK_BUTTON_PRESS && event->button == 1)
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 combo_box->priv->popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1968
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1969 gtk_menu_set_active (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1970 combo_box->priv->active_item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1971
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1972 if (combo_box->priv->wrap_width == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1973 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1974 GtkRequisition requisition;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1975 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1976
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1977 width = GTK_WIDGET (combo_box)->allocation.width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1978 gtk_widget_size_request (combo_box->priv->popup_widget, &requisition);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1979
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1980 gtk_widget_set_size_request (combo_box->priv->popup_widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1981 MAX (width, requisition.width), -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1982 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1983
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1984 gtk_menu_popup (GTK_MENU (combo_box->priv->popup_widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1985 NULL, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1986 gtk_combo_box_menu_position, combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1987 event->button, event->time);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1988
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1989 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1990 }
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 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1995 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1996 gtk_combo_box_menu_item_activate (GtkWidget *item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
1997 gpointer user_data)
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 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2000 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2001 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2002
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2003 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2004 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2005
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2006 index = g_list_index (GTK_MENU_SHELL (menu)->children, item);
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 gtk_combo_box_set_active (combo_box, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2009 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2010
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2011 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2012 gtk_combo_box_model_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2013 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2014 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2015 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2016 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2017 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2018 gint index = gtk_tree_path_get_indices (path)[0];
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 if (combo_box->priv->active_item >= index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2021 combo_box->priv->active_item++;
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 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2024 gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2025 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2026
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2027 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2028 gtk_combo_box_model_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2029 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2030 gpointer 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 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2033 gint index = gtk_tree_path_get_indices (path)[0];
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 if (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2036 gtk_combo_box_menu_row_deleted (model, path, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2037
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2038 if (index == combo_box->priv->active_item)
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 gint items = gtk_tree_model_iter_n_children (model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2041
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2042 if (items == 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2043 gtk_combo_box_set_active_internal (combo_box, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2044 else if (index == items)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2045 gtk_combo_box_set_active_internal (combo_box, index - 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2046 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2047 gtk_combo_box_set_active_internal (combo_box, index);
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 else 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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2053 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2054 gtk_combo_box_model_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2055 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2056 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2057 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2058 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2059 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2060 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2061 gint items = gtk_tree_model_iter_n_children (model, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2062 gint i;
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 for (i = 0; i < items; i++)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2065 if (new_order[i] == combo_box->priv->active_item)
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 combo_box->priv->active_item = i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2068 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2069 }
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 (!combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2072 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
2073 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2074
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2075 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2076 gtk_combo_box_model_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2077 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2078 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2079 gpointer user_data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2082 gint index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2083
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2084 if (index == combo_box->priv->active_item &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2085 combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2086 gtk_widget_queue_resize (GTK_WIDGET (combo_box->priv->cell_view));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2087
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2088 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2089 gtk_combo_box_list_row_changed (model, path, iter, user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2090 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2091 gtk_combo_box_menu_row_changed (model, path, iter, user_data);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2094
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2095 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2096 gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2097 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2098 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2099 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2100 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2101 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2102 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2103 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2104
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2105 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2106 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2107
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2108 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2109 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2110
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2111 item = gtk_cell_view_menu_item_new_from_model (model, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2112 g_signal_connect (item, "activate",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2113 G_CALLBACK (gtk_combo_box_menu_item_activate),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2114 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2115
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2116 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
2117
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2118 gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2119 gtk_tree_path_get_indices (path)[0]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2120 gtk_widget_show (item);
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2124 gtk_combo_box_menu_row_deleted (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2125 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2126 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2127 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2128 gint index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2129 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2130 GtkWidget *item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2131 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2132
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2133 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2134 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2135
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2136 index = gtk_tree_path_get_indices (path)[0];
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2137
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2138 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2139 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2140
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2141 item = g_list_nth_data (GTK_MENU_SHELL (menu)->children, index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2142 g_return_if_fail (GTK_IS_MENU_ITEM (item));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2143
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2144 gtk_container_remove (GTK_CONTAINER (menu), item);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2145 }
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2148 gtk_combo_box_menu_rows_reordered (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2149 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2150 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2151 gint *new_order,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2152 gpointer user_data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2153 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2154 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2155
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2156 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2157 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2158
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2159 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2160 gtk_combo_box_menu_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2161 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2162 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2163 gpointer user_data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2166 gint width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2167
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2168 if (!combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2169 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2170
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2171 if (combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2172 gtk_combo_box_relayout_item (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2173 gtk_tree_path_get_indices (path)[0]);
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 width = gtk_combo_box_calc_requested_width (combo_box, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2176
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2177 if (width > combo_box->priv->width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2178 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2179 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2180 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2181 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2182 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2183 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2184 combo_box->priv->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2185 }
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 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2189 * list style
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2190 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2191
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2192 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2193 gtk_combo_box_list_setup (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2194 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2195 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2196 GtkTreeSelection *sel;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2197
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2198 combo_box->priv->button = gtk_toggle_button_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2199 gtk_widget_set_parent (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2200 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2201 g_signal_connect (combo_box->priv->button, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2202 G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2203 g_signal_connect (combo_box->priv->button, "toggled",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2204 G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2205 g_signal_connect_after (combo_box, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2206 G_CALLBACK (gtk_combo_box_key_press), combo_box);
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 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
2209 gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2210 combo_box->priv->arrow);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2211 combo_box->priv->separator = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2212 gtk_widget_show_all (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2213
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2214 if (combo_box->priv->cell_view)
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 combo_box->priv->cell_view_frame = gtk_frame_new (NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2217 gtk_widget_set_parent (combo_box->priv->cell_view_frame,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2218 GTK_BIN (combo_box)->child->parent);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2219 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
2220 GTK_SHADOW_IN);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2221
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2222 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
2223 &GTK_WIDGET (combo_box)->style->base[GTK_WIDGET_STATE (combo_box)]);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2224
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2225 combo_box->priv->box = gtk_event_box_new ();
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 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
2228 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2229 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2230
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2231 gtk_container_add (GTK_CONTAINER (combo_box->priv->cell_view_frame),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2232 combo_box->priv->box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2233
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2234 gtk_widget_show_all (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2235
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2236 g_signal_connect (combo_box->priv->box, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2237 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2238 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2239 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2240
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2241 combo_box->priv->tree_view = gtk_tree_view_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2242 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
2243 gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2244 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
2245 FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2246 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2247 _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
2248 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2249 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2250 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2251 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
2252 combo_box->priv->model);
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 g_signal_connect (combo_box->priv->tree_view, "button_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2255 G_CALLBACK (gtk_combo_box_list_button_pressed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2256 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2257 g_signal_connect (combo_box->priv->tree_view, "button_release_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2258 G_CALLBACK (gtk_combo_box_list_button_released),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2259 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2260 g_signal_connect (combo_box->priv->tree_view, "key_press_event",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2261 G_CALLBACK (gtk_combo_box_list_key_press),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2262 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2263
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2264 combo_box->priv->column = gtk_tree_view_column_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2265 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
2266 combo_box->priv->column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2267
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2268 /* sync up */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2269 for (i = combo_box->priv->cells; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2270 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2271 GSList *j;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2272 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2273
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2274 if (info->pack == GTK_PACK_START)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2275 gtk_tree_view_column_pack_start (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2276 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2277 else if (info->pack == GTK_PACK_END)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2278 gtk_tree_view_column_pack_end (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2279 info->cell, info->expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2280
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2281 for (j = info->attributes; j; j = j->next->next)
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 gtk_tree_view_column_add_attribute (combo_box->priv->column,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2284 info->cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2285 j->data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2286 GPOINTER_TO_INT (j->next->data));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2287 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2288 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2289
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2290 if (combo_box->priv->active_item != -1)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2291 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2292 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2293
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2294 path = gtk_tree_path_new_from_indices (combo_box->priv->active_item, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2295 if (path)
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 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
2298 path, NULL, FALSE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2299 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2300 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2301 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2302
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2303 /* set sample/popup widgets */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2304 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
2305
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2306 gtk_widget_show (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2307 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2308
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2309 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2310 gtk_combo_box_list_destroy (GtkComboBox *combo_box)
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 /* disconnect signals */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2313 g_signal_handlers_disconnect_matched (combo_box->priv->tree_view,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2314 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2315 0, 0, NULL, NULL, combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2316 g_signal_handlers_disconnect_matched (combo_box->priv->button,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2317 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2318 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2319 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2320 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2321 if (combo_box->priv->box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2322 g_signal_handlers_disconnect_matched (combo_box->priv->box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2323 G_SIGNAL_MATCH_DATA,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2324 0, 0, NULL,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2325 gtk_combo_box_list_button_pressed,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2326 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2327
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2328 /* destroy things (unparent will kill the latest ref from us)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2329 * last unref on button will destroy the arrow
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2330 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2331 gtk_widget_unparent (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2332 combo_box->priv->button = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2333 combo_box->priv->arrow = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2334
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2335 if (combo_box->priv->cell_view)
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 g_object_set (G_OBJECT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2338 "background_set", FALSE,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2339 NULL);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2342 if (combo_box->priv->cell_view_frame)
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 gtk_widget_unparent (combo_box->priv->cell_view_frame);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2345 combo_box->priv->cell_view_frame = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2346 combo_box->priv->box = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2347 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2348
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2349 gtk_widget_destroy (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2350
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2351 combo_box->priv->tree_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2352 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2353 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2354
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2355 /* callbacks */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2356 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2357 gtk_combo_box_list_remove_grabs (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2358 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2359 if (combo_box->priv->tree_view &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2360 GTK_WIDGET_HAS_GRAB (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2361 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2362 gtk_grab_remove (combo_box->priv->tree_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2363 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2364
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2365 if (combo_box->priv->popup_window &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2366 GTK_WIDGET_HAS_GRAB (combo_box->priv->popup_window))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2367 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2368 gtk_grab_remove (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2369 gdk_keyboard_ungrab (GDK_CURRENT_TIME);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2370 gdk_pointer_ungrab (GDK_CURRENT_TIME);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2373
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2374 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2375 gtk_combo_box_list_button_pressed (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2376 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2377 gpointer data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2380
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2381 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
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 if (ewidget == combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2384 return TRUE;
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 if ((ewidget != combo_box->priv->button && ewidget != combo_box->priv->box) ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2387 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2388 return FALSE;
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 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2391
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2392 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2393 TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2394
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2395 combo_box->priv->popup_in_progress = TRUE;
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 return TRUE;
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2401 gtk_combo_box_list_button_released (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2402 GdkEventButton *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2403 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2404 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2405 gboolean ret;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2406 GtkTreePath *path = NULL;
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 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2409
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2410 gboolean popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2411
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2412 GtkWidget *ewidget = gtk_get_event_widget ((GdkEvent *)event);
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 if (combo_box->priv->popup_in_progress)
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 popup_in_progress = TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2417 combo_box->priv->popup_in_progress = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2418 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2419
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2420 if (ewidget != combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2421 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2422 if (ewidget == combo_box->priv->button &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2423 !popup_in_progress &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2424 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2425 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2426 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2427 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2428 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2429
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2430 /* released outside treeview */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2431 if (ewidget != combo_box->priv->button)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2432 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2433 gtk_combo_box_popdown (combo_box);
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 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2436 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2437
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2438 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2441 /* select something cool */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2442 ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2443 event->x, event->y,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2444 &path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2445 NULL, NULL, NULL);
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 if (!ret)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2448 return TRUE; /* clicked outside window? */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2449
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2450 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
2451 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2452
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2453 gtk_tree_path_free (path);
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 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2458 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2459 gtk_combo_box_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2460 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2461 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2462 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2463 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2464 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2465 gint items = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2466 gint index = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2467 gint new_index;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2468
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2469 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2470 items = gtk_tree_model_iter_n_children (combo_box->priv->model, NULL);
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 if ((event->keyval == GDK_Down || event->keyval == GDK_KP_Down) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2473 state == GDK_MOD1_MASK)
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 gtk_combo_box_popup (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2476
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2477 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2478 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2479
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2480 switch (event->keyval)
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 case GDK_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2483 case GDK_KP_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2484 new_index = index + 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2485 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2486 case GDK_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2487 case GDK_KP_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2488 new_index = index - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2489 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2490 case GDK_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2491 case GDK_KP_Page_Up:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2492 case GDK_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2493 case GDK_KP_Home:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2494 new_index = 0;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2495 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2496 case GDK_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2497 case GDK_KP_Page_Down:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2498 case GDK_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2499 case GDK_KP_End:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2500 new_index = items - 1;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2501 break;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2502 default:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2503 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2504 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2505
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2506 if (items > 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2507 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
2508
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2509 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2510 }
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 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2513 gtk_combo_box_menu_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2514 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2515 gpointer data)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2518 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2519
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2520 if ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2521 state == GDK_MOD1_MASK)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2522 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2523 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2524
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2525 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2526 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2527
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2528 return FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2529 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2530
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2531 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2532 gtk_combo_box_list_key_press (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2533 GdkEventKey *event,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2534 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2535 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2536 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2537 guint state = event->state & gtk_accelerator_get_default_mod_mask ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2538
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2539 if (event->keyval == GDK_Escape ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2540 ((event->keyval == GDK_Up || event->keyval == GDK_KP_Up) &&
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2541 state == GDK_MOD1_MASK))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2542 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2543 /* reset active item -- this is incredibly lame and ugly */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2544 gtk_combo_box_set_active (combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2545 gtk_combo_box_get_active (combo_box));
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 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2548
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2549 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2550 }
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 if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2553 event->keyval == GDK_space || event->keyval == GDK_KP_Space)
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 gboolean ret = FALSE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2556 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2557 GtkTreeModel *model = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2558
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2559 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2560 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2561 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
2562
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2563 ret = gtk_tree_selection_get_selected (sel, &model, &iter);
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 if (ret)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2566 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2567 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2568
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2569 path = gtk_tree_model_get_path (model, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2570 if (path)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2571 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2572 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
2573 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2574 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2575 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2576
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2577 gtk_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2578
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2579 return TRUE;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2580 }
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 return FALSE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2585 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2586 gtk_combo_box_list_row_changed (GtkTreeModel *model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2587 GtkTreePath *path,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2588 GtkTreeIter *iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2589 gpointer data)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2590 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2591 GtkComboBox *combo_box = GTK_COMBO_BOX (data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2592 gint width;
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 width = gtk_combo_box_calc_requested_width (combo_box, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2595
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2596 if (width > combo_box->priv->width)
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2599 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2600 gtk_widget_set_size_request (combo_box->priv->cell_view, width, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2601 gtk_widget_queue_resize (combo_box->priv->cell_view);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2602 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2603 combo_box->priv->width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2604 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2605 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2606
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2607 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2608 * GtkCellLayout implementation
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2611 gtk_combo_box_cell_layout_pack_start (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2612 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2613 gboolean expand)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2614 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2615 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2616 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2617 GtkWidget *menu;
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 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2620 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2621
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2622 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2623
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2624 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2625 gtk_object_sink (GTK_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2626
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2627 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2628 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2629 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2630 info->pack = GTK_PACK_START;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2631
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2632 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2633
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2634 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2635 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
2636 cell, expand);
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 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2639 gtk_tree_view_column_pack_start (combo_box->priv->column, cell, expand);
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 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2642 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2643 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2644 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2645
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2646 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2647 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2648 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2649 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2650
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2651 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2652 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2653 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2654 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2655
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2656 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2657 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2658 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2659 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2660 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2661
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2662 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2663 gtk_combo_box_cell_layout_pack_end (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2664 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2665 gboolean expand)
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 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2668 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2669 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2670
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2671 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2672 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2673
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2674 combo_box = GTK_COMBO_BOX (layout);
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 g_object_ref (G_OBJECT (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2677 gtk_object_sink (GTK_OBJECT (cell));
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 info = g_new0 (ComboCellInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2680 info->cell = cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2681 info->expand = expand;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2682 info->pack = GTK_PACK_END;
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 combo_box->priv->cells = g_slist_append (combo_box->priv->cells, info);
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 (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2687 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
2688 cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2689
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2690 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2691 gtk_tree_view_column_pack_end (combo_box->priv->column, 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 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2694 if (GTK_IS_MENU (menu))
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 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2697
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2698 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2699 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2700 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2701 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2702
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2703 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2704 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2705 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2706 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2707
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2708 gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (view), cell, expand);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2709 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2710 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2711 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2712 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2713
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2714 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2715 gtk_combo_box_cell_layout_clear (GtkCellLayout *layout)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2716 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2717 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2718 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2719 GSList *i;
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 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2722
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2723 combo_box = GTK_COMBO_BOX (layout);
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->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2726 gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_box->priv->cell_view));
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 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2729 gtk_tree_view_column_clear (combo_box->priv->column);
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 for (i = combo_box->priv->cells; i; i = i->next)
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 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2734
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2735 gtk_combo_box_cell_layout_clear_attributes (layout, info->cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2736 g_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2737 g_free (info);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2738 i->data = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2739 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2740 g_slist_free (combo_box->priv->cells);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2741 combo_box->priv->cells = NULL;
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 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2744 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2745 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2746 GList *i, *list;
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 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2749 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2750 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2751 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2752
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2753 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2754 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2755 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2756 view = GTK_CELL_VIEW (i->data);
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 gtk_cell_layout_clear (GTK_CELL_LAYOUT (view));
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 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2761 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2762 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2763
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2764 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2765 gtk_combo_box_cell_layout_add_attribute (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2766 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2767 const gchar *attribute,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2768 gint column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2769 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2770 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2771 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2772 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2773
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2774 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2775 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2776
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2777 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2778
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2779 info = gtk_combo_box_get_cell_info (combo_box, cell);
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 info->attributes = g_slist_prepend (info->attributes,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2782 GINT_TO_POINTER (column));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2783 info->attributes = g_slist_prepend (info->attributes,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2784 g_strdup (attribute));
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 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2787 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
2788 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2789
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2790 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2791 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2792 cell, attribute, column);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2793
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2794 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2795 if (GTK_IS_MENU (menu))
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 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2798
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2799 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2800 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2801 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2802 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2803
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2804 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2805 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2806 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2807 view = GTK_CELL_VIEW (i->data);
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 gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2810 attribute, column);
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 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2815 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2816 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2817
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2818 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2819 gtk_combo_box_cell_layout_set_cell_data_func (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2820 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2821 GtkCellLayoutDataFunc func,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2822 gpointer func_data,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2823 GDestroyNotify destroy)
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 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2826 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2827 GtkWidget *menu;
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 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2830
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2831 combo_box = GTK_COMBO_BOX (layout);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2832
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2833 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2834 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2835
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2836 if (info->destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2837 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2838 GDestroyNotify d = info->destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2839
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2840 info->destroy = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2841 d (info->func_data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2842 }
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 info->func = func;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2845 info->func_data = func_data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2846 info->destroy = destroy;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2847
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2848 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2849 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
2850
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2851 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2852 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
2853
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2854 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2855 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2856 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2857 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2858
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2859 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2860 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2861 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2862 GtkCellView *view;
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 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2865 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2866 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2867 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2868
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2869 gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (view), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2870 func, func_data, NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2871 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2872 g_list_free (list);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2873 }
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 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2876 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2877
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2878 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2879 gtk_combo_box_cell_layout_clear_attributes (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2880 GtkCellRenderer *cell)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2881 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2882 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2883 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2884 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2885 GSList *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2886
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2887 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2888 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2889
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2890 combo_box = GTK_COMBO_BOX (layout);
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 info = gtk_combo_box_get_cell_info (combo_box, cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2893 if (info)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2894 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2895 list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2896 while (list && list->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2897 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2898 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2899 list = list->next->next;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2900 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2901 g_slist_free (info->attributes);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2902 info->attributes = NULL;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2905 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2906 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
2907
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2908 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2909 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
2910
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2911 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2912 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2913 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2914 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2915
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2916 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2917 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2918 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2919 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2920
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2921 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2922 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2923 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2924 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2925
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2926 gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (view), cell);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2927 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2928 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2931 gtk_widget_queue_resize (GTK_WIDGET (combo_box));
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2934 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2935 gtk_combo_box_cell_layout_reorder (GtkCellLayout *layout,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2936 GtkCellRenderer *cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2937 gint position)
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 ComboCellInfo *info;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2940 GtkComboBox *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2941 GtkWidget *menu;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2942 GSList *link;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2943
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2944 g_return_if_fail (GTK_IS_COMBO_BOX (layout));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2945 g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2946
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2947 combo_box = GTK_COMBO_BOX (layout);
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 info = gtk_combo_box_get_cell_info (combo_box, cell);
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 g_return_if_fail (info != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2952 g_return_if_fail (position >= 0);
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 link = g_slist_find (combo_box->priv->cells, info);
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 g_return_if_fail (link != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2957
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2958 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
2959 combo_box->priv->cells = g_slist_insert (combo_box->priv->cells, info,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2960 position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2961
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2962 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2963 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->cell_view),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2964 cell, position);
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 if (combo_box->priv->column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2967 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (combo_box->priv->column),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2968 cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2969
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2970 menu = combo_box->priv->popup_widget;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2971 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2972 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2973 GList *i, *list;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2974
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2975 list = gtk_container_get_children (GTK_CONTAINER (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2976 for (i = list; i; i = i->next)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2977 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2978 GtkCellView *view;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2979
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2980 if (GTK_IS_CELL_VIEW_MENU_ITEM (i->data))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2981 view = GTK_CELL_VIEW (GTK_BIN (i->data)->child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2982 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2983 view = GTK_CELL_VIEW (i->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2984
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2985 gtk_cell_layout_reorder (GTK_CELL_LAYOUT (view), cell, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2986 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2987 g_list_free (list);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2990 gtk_widget_queue_draw (GTK_WIDGET (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2991 }
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 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2994 * public API
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2995 */
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2998 * gtk_combo_box_new:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
2999 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3000 * Creates a new empty #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3001 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3002 * Return value: A new #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3003 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3004 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3005 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3006 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3007 gtk_combo_box_new (void)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3008 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3009 return GTK_WIDGET (g_object_new (GTK_TYPE_COMBO_BOX, NULL));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3010 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3011
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3012 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3013 * gtk_combo_box_new_with_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3014 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3015 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3016 * Creates a new #GtkComboBox with the model initialized to @model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3017 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3018 * Return value: A new #GtkComboBox.
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 * Since: 2.4
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 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3023 gtk_combo_box_new_with_model (GtkTreeModel *model)
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 GtkComboBox *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 g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
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 combo_box = GTK_COMBO_BOX (g_object_new (GTK_TYPE_COMBO_BOX,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3030 "model", model,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3031 NULL));
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 return GTK_WIDGET (combo_box);
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
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 * gtk_combo_box_set_wrap_width:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3038 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3039 * @width: Preferred number of columns.
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 * 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
3042 * 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
3043 * in a table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3044 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3045 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3048 gtk_combo_box_set_wrap_width (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3049 gint width)
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3052 g_return_if_fail (width >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3053
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3054 if (width != combo_box->priv->wrap_width)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3055 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3056 combo_box->priv->wrap_width = width;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3057
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3058 gtk_combo_box_check_appearance (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3059 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3060
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3061 g_object_notify (G_OBJECT (combo_box), "wrap_width");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3062 }
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3065 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3066 * gtk_combo_box_set_row_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3067 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3068 * @row_span: A column in the model passed during construction.
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 * 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
3071 * The row span column contains integers which indicate how many rows
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3072 * an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3073 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3074 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3077 gtk_combo_box_set_row_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3078 gint row_span)
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 gint col;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3083
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3084 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3085 g_return_if_fail (row_span >= 0 && row_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3086
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3087 if (row_span != combo_box->priv->row_column)
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 combo_box->priv->row_column = row_span;
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 gtk_combo_box_relayout (combo_box);
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 g_object_notify (G_OBJECT (combo_box), "row_span_column");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3094 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3095 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3096
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 * gtk_combo_box_set_column_span_column:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3099 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3100 * @column_span: A column in the model passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3101 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3102 * Sets the column with column span information for @combo_box to be
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3103 * @column_span. The column span column contains integers which indicate
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3104 * how many columns an item should span.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3105 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3106 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3107 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3108 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3109 gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3110 gint column_span)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3111 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3112 gint col;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3113
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3114 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3115
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3116 col = gtk_tree_model_get_n_columns (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3117 g_return_if_fail (column_span >= 0 && column_span < col);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3118
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3119 if (column_span != combo_box->priv->col_column)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3120 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3121 combo_box->priv->col_column = column_span;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3122
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3123 gtk_combo_box_relayout (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3124
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3125 g_object_notify (G_OBJECT (combo_box), "column_span_column");
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3126 }
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
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 * gtk_combo_box_get_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3131 * @combo_box: A #GtkComboBox.
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 * 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
3134 * active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3135 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3136 * 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
3137 * -1 if there's no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3138 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3139 * Since: 2.4
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 gint
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3142 gtk_combo_box_get_active (GtkComboBox *combo_box)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3143 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3144 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3145
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3146 return combo_box->priv->active_item;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3147 }
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3150 * gtk_combo_box_set_active:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3151 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3152 * @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
3153 * no active item.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3154 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3155 * 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
3156 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3157 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3158 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3159 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3160 gtk_combo_box_set_active (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3161 gint index_)
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3164 /* -1 means "no item selected" */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3165 g_return_if_fail (index_ >= -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3166
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3167 if (combo_box->priv->active_item == index_)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3168 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3169
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3170 gtk_combo_box_set_active_internal (combo_box, index_);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3171 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3172
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3173 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3174 gtk_combo_box_set_active_internal (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3175 gint index)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3176 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3177 GtkTreePath *path;
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 combo_box->priv->active_item = index;
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 if (index == -1)
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 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3184 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
3185 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3186 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3187 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3188
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3189 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3190 gtk_menu_set_active (menu, -1);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3193 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3194 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
3195 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3196 else
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 path = gtk_tree_path_new_from_indices (index, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3199
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3200 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3201 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
3202 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3203 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3204 GtkMenu *menu = GTK_MENU (combo_box->priv->popup_widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3205
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3206 if (GTK_IS_MENU (menu))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3207 gtk_menu_set_active (GTK_MENU (menu), index);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3208 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3209
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3210 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3211 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
3212
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3213 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3214 }
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 g_signal_emit_by_name (combo_box, "changed", NULL, NULL);
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3219
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3220 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3221 * gtk_combo_box_get_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3222 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3223 * @iter: The uninitialized #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3224 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3225 * Sets @iter to point to the current active item, if it exists.
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 * Return value: %TRUE, if @iter was set
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3228 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3229 * Since: 2.4
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 gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3232 gtk_combo_box_get_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3233 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3234 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3235 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3236 gint active;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3237 gboolean retval;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3238
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3239 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
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 active = gtk_combo_box_get_active (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3242 if (active < 0)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3243 return FALSE;
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 path = gtk_tree_path_new_from_indices (active, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3246 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
3247 iter, path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3248 gtk_tree_path_free (path);
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 return retval;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3251 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3252
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3253 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3254 * gtk_combo_box_set_active_iter:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3255 * @combo_box: A #GtkComboBox
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3256 * @iter: The #GtkTreeIter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3257 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3258 * Sets the current active item to be the one referenced by @iter.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3259 * @iter must correspond to a path of depth one.
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 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3262 **/
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3263 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3264 gtk_combo_box_set_active_iter (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3265 GtkTreeIter *iter)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3266 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3267 GtkTreePath *path;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3268
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3269 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3270
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3271 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
3272 g_return_if_fail (path != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3273 g_return_if_fail (gtk_tree_path_get_depth (path) == 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3274
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3275 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
3276 gtk_tree_path_free (path);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3277 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3278
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3279 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3280 * gtk_combo_box_set_model:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3281 * @combo_box: A #GtkComboBox.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3282 * @model: A #GtkTreeModel.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3283 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3284 * 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
3285 * 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
3286 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3287 * 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
3288 * 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
3289 * different cell renderers for the new model.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3290 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3291 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3292 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3293 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3294 gtk_combo_box_set_model (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3295 GtkTreeModel *model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3296 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3297 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
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 if (!model)
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 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3302 return;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3303 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3304
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3305 g_return_if_fail (GTK_IS_TREE_MODEL (model));
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 if (model == combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3308 return;
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 if (combo_box->priv->model)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3311 gtk_combo_box_unset_model (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3312
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3313 combo_box->priv->model = model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3314 g_object_ref (G_OBJECT (combo_box->priv->model));
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 combo_box->priv->inserted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3317 g_signal_connect (combo_box->priv->model, "row_inserted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3318 G_CALLBACK (gtk_combo_box_model_row_inserted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3319 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3320 combo_box->priv->deleted_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3321 g_signal_connect (combo_box->priv->model, "row_deleted",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3322 G_CALLBACK (gtk_combo_box_model_row_deleted),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3323 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3324 combo_box->priv->reordered_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3325 g_signal_connect (combo_box->priv->model, "rows_reordered",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3326 G_CALLBACK (gtk_combo_box_model_rows_reordered),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3327 combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3328 combo_box->priv->changed_id =
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3329 g_signal_connect (combo_box->priv->model, "row_changed",
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3330 G_CALLBACK (gtk_combo_box_model_row_changed),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3331 combo_box);
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 if (combo_box->priv->tree_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3334 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3335 /* list mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3336 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
3337 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3338 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3339 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3340 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3341 /* menu mode */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3342 if (combo_box->priv->popup_widget)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3343 gtk_combo_box_menu_fill (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3344
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3347 if (combo_box->priv->cell_view)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3348 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
3349 combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3350 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3351
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3352 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3353 * gtk_combo_box_get_model
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3354 * @combo_box: A #GtkComboBox.
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 * Returns the #GtkTreeModel which is acting as data source for @combo_box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3357 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3358 * Return value: A #GtkTreeModel which was passed during construction.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3359 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3360 * Since: 2.4
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 GtkTreeModel *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3363 gtk_combo_box_get_model (GtkComboBox *combo_box)
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 g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3366
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3367 return combo_box->priv->model;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3368 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3369
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3370
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3371 /* convenience API for simple text combos */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3372
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3373 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3374 * gtk_combo_box_new_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3375 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3376 * Convenience function which constructs a new text combo box, which is a
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3377 * #GtkComboBox just displaying strings. If you use this function to create
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3378 * 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
3379 * following convenience functions: gtk_combo_box_append_text(),
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3380 * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3381 * gtk_combo_box_remove_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3382 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3383 * Return value: A new text combo box.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3384 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3385 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3386 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3387 GtkWidget *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3388 gtk_combo_box_new_text (void)
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 GtkWidget *combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3391 GtkCellRenderer *cell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3392 GtkListStore *store;
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 store = gtk_list_store_new (1, G_TYPE_STRING);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3395 combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3396 g_object_unref (store);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3397
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3398 cell = gtk_cell_renderer_text_new ();
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3399 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3400 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3401 "text", 0,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3402 NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3403
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3404 return combo_box;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3405 }
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3408 * gtk_combo_box_append_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3409 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3410 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3411 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3412 * 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
3413 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3414 * gtk_combo_box_new_text().
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 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3419 gtk_combo_box_append_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3420 const gchar *text)
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 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3423 GtkListStore *store;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3426 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3427 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3428
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3429 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3430
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3431 gtk_list_store_append (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3432 gtk_list_store_set (store, &iter, 0, text, -1);
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
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 * gtk_combo_box_insert_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3437 * @combo_box: A #GtkComboBox constructed using gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3438 * @position: An index to insert @text.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3439 * @text: A string.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3440 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3441 * 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
3442 * Note that you can only use this function with combo boxes constructed
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3443 * with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3444 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3445 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3448 gtk_combo_box_insert_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3449 gint position,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3450 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3451 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3452 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3453 GtkListStore *store;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3456 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3457 g_return_if_fail (position >= 0);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3458 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3459
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3460 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3461
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3462 gtk_list_store_insert (store, &iter, position);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3463 gtk_list_store_set (store, &iter, 0, text, -1);
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
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 * gtk_combo_box_prepend_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3468 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3469 * @text: A string.
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 * 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
3472 * you can only use this function with combo boxes constructed with
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3473 * gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3474 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3475 * Since: 2.4
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3476 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3477 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3478 gtk_combo_box_prepend_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3479 const gchar *text)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3480 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3481 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3482 GtkListStore *store;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3485 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3486 g_return_if_fail (text != NULL);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3487
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3488 store = GTK_LIST_STORE (combo_box->priv->model);
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 gtk_list_store_prepend (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3491 gtk_list_store_set (store, &iter, 0, text, -1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3492 }
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 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3495 * gtk_combo_box_remove_text:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3496 * @combo_box: A #GtkComboBox constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3497 * @position: Index of the item to remove.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3498 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3499 * 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
3500 * this function with combo boxes constructed with gtk_combo_box_new_text().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3501 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3502 * Since: 2.4
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 void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3505 gtk_combo_box_remove_text (GtkComboBox *combo_box,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3506 gint position)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3507 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3508 GtkTreeIter iter;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3509 GtkListStore *store;
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 g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3512 g_return_if_fail (GTK_IS_LIST_STORE (combo_box->priv->model));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3513 g_return_if_fail (position >= 0);
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 store = GTK_LIST_STORE (combo_box->priv->model);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3516
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3517 if (gtk_tree_model_iter_nth_child (combo_box->priv->model, &iter,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3518 NULL, position))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3519 gtk_list_store_remove (store, &iter);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3520 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3521
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3522
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3523 static gboolean
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3524 gtk_combo_box_mnemonic_activate (GtkWidget *widget,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3525 gboolean group_cycling)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3526 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3527 GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3528
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3529 gtk_widget_grab_focus (combo_box->priv->button);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3530
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3531 return TRUE;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3534 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3535 gtk_combo_box_destroy (GtkObject *object)
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 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
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_combo_box_popdown (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3540
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3541 combo_box->priv->destroying = 1;
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 GTK_OBJECT_CLASS (parent_class)->destroy (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3544 combo_box->priv->cell_view = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3545
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3546 combo_box->priv->destroying = 0;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3549 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3550 gtk_combo_box_finalize (GObject *object)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3551 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3552 GtkComboBox *combo_box = GTK_COMBO_BOX (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3553 GSList *i;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3554
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3555 if (GTK_IS_MENU (combo_box->priv->popup_widget))
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 gtk_combo_box_menu_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3558 gtk_menu_detach (GTK_MENU (combo_box->priv->popup_widget));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3559 combo_box->priv->popup_widget = NULL;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3560 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3561
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3562 if (GTK_IS_TREE_VIEW (combo_box->priv->tree_view))
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3563 gtk_combo_box_list_destroy (combo_box);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3564
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3565 if (combo_box->priv->popup_window)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3566 gtk_widget_destroy (combo_box->priv->popup_window);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3567
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3568 gtk_combo_box_unset_model (combo_box);
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 for (i = combo_box->priv->cells; i; i = i->next)
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 ComboCellInfo *info = (ComboCellInfo *)i->data;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3573 GSList *list = info->attributes;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3574
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3575 if (info->destroy)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3576 info->destroy (info->func_data);
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 while (list && list->next)
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 g_free (list->data);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3581 list = list->next->next;
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 g_slist_free (info->attributes);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3584
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3585 g_object_unref (G_OBJECT (info->cell));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3586 g_free (info);
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 g_slist_free (combo_box->priv->cells);
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 g_free (combo_box->priv);
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 G_OBJECT_CLASS (parent_class)->finalize (object);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3593 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3594
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3595
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 * 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
3598 * and is needed to provide gtk_menu_attach()
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3599 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3600
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3601 typedef struct
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3602 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3603 gint left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3604 gint right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3605 gint top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3606 gint bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3607 gint effective_left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3608 gint effective_right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3609 gint effective_top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3610 gint effective_bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3611 } AttachInfo;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3612
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3613 #define ATTACH_INFO_KEY "gtk-menu-child-attach-info-key"
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3614
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3615 static AttachInfo *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3616 get_attach_info (GtkWidget *child)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3617 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3618 GObject *object = G_OBJECT (child);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3619 AttachInfo *ai = g_object_get_data (object, ATTACH_INFO_KEY);
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 if (!ai)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3622 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3623 ai = g_new0 (AttachInfo, 1);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3624 g_object_set_data_full (object, ATTACH_INFO_KEY, ai, g_free);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3625 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3626
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3627 return ai;
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
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3630 /**
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3631 * gtk_menu_attach:
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3632 * @menu: a #GtkMenu.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3633 * @child: a #GtkMenuItem.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3634 * @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
3635 * @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
3636 * @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
3637 * @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
3638 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3639 * 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
3640 * an item will occupy is specified by @left_attach, @right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3641 * @top_attach and @bottom_attach. These each represent the leftmost,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3642 * rightmost, uppermost and lower column and row numbers of the table.
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3643 * (Columns and rows are indexed from zero).
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 * Note that this function is not related to gtk_menu_detach().
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3646 *
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3647 * Since: 2.4
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 static void
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3650 gtk_menu_attach (GtkMenu *menu,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3651 GtkWidget *child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3652 guint left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3653 guint right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3654 guint top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3655 guint bottom_attach)
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3656 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3657 GtkMenuShell *menu_shell;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3658
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3659 g_return_if_fail (GTK_IS_MENU (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3660 g_return_if_fail (GTK_IS_MENU_ITEM (child));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3661 g_return_if_fail (child->parent == NULL ||
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3662 child->parent == GTK_WIDGET (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3663 g_return_if_fail (left_attach < right_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3664 g_return_if_fail (top_attach < bottom_attach);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3665
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3666 menu_shell = GTK_MENU_SHELL (menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3667
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3668 if (!child->parent)
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 AttachInfo *ai = get_attach_info (child);
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->left_attach = left_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3673 ai->right_attach = right_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3674 ai->top_attach = top_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3675 ai->bottom_attach = bottom_attach;
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3676
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3677 menu_shell->children = g_list_append (menu_shell->children, child);
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 gtk_widget_set_parent (child, GTK_WIDGET (menu));
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3680
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3681 /*
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3682 menu_queue_resize (menu);
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3683 */
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3684 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3685 else
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3686 {
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3687 gtk_container_child_set (GTK_CONTAINER (child->parent), child,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3688 "left_attach", left_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3689 "right_attach", right_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3690 "top_attach", top_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3691 "bottom_attach", bottom_attach,
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3692 NULL);
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 }
d0d1d631ed49 [gaim-migrate @ 12297]
Stu Tomlinson <stu@nosnilmot.com>
parents:
diff changeset
3695 #endif /* Gtk 2.4 */