annotate src/gtkstatusbox.c @ 11884:b1099e09eb33

[gaim-migrate @ 14175] I *think* this will make sure we distribute the right pieces for dbus support, but I don't currently have a sensible way of testing. Also, I suspect we may want some of the code generation to happen at dist time instead of build time. Something to think about. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 29 Oct 2005 02:06:36 +0000
parents 678ef9ad7a0d
children 163104122522
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gtkstatusbox.c GTK+ Status Selection Widget
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup gtkui
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * gaim
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
26 #include "account.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "internal.h"
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
28 #include "savedstatuses.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "status.h"
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
30 #include "debug.h"
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
31
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gtkgaim.h"
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
33 #include "gtksavedstatuses.h"
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gtkstock.h"
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtkstatusbox.h"
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
11836
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
37 /*
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
38 * TODO: The preference "/core/status/current" contains the name of
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
39 * the GaimSavedStatus that is the current master status of all
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
40 * enabled accounts. We need to monitor this preference and
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
41 * update ourself when the pref changes.
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
42 */
86cdfd6b32a6 [gaim-migrate @ 14127]
Mark Doliner <mark@kingant.net>
parents: 11806
diff changeset
43
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data);
11562
9f521a61ef58 [gaim-migrate @ 13828]
Sean Egan <seanegan@gmail.com>
parents: 11523
diff changeset
45 static void remove_typing_cb(GtkGaimStatusBox *box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
47 static void gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 static void gtk_gaim_status_box_changed(GtkComboBox *box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
58
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 enum {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
60 TYPE_COLUMN, /* A GtkGaimStatusBoxItemType */
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
61 ICON_COLUMN, /* This is a GdkPixbuf (the other columns are strings) */
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
62 TEXT_COLUMN, /* A string */
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
63 TITLE_COLUMN, /* The plain-English title of this item */
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
64 DESC_COLUMN, /* A plain-English description of this item */
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 NUM_COLUMNS
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 };
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
68 enum {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
69 PROP_0,
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
70 PROP_ACCOUNT
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
71 };
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
72
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 GType
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 gtk_gaim_status_box_get_type (void)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
79 static GType status_box_type = 0;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
81 if (!status_box_type)
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
82 {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
83 static const GTypeInfo status_box_info =
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
84 {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
85 sizeof (GtkGaimStatusBoxClass),
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
86 NULL, /* base_init */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
87 NULL, /* base_finalize */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
88 (GClassInitFunc) gtk_gaim_status_box_class_init,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
89 NULL, /* class_finalize */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
90 NULL, /* class_data */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
91 sizeof (GtkGaimStatusBox),
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
92 0,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
93 (GInstanceInitFunc) gtk_gaim_status_box_init
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
94 };
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
96 status_box_type = g_type_register_static(GTK_TYPE_COMBO_BOX,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
97 "GtkGaimStatusBox",
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
98 &status_box_info,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
99 0);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
100 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
102 return status_box_type;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 static void
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
106 gtk_gaim_status_box_get_property(GObject *object, guint param_id,
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
107 GValue *value, GParamSpec *psec)
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
108 {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
109 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
110
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
111 switch (param_id) {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
112 case PROP_ACCOUNT:
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
113 g_value_set_pointer(value, statusbox->account);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
114 break;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
115 default:
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
116 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, psec);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
117 break;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
118 }
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
119 }
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
120
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
121 static void
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
122 gtk_gaim_status_box_set_property(GObject *object, guint param_id,
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
123 const GValue *value, GParamSpec *pspec)
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
124 {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
125 GtkGaimStatusBox *statusbox = GTK_GAIM_STATUS_BOX(object);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
126
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
127 switch (param_id) {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
128 case PROP_ACCOUNT:
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
129 statusbox->account = g_value_get_pointer(value);
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
130 gtk_gaim_status_box_regenerate(statusbox);
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
131 break;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
132 default:
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
133 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
134 break;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
135 }
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
136 }
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
137
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
138
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
139 static void
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
142 GObjectClass *object_class;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
143 GtkWidgetClass *widget_class;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
144 GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
145 GtkContainerClass *container_class = (GtkContainerClass*)klass;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
147 parent_class->changed = gtk_gaim_status_box_changed;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
148 widget_class = (GtkWidgetClass*)klass;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
149 combo_box_size_request = widget_class->size_request;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
150 widget_class->size_request = gtk_gaim_status_box_size_request;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
151 combo_box_size_allocate = widget_class->size_allocate;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
152 widget_class->size_allocate = gtk_gaim_status_box_size_allocate;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
153 combo_box_expose_event = widget_class->expose_event;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
154 widget_class->expose_event = gtk_gaim_status_box_expose_event;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
156 combo_box_forall = container_class->forall;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
157 container_class->forall = gtk_gaim_status_box_forall;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
158
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
159 object_class = (GObjectClass *)klass;
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
160
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
161 object_class->get_property = gtk_gaim_status_box_get_property;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
162 object_class->set_property = gtk_gaim_status_box_set_property;
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
163
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
164 g_object_class_install_property(object_class,
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
165 PROP_ACCOUNT,
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
166 g_param_spec_pointer("account",
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
167 "Account",
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
168 "The account, or NULL for all accounts",
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
169 G_PARAM_READWRITE
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
170 )
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
171 );
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 static void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 {
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
177 char *text, *title;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 char aa_color[8];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 GdkPixbuf *pixbuf;
10702
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
180 GtkTreePath *path;
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
181 GtkStyle *style;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
183 style = gtk_widget_get_style(GTK_WIDGET(status_box));
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 style->text_aa[GTK_STATE_NORMAL].red >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 style->text_aa[GTK_STATE_NORMAL].green >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
188
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
189 title = status_box->title;
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
190 if (!title)
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
191 title = "";
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
192
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (status_box->error) {
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
194 text = g_strdup_printf("%s\n<span size=\"smaller\" weight=\"bold\" color=\"red\">%s</span>",
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
195 title, status_box->error);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 } else if (status_box->typing) {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
197 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>",
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
198 title, aa_color, _("Typing"));
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 } else if (status_box->connecting) {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
200 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>",
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
201 title, aa_color, _("Connecting"));
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
202 } else if (status_box->desc) {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
203 text = g_strdup_printf("%s\n<span size=\"smaller\" color=\"%s\">%s</span>",
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
204 title, aa_color, status_box->desc);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 } else {
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
206 text = g_strdup_printf("%s", title);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 }
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
208
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
209 if (status_box->connecting)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
210 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index];
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
211 else if (status_box->error)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 pixbuf = status_box->error_pixbuf;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 else if (status_box->typing)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 pixbuf = status_box->typing_pixbufs[status_box->typing_index];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 else
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 pixbuf = status_box->pixbuf;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 gtk_list_store_set(status_box->store, &(status_box->iter),
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
219 TYPE_COLUMN, -1, /* This field is not used in this list store */
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 ICON_COLUMN, pixbuf,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
221 TEXT_COLUMN, text,
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
222 TITLE_COLUMN, title,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
223 DESC_COLUMN, status_box->desc,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
224 -1);
10702
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
225 path = gtk_tree_path_new_from_string("0");
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
226 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path);
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
227 gtk_tree_path_free(path);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 g_free(text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
232 static GdkPixbuf *
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
233 load_icon(const char *basename)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
234 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
235 char basename2[BUFSIZ];
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
236 char *filename;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
237 GdkPixbuf *pixbuf, *scale = NULL;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
238
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
239 if (!strcmp(basename, "available"))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
240 basename = "online";
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
241 else if (!strcmp(basename, "hidden"))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
242 basename = "invisible";
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
243
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
244 /*
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
245 * TODO: Find a way to fallback to the GaimStatusPrimitive
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
246 * if an icon for this id does not exist.
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
247 */
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
248 g_snprintf(basename2, sizeof(basename2), "%s.png",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
249 basename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
250 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
251 basename2, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
252 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
253 g_free(filename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
254
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
255 if (pixbuf != NULL) {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
256 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
257 GDK_INTERP_BILINEAR);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
258
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
259 g_object_unref(G_OBJECT(pixbuf));
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
260 } else {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
261 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
262 "default", basename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
263 scale = gdk_pixbuf_new_from_file(filename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
264 g_free(filename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
265 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
266
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
267 return scale;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
268 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
269
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
270 /**
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
271 * This updates the GtkTreeView so that it correctly shows the state
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
272 * we are currently using. It is used when the current state is
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
273 * updated from somewhere other than the GtkStatusBox (from a plugin,
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
274 * or when signing on with the "-n" option, for example). It is
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
275 * also used when the user selects the "Custom..." option.
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
276 *
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
277 * TODO: It should ONLY update the appearance of the GtkStatusBox. It
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
278 * should not trigger the text-input-typing-timer. It should also
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
279 * not trigger a status change.
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
280 *
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
281 * Maybe we could accomplish this by triggering off the mouse and
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
282 * keyboard signals instead of the changed signal?
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
283 */
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
284 static void
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
285 update_to_reflect_current_status(GtkGaimStatusBox *status_box)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
286 {
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
287 const char *current_savedstatus_name;
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
288 GaimSavedStatus *saved_status;
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
289
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
290 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
291 saved_status = gaim_savedstatus_find(current_savedstatus_name);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
292 if (saved_status == NULL)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
293 {
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
294 /* Default to "available" */
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
295 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
296 }
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
297 else
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
298 {
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
299 GaimStatusPrimitive primitive;
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
300 const char *message;
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
301
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
302 primitive = gaim_savedstatus_get_type(saved_status);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
303 if (gaim_savedstatus_has_substatuses(saved_status) ||
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
304 ((primitive != GAIM_STATUS_AVAILABLE) &&
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
305 (primitive != GAIM_STATUS_OFFLINE) &&
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
306 (primitive != GAIM_STATUS_AWAY) &&
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
307 (primitive != GAIM_STATUS_HIDDEN)))
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
308 {
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
309 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
310 }
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
311 else
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
312 {
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
313 if (primitive == GAIM_STATUS_AVAILABLE)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
314 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
315 if (primitive == GAIM_STATUS_OFFLINE)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
316 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
317 else if (primitive == GAIM_STATUS_AWAY)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
318 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
319 else if (primitive == GAIM_STATUS_HIDDEN)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
320 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
321 }
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
322
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
323 message = gaim_savedstatus_get_message(saved_status);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
324 if (message != NULL)
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
325 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0);
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
326 }
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
327 }
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
328
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
329 static void
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
330 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
331 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
332 GaimAccount *account;
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
333 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
334 GtkIconSize icon_size;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
335
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
336 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
337
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
338 gtk_list_store_clear(status_box->dropdown_store);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
339
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
340 account = GTK_GAIM_STATUS_BOX(status_box)->account;
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
341 if (account == NULL)
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
342 {
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
343 pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_ONLINE,
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
344 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
345 pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_AWAY,
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
346 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
347 pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE,
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
348 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
349 pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_INVISIBLE,
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
350 icon_size, "GtkGaimStatusBox");
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
351 /* hacks */
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
352 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AVAILABLE, pixbuf, _("Available"), NULL);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
353 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_AWAY, pixbuf2, _("Away"), NULL);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
354 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_HIDDEN, pixbuf4, _("Invisible"), NULL);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
355 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GAIM_STATUS_OFFLINE, pixbuf3, _("Offline"), NULL);
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
356 gtk_gaim_status_box_add_separator(GTK_GAIM_STATUS_BOX(status_box));
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
357 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_CUSTOM, pixbuf, _("Custom..."), NULL);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
358 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), GTK_GAIM_STATUS_BOX_TYPE_SAVED, pixbuf, _("Saved..."), NULL);
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
359
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
360 update_to_reflect_current_status(status_box);
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
361
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
362 } else {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
363 const GList *l;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
364
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
365 for (l = gaim_account_get_status_types(account); l != NULL; l = l->next)
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
366 {
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
367 GaimStatusType *status_type = (GaimStatusType *)l->data;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
368
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
369 if (!gaim_status_type_is_user_settable(status_type))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
370 continue;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
371
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
372 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
373 gaim_status_type_get_primitive(status_type),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
374 load_icon(gaim_status_type_get_id(status_type)),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
375 gaim_status_type_get_name(status_type),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
376 NULL);
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
377 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
378 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
379
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
380 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
381
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
382 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
383 static gboolean
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
384 dropdown_store_row_separator_func(GtkTreeModel *model,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
385 GtkTreeIter *iter, gpointer data)
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
386 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
387 GtkGaimStatusBoxItemType type;
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
388 GdkPixbuf *pixbuf;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
389 gchar *text, *title, *description;
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
390
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
391 gtk_tree_model_get(model, iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
392 TYPE_COLUMN, &type,
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
393 ICON_COLUMN, &pixbuf,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
394 TEXT_COLUMN, &text,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
395 TITLE_COLUMN, &title,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
396 DESC_COLUMN, &description,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
397 -1);
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
398
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
399 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
400 return TRUE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
401
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
402 return FALSE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
403 }
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
404 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
405
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 static void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
409 GtkCellRenderer *text_rend;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
410 GtkCellRenderer *icon_rend;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 GtkTextBuffer *buffer;
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
412 GtkTreePath *path;
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
413 GtkIconSize icon_size;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
414
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
415 text_rend = gtk_cell_renderer_text_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
416 icon_rend = gtk_cell_renderer_pixbuf_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
417 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 status_box->imhtml_visible = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 status_box->connecting = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 status_box->typing = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 status_box->title = NULL;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
423 status_box->pixbuf = NULL;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 status_box->cell_view = gtk_cell_view_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 gtk_widget_show (status_box->cell_view);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
426
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
427 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
428 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 gtk_list_store_append(status_box->store, &(status_box->iter));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 gtk_gaim_status_box_refresh(status_box);
11593
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
434 path = gtk_tree_path_new_from_string("0");
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
435 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), path);
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
436 gtk_tree_path_free(path);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
438
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 status_box->icon_rend = gtk_cell_renderer_pixbuf_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 status_box->text_rend = gtk_cell_renderer_text_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
443 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE);
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
448 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 status_box->vbox = gtk_vbox_new(0, FALSE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 status_box->imhtml = gtk_imhtml_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box);
11562
9f521a61ef58 [gaim-migrate @ 13828]
Sean Egan <seanegan@gmail.com>
parents: 11523
diff changeset
456 g_signal_connect_swapped(G_OBJECT(status_box->imhtml), "message_send", G_CALLBACK(remove_typing_cb), status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 status_box->sw = gtk_scrolled_window_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
464
11850
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
465
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
466 #if GTK_CHECK_VERSION(2,6,0)
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
467 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL);
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
468 #endif
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
469
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
470 status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_OFFLINE,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
471 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
472 status_box->connecting_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
473 status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT0,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
474 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
475 status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT1,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
476 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
477 status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT2,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
478 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
479 status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_CONNECT3,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
480 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
481
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
482 status_box->typing_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
483 status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING0,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
484 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
485 status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING1,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
486 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
487 status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING2,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
488 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
489 status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), GAIM_STOCK_STATUS_TYPING3,
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
490 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
491
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
492 gtk_gaim_status_box_regenerate(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
497 gtk_gaim_status_box_size_request(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
498 GtkRequisition *requisition)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 GtkRequisition box_req;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 combo_box_size_request(widget, requisition);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
502
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 if (box_req.height > 1)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 requisition->height = requisition->height + box_req.height + 6;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
506
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 requisition->width = 1;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
512 gtk_gaim_status_box_size_allocate(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
513 GtkAllocation *allocation)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 GtkRequisition req = {0,0};
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
516 GtkAllocation parent_alc, box_alc;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
517
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
518 parent_alc = *allocation;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
519 box_alc = *allocation;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 combo_box_size_request(widget, &req);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
521
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 /* EVIL XXX */
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
523 box_alc.height = 80;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
524 /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
525
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 box_alc.y = box_alc.y + req.height + 6;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
528
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 parent_alc.height = MAX(1,req.height);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 combo_box_size_allocate(widget, &parent_alc);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 widget->allocation = *allocation;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 static gboolean
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
536 gtk_gaim_status_box_expose_event(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
537 GdkEventExpose *event)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
539 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
540 combo_box_expose_event(widget, event);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
542 gtk_container_propagate_expose(GTK_CONTAINER(widget),
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
543 status_box->vbox, event);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
544 return FALSE;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
548 gtk_gaim_status_box_forall(GtkContainer *container,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
549 gboolean include_internals,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
550 GtkCallback callback,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
551 gpointer callback_data)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
553 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
555 if (include_internals)
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
556 {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
557 (* callback) (status_box->vbox, callback_data);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
558 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
560 combo_box_forall(container, include_internals, callback, callback_data);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 GtkWidget *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 gtk_gaim_status_box_new()
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
569 GtkWidget *
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
570 gtk_gaim_status_box_new_with_account(GaimAccount *account)
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
571 {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
572 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, "account", account, NULL);
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
573 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 void
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
576 gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GtkGaimStatusBoxItemType type, GdkPixbuf *pixbuf, const char *text, const char *sec_text)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 GtkTreeIter iter;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 char *t;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
580
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 if (sec_text) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 char aa_color[8];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 style->text_aa[GTK_STATE_NORMAL].red >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 style->text_aa[GTK_STATE_NORMAL].green >> 8,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
587 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 t = g_strdup_printf("%s\n<span color=\"%s\">%s</span>", text, aa_color, sec_text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 } else {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 t = g_strdup(text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 }
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
592
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 gtk_list_store_append(status_box->dropdown_store, &iter);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
595 TYPE_COLUMN, type,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 ICON_COLUMN, pixbuf,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
597 TEXT_COLUMN, t,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 TITLE_COLUMN, text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
599 DESC_COLUMN, sec_text,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
600 -1);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
601 g_free(t);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 void
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
605 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box)
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
606 {
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
607 /* Don't do anything unless GTK actually supports
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
608 * gtk_combo_box_set_row_separator_func */
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
609 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
610 GtkTreeIter iter;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
611
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
612 gtk_list_store_append(status_box->dropdown_store, &iter);
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
613 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
614 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
615 -1);
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
616 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
617 }
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
618
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
619 void
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
622 if (status_box->error)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
623 g_free(status_box->error);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 status_box->error = g_strdup(error);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 status_box->connecting = connecting;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 if (status_box->connecting_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 status_box->connecting_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
644 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 status_box->connecting_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 if (status_box->typing_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 status_box->typing_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
654 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 status_box->typing_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
659 static void
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
660 activate_currently_selected_status(GtkGaimStatusBox *status_box)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
662 GtkGaimStatusBoxItemType type;
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
663 gchar *title;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 GtkTreeIter iter;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
665 char *message;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
666 GaimSavedStatus *saved_status;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
668 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
669 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
670 TYPE_COLUMN, &type,
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
671 TITLE_COLUMN, &title, -1);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
672 message = gtk_gaim_status_box_get_message(status_box);
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
673
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
674 /*
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
675 * If the currently selected status is "Custom..." or
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
676 * "Saved..." then do nothing.
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
677 */
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
678 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES))
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
679 return;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
680
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
681 /* TODO: Should save the previous status as a transient status? */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
682
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
683 /* Save the newly selected status to prefs.xml and status.xml */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
684 saved_status = gaim_savedstatus_find(_("Default"));
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
685 if (saved_status == NULL)
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
686 saved_status = gaim_savedstatus_new(_("Default"), type);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
687 gaim_savedstatus_set_type(saved_status, type);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
688 gaim_savedstatus_set_message(saved_status, message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
689 gaim_prefs_set_string("/core/status/current", _("Default"));
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
690
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
691 /* Set the status for each account */
11806
7584d802f0ac [gaim-migrate @ 14097]
Mark Doliner <mark@kingant.net>
parents: 11756
diff changeset
692 gaim_savedstatus_activate(saved_status);
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
693
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
694 g_free(title);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
695 g_free(message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
696 }
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
697
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
698 static void remove_typing_cb(GtkGaimStatusBox *status_box)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
699 {
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
700 activate_currently_selected_status(status_box);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
701
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
702 g_source_remove(status_box->typing);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
703 status_box->typing = 0;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
704 gtk_gaim_status_box_refresh(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 static void gtk_gaim_status_box_changed(GtkComboBox *box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
709 GtkGaimStatusBox *status_box;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
711 GtkGaimStatusBoxItemType type;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 char *text, *sec_text;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 GdkPixbuf *pixbuf;
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
714 GList *accounts, *node;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
716 status_box = GTK_GAIM_STATUS_BOX(box);
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
717
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter);
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
719 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
720 TYPE_COLUMN, &type,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
721 TITLE_COLUMN, &text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
722 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
723 -1);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 if (status_box->title)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 g_free(status_box->title);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
726 status_box->title = text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 if (status_box->desc && sec_text)
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
728 g_free(status_box->desc);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
729 status_box->desc = sec_text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 if (status_box->pixbuf)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 g_object_unref(status_box->pixbuf);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 status_box->pixbuf = pixbuf;
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
733 if (status_box->typing)
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
734 g_source_remove(status_box->typing);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
735 status_box->typing = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
736
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
737 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
738 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
739 gaim_gtk_status_editor_show(NULL);
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
740 update_to_reflect_current_status(status_box);
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
741 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
742 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
743
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
744 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
745 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
746 gaim_gtk_status_window_show();
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
747 update_to_reflect_current_status(status_box);
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
748 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
749 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
750
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
751 /*
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
752 * Show the message box whenever 'type' allows for a
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
753 * message attribute on any protocol that is enabled.
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
754 */
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
755 accounts = gaim_accounts_get_all_active();
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
756 status_box->imhtml_visible = FALSE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
757 for (node = accounts; node != NULL; node = node->next)
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
758 {
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
759 GaimAccount *account;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
760 GaimStatusType *status_type;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
761
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
762 account = node->data;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
763 status_type = gaim_account_get_status_type_with_primitive(account, type);
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
764 if ((status_type != NULL) &&
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
765 (gaim_status_type_get_attr(status_type, "message") != NULL))
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
766 {
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
767 status_box->imhtml_visible = TRUE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
768 break;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
769 }
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
770 }
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
771 g_list_free(accounts);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
772
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
773 if (status_box->imhtml_visible)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
774 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 gtk_widget_show_all(status_box->vbox);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 gtk_widget_grab_focus(status_box->imhtml);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
779 }
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
780 else
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
781 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 gtk_widget_hide_all(status_box->vbox);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
783 activate_currently_selected_status(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791 if (box->typing) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 gtk_gaim_status_box_pulse_typing(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 g_source_remove(box->typing);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
794 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 gtk_gaim_status_box_refresh(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 }
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
798
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
799 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box)
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
800 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
801 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
802 GtkGaimStatusBoxItemType type;
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
803 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
804 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
805 TYPE_COLUMN, &type, -1);
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
806 return type;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
807 }
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
808
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
809 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box)
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
810 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
811 if (status_box->imhtml_visible)
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
812 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml));
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
813 else
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
814 return NULL;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
815 }