annotate src/gtkstatusbox.c @ 11888:7d2d926704aa

[gaim-migrate @ 14179] Gtk 2.0 support. Deja Vu. committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 29 Oct 2005 14:45:15 +0000
parents 163104122522
children f1ada7870fae
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
11885
163104122522 [gaim-migrate @ 14176]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11870
diff changeset
389 gtk_tree_model_get(model, iter, TYPE_COLUMN, &type, -1);
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
390
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
391 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
392 return TRUE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
393
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
394 return FALSE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
395 }
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
396 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
397
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 static void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
401 GtkCellRenderer *text_rend;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
402 GtkCellRenderer *icon_rend;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 GtkTextBuffer *buffer;
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
404 GtkTreePath *path;
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
405 GtkIconSize icon_size;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
406
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
407 text_rend = gtk_cell_renderer_text_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
408 icon_rend = gtk_cell_renderer_pixbuf_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
409 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 status_box->imhtml_visible = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 status_box->connecting = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 status_box->typing = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 status_box->title = NULL;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
415 status_box->pixbuf = NULL;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 status_box->cell_view = gtk_cell_view_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 gtk_widget_show (status_box->cell_view);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
418
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
419 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
420 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
421 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
422 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
423 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 gtk_list_store_append(status_box->store, &(status_box->iter));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 gtk_gaim_status_box_refresh(status_box);
11593
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
426 path = gtk_tree_path_new_from_string("0");
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
427 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
428 gtk_tree_path_free(path);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 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
430
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 status_box->icon_rend = gtk_cell_renderer_pixbuf_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 status_box->text_rend = gtk_cell_renderer_text_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 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
435 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
436 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
437 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
438
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 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
440 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
441 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
442 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
443
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 status_box->vbox = gtk_vbox_new(0, FALSE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 status_box->imhtml = gtk_imhtml_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 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
448 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
449 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 status_box->sw = gtk_scrolled_window_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 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
453 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
454 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 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
456
11850
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
457
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
458 #if GTK_CHECK_VERSION(2,6,0)
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
459 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
460 #endif
0d793b594a23 [gaim-migrate @ 14141]
Nathan Walp <nwalp@pidgin.im>
parents: 11836
diff changeset
461
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
462 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
463 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
464 status_box->connecting_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
465 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
466 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
467 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
468 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
469 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
470 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
471 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
472 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
473
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
474 status_box->typing_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
475 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
476 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
477 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
478 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
479 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
480 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
481 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
482 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
483
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
484 gtk_gaim_status_box_regenerate(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
489 gtk_gaim_status_box_size_request(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
490 GtkRequisition *requisition)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 GtkRequisition box_req;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 combo_box_size_request(widget, requisition);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
494
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 if (box_req.height > 1)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 requisition->height = requisition->height + box_req.height + 6;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
498
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 requisition->width = 1;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
504 gtk_gaim_status_box_size_allocate(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
505 GtkAllocation *allocation)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 GtkRequisition req = {0,0};
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
508 GtkAllocation parent_alc, box_alc;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
509
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
510 parent_alc = *allocation;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
511 box_alc = *allocation;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 combo_box_size_request(widget, &req);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
513
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 /* EVIL XXX */
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
515 box_alc.height = 80;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
516 /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
517
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 box_alc.y = box_alc.y + req.height + 6;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 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
520
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 parent_alc.height = MAX(1,req.height);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 combo_box_size_allocate(widget, &parent_alc);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 widget->allocation = *allocation;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 static gboolean
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
528 gtk_gaim_status_box_expose_event(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
529 GdkEventExpose *event)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
531 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
532 combo_box_expose_event(widget, event);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
534 gtk_container_propagate_expose(GTK_CONTAINER(widget),
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
535 status_box->vbox, event);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
536 return FALSE;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
540 gtk_gaim_status_box_forall(GtkContainer *container,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
541 gboolean include_internals,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
542 GtkCallback callback,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
543 gpointer callback_data)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
545 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
547 if (include_internals)
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
548 {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
549 (* callback) (status_box->vbox, callback_data);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
550 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
552 combo_box_forall(container, include_internals, callback, callback_data);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 GtkWidget *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 gtk_gaim_status_box_new()
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
561 GtkWidget *
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
562 gtk_gaim_status_box_new_with_account(GaimAccount *account)
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
563 {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
564 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
565 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 void
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
568 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
569 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 GtkTreeIter iter;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 char *t;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
572
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 if (sec_text) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 char aa_color[8];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 style->text_aa[GTK_STATE_NORMAL].red >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 style->text_aa[GTK_STATE_NORMAL].green >> 8,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
579 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 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
581 } else {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 t = g_strdup(text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 }
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
584
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 gtk_list_store_append(status_box->dropdown_store, &iter);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
587 TYPE_COLUMN, type,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 ICON_COLUMN, pixbuf,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
589 TEXT_COLUMN, t,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 TITLE_COLUMN, text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
591 DESC_COLUMN, sec_text,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
592 -1);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
593 g_free(t);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 void
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
597 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box)
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
598 {
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
599 /* Don't do anything unless GTK actually supports
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
600 * gtk_combo_box_set_row_separator_func */
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
601 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
602 GtkTreeIter iter;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
603
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
604 gtk_list_store_append(status_box->dropdown_store, &iter);
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
605 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
606 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
607 -1);
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
608 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
609 }
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
610
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
611 void
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
614 if (status_box->error)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
615 g_free(status_box->error);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 status_box->error = g_strdup(error);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 status_box->connecting = connecting;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 gtk_gaim_status_box_refresh(status_box);
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
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 if (status_box->connecting_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 status_box->connecting_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
636 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 status_box->connecting_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 gtk_gaim_status_box_refresh(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
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 if (status_box->typing_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 status_box->typing_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
646 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 status_box->typing_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
651 static void
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
652 activate_currently_selected_status(GtkGaimStatusBox *status_box)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
654 GtkGaimStatusBoxItemType type;
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
655 gchar *title;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 GtkTreeIter iter;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
657 char *message;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
658 GaimSavedStatus *saved_status;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
660 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
661 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
662 TYPE_COLUMN, &type,
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
663 TITLE_COLUMN, &title, -1);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
664 message = gtk_gaim_status_box_get_message(status_box);
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
665
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
666 /*
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
667 * If the currently selected status is "Custom..." or
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
668 * "Saved..." then do nothing.
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
669 */
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
670 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES))
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
671 return;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
672
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
673 /* TODO: Should save the previous status as a transient status? */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
674
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
675 /* Save the newly selected status to prefs.xml and status.xml */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
676 saved_status = gaim_savedstatus_find(_("Default"));
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
677 if (saved_status == NULL)
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
678 saved_status = gaim_savedstatus_new(_("Default"), type);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
679 gaim_savedstatus_set_type(saved_status, type);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
680 gaim_savedstatus_set_message(saved_status, message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
681 gaim_prefs_set_string("/core/status/current", _("Default"));
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 /* Set the status for each account */
11806
7584d802f0ac [gaim-migrate @ 14097]
Mark Doliner <mark@kingant.net>
parents: 11756
diff changeset
684 gaim_savedstatus_activate(saved_status);
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
685
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
686 g_free(title);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
687 g_free(message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
688 }
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
689
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
690 static void remove_typing_cb(GtkGaimStatusBox *status_box)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
691 {
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
692 activate_currently_selected_status(status_box);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
693
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
694 g_source_remove(status_box->typing);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
695 status_box->typing = 0;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
696 gtk_gaim_status_box_refresh(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 static void gtk_gaim_status_box_changed(GtkComboBox *box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
701 GtkGaimStatusBox *status_box;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
703 GtkGaimStatusBoxItemType type;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 char *text, *sec_text;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 GdkPixbuf *pixbuf;
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
706 GList *accounts, *node;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
708 status_box = GTK_GAIM_STATUS_BOX(box);
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
709
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 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
711 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
712 TYPE_COLUMN, &type,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
713 TITLE_COLUMN, &text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
714 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
715 -1);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 if (status_box->title)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 g_free(status_box->title);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
718 status_box->title = text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 if (status_box->desc && sec_text)
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
720 g_free(status_box->desc);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
721 status_box->desc = sec_text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 if (status_box->pixbuf)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 g_object_unref(status_box->pixbuf);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 status_box->pixbuf = pixbuf;
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
725 if (status_box->typing)
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
726 g_source_remove(status_box->typing);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
727 status_box->typing = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
728
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
729 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
730 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
731 gaim_gtk_status_editor_show(NULL);
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
732 update_to_reflect_current_status(status_box);
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
733 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
734 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
735
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
736 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
737 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
738 gaim_gtk_status_window_show();
11870
678ef9ad7a0d [gaim-migrate @ 14161]
Mark Doliner <mark@kingant.net>
parents: 11850
diff changeset
739 update_to_reflect_current_status(status_box);
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
740 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
741 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
742
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
743 /*
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
744 * Show the message box whenever 'type' allows for a
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
745 * message attribute on any protocol that is enabled.
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
746 */
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
747 accounts = gaim_accounts_get_all_active();
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
748 status_box->imhtml_visible = FALSE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
749 for (node = accounts; node != NULL; node = node->next)
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
750 {
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
751 GaimAccount *account;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
752 GaimStatusType *status_type;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
753
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
754 account = node->data;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
755 status_type = gaim_account_get_status_type_with_primitive(account, type);
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
756 if ((status_type != NULL) &&
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
757 (gaim_status_type_get_attr(status_type, "message") != NULL))
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 status_box->imhtml_visible = TRUE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
760 break;
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 }
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
763 g_list_free(accounts);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
764
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
765 if (status_box->imhtml_visible)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
766 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 gtk_widget_show_all(status_box->vbox);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 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
769 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 gtk_widget_grab_focus(status_box->imhtml);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
771 }
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
772 else
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
773 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 gtk_widget_hide_all(status_box->vbox);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
775 activate_currently_selected_status(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 if (box->typing) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 gtk_gaim_status_box_pulse_typing(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 g_source_remove(box->typing);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
786 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 gtk_gaim_status_box_refresh(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 }
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
790
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
791 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
792 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
793 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
794 GtkGaimStatusBoxItemType type;
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
795 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
796 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
797 TYPE_COLUMN, &type, -1);
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
798 return type;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
799 }
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
800
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
801 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box)
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
802 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
803 if (status_box->imhtml_visible)
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
804 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml));
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
805 else
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
806 return NULL;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
807 }