annotate src/gtkstatusbox.c @ 11844:a0956e22fdde

[gaim-migrate @ 14135] Is there a reason this wasn't static? committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 26 Oct 2005 11:53:50 +0000
parents 86cdfd6b32a6
children 0d793b594a23
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;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 style->text_aa[GTK_STATE_NORMAL].red >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 style->text_aa[GTK_STATE_NORMAL].green >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
187
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
188 title = status_box->title;
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
189 if (!title)
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
190 title = "";
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
191
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 if (status_box->error) {
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
193 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
194 title, status_box->error);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 } else if (status_box->typing) {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
196 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
197 title, aa_color, _("Typing"));
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 } else if (status_box->connecting) {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
199 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
200 title, aa_color, _("Connecting"));
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
201 } else if (status_box->desc) {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
202 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
203 title, aa_color, status_box->desc);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 } else {
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
205 text = g_strdup_printf("%s", title);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
207
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
208 if (status_box->connecting)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
209 pixbuf = status_box->connecting_pixbufs[status_box->connecting_index];
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
210 else if (status_box->error)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 pixbuf = status_box->error_pixbuf;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 else if (status_box->typing)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 pixbuf = status_box->typing_pixbufs[status_box->typing_index];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 else
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 pixbuf = status_box->pixbuf;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 gtk_list_store_set(status_box->store, &(status_box->iter),
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
218 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
219 ICON_COLUMN, pixbuf,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
220 TEXT_COLUMN, text,
10672
0925c898b73c [gaim-migrate @ 12212]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10661
diff changeset
221 TITLE_COLUMN, title,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
222 DESC_COLUMN, status_box->desc,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
223 -1);
10702
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
224 path = gtk_tree_path_new_from_string("0");
f51e040affc6 [gaim-migrate @ 12284]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10672
diff changeset
225 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
226 gtk_tree_path_free(path);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 g_free(text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
231 static GdkPixbuf *
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
232 load_icon(const char *basename)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
233 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
234 char basename2[BUFSIZ];
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
235 char *filename;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
236 GdkPixbuf *pixbuf, *scale = NULL;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
237
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
238 if (!strcmp(basename, "available"))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
239 basename = "online";
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
240 else if (!strcmp(basename, "hidden"))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
241 basename = "invisible";
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
242
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 * TODO: Find a way to fallback to the GaimStatusPrimitive
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
245 * if an icon for this id does not exist.
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
246 */
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
247 g_snprintf(basename2, sizeof(basename2), "%s.png",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
248 basename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
249 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
250 basename2, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
251 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
252 g_free(filename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
253
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
254 if (pixbuf != NULL) {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
255 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
256 GDK_INTERP_BILINEAR);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
257
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
258 g_object_unref(G_OBJECT(pixbuf));
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
259 } else {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
260 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
261 "default", basename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
262 scale = gdk_pixbuf_new_from_file(filename, NULL);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
263 g_free(filename);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
264 }
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 return scale;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
267 }
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 static void
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
270 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
271 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
272 GaimAccount *account;
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
273 GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
274 GtkIconSize icon_size;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
275 const char *current_savedstatus_name;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
276 GaimSavedStatus *saved_status;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
277
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
278 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
279
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
280 gtk_list_store_clear(status_box->dropdown_store);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
281
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
282 account = GTK_GAIM_STATUS_BOX(status_box)->account;
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
283 if (account == NULL)
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
284 {
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
285 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
286 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
287 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
288 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
289 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
290 icon_size, "GtkGaimStatusBox");
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
291 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
292 icon_size, "GtkGaimStatusBox");
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
293 /* hacks */
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
294 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
295 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
296 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
297 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
298 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
299 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
300 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
301
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
302 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
303 saved_status = gaim_savedstatus_find(current_savedstatus_name);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
304 if (saved_status == NULL)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
305 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
306 /* Default to "available" */
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
307 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
308 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
309 else
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
310 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
311 GaimStatusPrimitive primitive;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
312 const char *message;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
313
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
314 primitive = gaim_savedstatus_get_type(saved_status);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
315 if (gaim_savedstatus_has_substatuses(saved_status) ||
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
316 ((primitive != GAIM_STATUS_AVAILABLE) &&
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
317 (primitive != GAIM_STATUS_OFFLINE) &&
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
318 (primitive != GAIM_STATUS_AWAY) &&
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
319 (primitive != GAIM_STATUS_HIDDEN)))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
320 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
321 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
322 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
323 else
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
324 {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
325 if (primitive == GAIM_STATUS_AVAILABLE)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
326 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
327 if (primitive == GAIM_STATUS_OFFLINE)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
328 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
329 else if (primitive == GAIM_STATUS_AWAY)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
330 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
331 else if (primitive == GAIM_STATUS_HIDDEN)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
332 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
333 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
334
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
335 message = gaim_savedstatus_get_message(saved_status);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
336 if (message != NULL)
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
337 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0);
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
338 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
339
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
340
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
341 } else {
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
342 const GList *l;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
343
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
344 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
345 {
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
346 GaimStatusType *status_type = (GaimStatusType *)l->data;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
347
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
348 if (!gaim_status_type_is_user_settable(status_type))
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
349 continue;
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
350
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
351 gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
352 gaim_status_type_get_primitive(status_type),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
353 load_icon(gaim_status_type_get_id(status_type)),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
354 gaim_status_type_get_name(status_type),
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
355 NULL);
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
356 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
357 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
358
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
359 }
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
360
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
361 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
362 static gboolean
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
363 dropdown_store_row_separator_func(GtkTreeModel *model,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
364 GtkTreeIter *iter, gpointer data)
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
365 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
366 GtkGaimStatusBoxItemType type;
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
367 GdkPixbuf *pixbuf;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
368 gchar *text, *title, *description;
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
369
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
370 gtk_tree_model_get(model, iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
371 TYPE_COLUMN, &type,
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
372 ICON_COLUMN, &pixbuf,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
373 TEXT_COLUMN, &text,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
374 TITLE_COLUMN, &title,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
375 DESC_COLUMN, &description,
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
376 -1);
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
377
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
378 if (type == GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
379 return TRUE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
380
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
381 return FALSE;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
382 }
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
383 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
384
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 static void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 gtk_gaim_status_box_init (GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
388 GtkCellRenderer *text_rend;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
389 GtkCellRenderer *icon_rend;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 GtkTextBuffer *buffer;
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
391 GtkTreePath *path;
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
392 GtkIconSize icon_size;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
393
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
394 text_rend = gtk_cell_renderer_text_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
395 icon_rend = gtk_cell_renderer_pixbuf_new();
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
396 icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 status_box->imhtml_visible = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 status_box->connecting = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 status_box->typing = FALSE;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 status_box->title = NULL;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
402 status_box->pixbuf = NULL;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 status_box->cell_view = gtk_cell_view_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 gtk_widget_show (status_box->cell_view);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
405
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
406 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
407 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);
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
408 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
409 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(status_box), dropdown_store_row_separator_func, NULL, NULL);
11753
59ae71ae0b7c [gaim-migrate @ 14044]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11739
diff changeset
410 #endif
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 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
412 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
413 gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 gtk_list_store_append(status_box->store, &(status_box->iter));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 gtk_gaim_status_box_refresh(status_box);
11593
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
416 path = gtk_tree_path_new_from_string("0");
4b7fb30b8926 [gaim-migrate @ 13863]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11562
diff changeset
417 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
418 gtk_tree_path_free(path);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 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
420
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 status_box->icon_rend = gtk_cell_renderer_pixbuf_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 status_box->text_rend = gtk_cell_renderer_text_new();
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 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
425 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
426 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
427 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
428
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 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
430 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
431 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
432 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
433
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 status_box->vbox = gtk_vbox_new(0, FALSE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 status_box->imhtml = gtk_imhtml_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 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
438 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
439 gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 status_box->sw = gtk_scrolled_window_new(NULL, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 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
443 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
444 gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 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
446
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
447 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
448 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
449 status_box->connecting_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
450 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
451 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
452 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
453 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
454 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
455 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
456 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
457 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
458
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
459 status_box->typing_index = 0;
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
460 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
461 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
462 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
463 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
464 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
465 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
466 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
467 icon_size, "GtkGaimStatusBox");
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
468
11732
03c813a42c76 [gaim-migrate @ 14023]
Tim Ringenbach <marv@pidgin.im>
parents: 11729
diff changeset
469 gtk_gaim_status_box_regenerate(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
474 gtk_gaim_status_box_size_request(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
475 GtkRequisition *requisition)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 GtkRequisition box_req;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 combo_box_size_request(widget, requisition);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
479
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 if (box_req.height > 1)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 requisition->height = requisition->height + box_req.height + 6;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
483
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 requisition->width = 1;
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_allocate(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
490 GtkAllocation *allocation)
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 req = {0,0};
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
493 GtkAllocation parent_alc, box_alc;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
494
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
495 parent_alc = *allocation;
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
496 box_alc = *allocation;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 combo_box_size_request(widget, &req);
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 /* EVIL XXX */
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
500 box_alc.height = 80;
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
501 /* box_alc.height = MAX(1,box_alc.height - req.height - 6); */
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
502
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 box_alc.y = box_alc.y + req.height + 6;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 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
505
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 parent_alc.height = MAX(1,req.height);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 combo_box_size_allocate(widget, &parent_alc);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 widget->allocation = *allocation;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 static gboolean
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
513 gtk_gaim_status_box_expose_event(GtkWidget *widget,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
514 GdkEventExpose *event)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
516 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(widget);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
517 combo_box_expose_event(widget, event);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
519 gtk_container_propagate_expose(GTK_CONTAINER(widget),
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
520 status_box->vbox, event);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
521 return FALSE;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 static void
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
525 gtk_gaim_status_box_forall(GtkContainer *container,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
526 gboolean include_internals,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
527 GtkCallback callback,
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
528 gpointer callback_data)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 {
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
530 GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
532 if (include_internals)
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
533 {
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
534 (* callback) (status_box->vbox, callback_data);
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
535 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
537 combo_box_forall(container, include_internals, callback, callback_data);
10643
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
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 GtkWidget *
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 gtk_gaim_status_box_new()
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545
11499
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
546 GtkWidget *
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
547 gtk_gaim_status_box_new_with_account(GaimAccount *account)
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
548 {
6f9fc83ee25c [gaim-migrate @ 13744]
Tim Ringenbach <marv@pidgin.im>
parents: 11400
diff changeset
549 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
550 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 void
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
553 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
554 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 GtkTreeIter iter;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 char *t;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
557
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 if (sec_text) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 char aa_color[8];
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x",
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 style->text_aa[GTK_STATE_NORMAL].red >> 8,
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 style->text_aa[GTK_STATE_NORMAL].green >> 8,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
564 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 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
566 } else {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 t = g_strdup(text);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 }
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
569
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 gtk_list_store_append(status_box->dropdown_store, &iter);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
572 TYPE_COLUMN, type,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 ICON_COLUMN, pixbuf,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
574 TEXT_COLUMN, t,
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 TITLE_COLUMN, text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
576 DESC_COLUMN, sec_text,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
577 -1);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
578 g_free(t);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 void
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
582 gtk_gaim_status_box_add_separator(GtkGaimStatusBox *status_box)
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
583 {
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
584 /* Don't do anything unless GTK actually supports
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
585 * gtk_combo_box_set_row_separator_func */
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
586 #if GTK_CHECK_VERSION(2,6,0)
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
587 GtkTreeIter iter;
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
588
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
589 gtk_list_store_append(status_box->dropdown_store, &iter);
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
590 gtk_list_store_set(status_box->dropdown_store, &iter,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
591 TYPE_COLUMN, GTK_GAIM_STATUS_BOX_TYPE_SEPARATOR,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
592 -1);
11756
f54c680d835c [gaim-migrate @ 14047]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11755
diff changeset
593 #endif
11738
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
594 }
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
595
992d49cf2b92 [gaim-migrate @ 14029]
Mark Doliner <mark@kingant.net>
parents: 11732
diff changeset
596 void
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 {
11523
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
599 if (status_box->error)
1116993aadd2 [gaim-migrate @ 13771]
Sean Egan <seanegan@gmail.com>
parents: 11499
diff changeset
600 g_free(status_box->error);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 status_box->error = g_strdup(error);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 status_box->connecting = connecting;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 if (!status_box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 return;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 if (status_box->connecting_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 status_box->connecting_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
621 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 status_box->connecting_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 void
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box)
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 if (status_box->typing_index == 3)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 status_box->typing_index = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
631 else
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 status_box->typing_index++;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
636 static void
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
637 activate_currently_selected_status(GtkGaimStatusBox *status_box)
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 {
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
639 GtkGaimStatusBoxItemType type;
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
640 gchar *title;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 GtkTreeIter iter;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
642 char *message;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
643 GaimSavedStatus *saved_status;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
645 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
646 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
647 TYPE_COLUMN, &type,
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
648 TITLE_COLUMN, &title, -1);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
649 message = gtk_gaim_status_box_get_message(status_box);
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
650
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
651 /*
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
652 * If the currently selected status is "Custom..." or
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
653 * "Saved..." then do nothing.
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
654 */
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
655 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES))
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
656 return;
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
657
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
658 /* TODO: Should save the previous status as a transient status? */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
659
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
660 /* Save the newly selected status to prefs.xml and status.xml */
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
661 saved_status = gaim_savedstatus_find(_("Default"));
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
662 if (saved_status == NULL)
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
663 saved_status = gaim_savedstatus_new(_("Default"), type);
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
664 gaim_savedstatus_set_type(saved_status, type);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
665 gaim_savedstatus_set_message(saved_status, message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
666 gaim_prefs_set_string("/core/status/current", _("Default"));
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
667
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
668 /* Set the status for each account */
11806
7584d802f0ac [gaim-migrate @ 14097]
Mark Doliner <mark@kingant.net>
parents: 11756
diff changeset
669 gaim_savedstatus_activate(saved_status);
11627
5dbefebb20cb [gaim-migrate @ 13902]
Tim Ringenbach <marv@pidgin.im>
parents: 11593
diff changeset
670
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
671 g_free(title);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
672 g_free(message);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
673 }
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 static void remove_typing_cb(GtkGaimStatusBox *status_box)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
676 {
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
677 activate_currently_selected_status(status_box);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
678
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
679 g_source_remove(status_box->typing);
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
680 status_box->typing = 0;
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
681 gtk_gaim_status_box_refresh(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 static void gtk_gaim_status_box_changed(GtkComboBox *box)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 {
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
686 GtkGaimStatusBox *status_box;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
688 GtkGaimStatusBoxItemType type;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 char *text, *sec_text;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 GdkPixbuf *pixbuf;
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
691 GList *accounts, *node;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692
11400
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
693 status_box = GTK_GAIM_STATUS_BOX(box);
62db025d3eb0 [gaim-migrate @ 13635]
Mark Doliner <mark@kingant.net>
parents: 11347
diff changeset
694
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 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
696 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
697 TYPE_COLUMN, &type,
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
698 TITLE_COLUMN, &text,
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
699 DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf,
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
700 -1);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 if (status_box->title)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 g_free(status_box->title);
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
703 status_box->title = text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 if (status_box->desc && sec_text)
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
705 g_free(status_box->desc);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
706 status_box->desc = sec_text;
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 if (status_box->pixbuf)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 g_object_unref(status_box->pixbuf);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 status_box->pixbuf = pixbuf;
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
710 if (status_box->typing)
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
711 g_source_remove(status_box->typing);
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
712 status_box->typing = 0;
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
713
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
714 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
715 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
716 gaim_gtk_status_editor_show(NULL);
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
717 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
718 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
719
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
720 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED)
11729
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
721 {
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
722 gaim_gtk_status_window_show();
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
723 return;
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
724 }
8a981a601242 [gaim-migrate @ 14020]
Mark Doliner <mark@kingant.net>
parents: 11724
diff changeset
725
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
726 /*
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
727 * Show the message box whenever 'type' allows for a
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
728 * message attribute on any protocol that is enabled.
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
729 */
11755
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
730 accounts = gaim_accounts_get_all_active();
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
731 status_box->imhtml_visible = FALSE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
732 for (node = accounts; node != NULL; node = node->next)
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
733 {
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
734 GaimAccount *account;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
735 GaimStatusType *status_type;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
736
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
737 account = node->data;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
738 status_type = gaim_account_get_status_type_with_primitive(account, type);
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
739 if ((status_type != NULL) &&
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
740 (gaim_status_type_get_attr(status_type, "message") != NULL))
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
741 {
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
742 status_box->imhtml_visible = TRUE;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
743 break;
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
744 }
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
745 }
50496ebef401 [gaim-migrate @ 14046]
Mark Doliner <mark@kingant.net>
parents: 11753
diff changeset
746 g_list_free(accounts);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
747
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
748 if (status_box->imhtml_visible)
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
749 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750 gtk_widget_show_all(status_box->vbox);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 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
752 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml));
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 gtk_widget_grab_focus(status_box->imhtml);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
754 }
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
755 else
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
756 {
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 gtk_widget_hide_all(status_box->vbox);
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11638
diff changeset
758 activate_currently_selected_status(status_box);
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760 gtk_gaim_status_box_refresh(status_box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 }
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data)
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data;
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 if (box->typing) {
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 gtk_gaim_status_box_pulse_typing(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768 g_source_remove(box->typing);
10861
42c16b293867 [gaim-migrate @ 12544]
Mark Doliner <mark@kingant.net>
parents: 10749
diff changeset
769 }
10643
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 gtk_gaim_status_box_refresh(box);
868aafbe859b [gaim-migrate @ 12153]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 }
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
773
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
774 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
775 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
776 GtkTreeIter iter;
11739
a25be0e70a67 [gaim-migrate @ 14030]
Mark Doliner <mark@kingant.net>
parents: 11738
diff changeset
777 GtkGaimStatusBoxItemType type;
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
778 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
779 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
780 TYPE_COLUMN, &type, -1);
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
781 return type;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
782 }
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
783
11638
3a05b53a589e [gaim-migrate @ 13914]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11627
diff changeset
784 char *gtk_gaim_status_box_get_message(GtkGaimStatusBox *status_box)
10649
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
785 {
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
786 if (status_box->imhtml_visible)
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
787 return gtk_imhtml_get_markup(GTK_IMHTML(status_box->imhtml));
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
788 else
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
789 return NULL;
3353656c119e [gaim-migrate @ 12167]
Sean Egan <seanegan@gmail.com>
parents: 10643
diff changeset
790 }