empathy-status-preset-dialog.c 16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * empathy-status-preset-dialog.c
 *
 * EmpathyStatusPresetDialog - a dialog for adding and removing preset status
 * messages.
 *
 * Copyright (C) 2009 Collabora Ltd.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
22 23
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
24
 *
25
 * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
26
 */
Davyd Madeley's avatar
Davyd Madeley committed
27 28 29 30 31 32 33 34 35
/**
 * SECTION:empathy-status-preset-dialog
 * @title: EmpathyStatusPresetDialog
 * @short_description: a dialog for editing the saved status messages
 * @include: libempathy-gtk/empathy-status-preset-dialog.h
 *
 * #EmpathyStatusPresetDialog is a dialog allowing the user to add/remove/edit
 * their saved status messages.
 */
36 37 38 39 40 41

#include "config.h"

#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>

42
#include <libempathy/empathy-utils.h>
43 44 45 46 47
#include <libempathy/empathy-status-presets.h>

#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>

48
#include "empathy-ui-utils.h"
49 50 51 52
#include "empathy-status-preset-dialog.h"

#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyStatusPresetDialog)

53 54
G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG);

55 56 57 58
static TpConnectionPresenceType states[] = {
	TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
	TP_CONNECTION_PRESENCE_TYPE_BUSY,
	TP_CONNECTION_PRESENCE_TYPE_AWAY,
59
};
60 61 62 63

typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv;
struct _EmpathyStatusPresetDialogPriv
{
64
	/* block status_preset_dialog_add_combo_changed () when > 0 */
65 66
	int block_add_combo_changed;

67
	GtkWidget *presets_treeview;
Davyd Madeley's avatar
Davyd Madeley committed
68 69 70
	GtkWidget *add_combobox;
	GtkWidget *add_button;

71
	GtkTreeIter selected_iter;
Davyd Madeley's avatar
Davyd Madeley committed
72
	gboolean add_combo_changed;
73
	char *saved_status;
74 75 76 77 78 79 80 81
};

enum
{
	PRESETS_STORE_STATE,
	PRESETS_STORE_ICON_NAME,
	PRESETS_STORE_STATUS,
	PRESETS_STORE_N_COLS
82 83
};

Davyd Madeley's avatar
Davyd Madeley committed
84 85 86 87 88 89 90 91 92
enum
{
	ADD_COMBO_STATE,
	ADD_COMBO_ICON_NAME,
	ADD_COMBO_STATUS,
	ADD_COMBO_DEFAULT_TEXT,
	ADD_COMBO_N_COLS
};

93 94 95 96 97 98 99 100 101 102
static void
empathy_status_preset_dialog_finalize (GObject *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);

	g_free (priv->saved_status);

	G_OBJECT_CLASS (empathy_status_preset_dialog_parent_class)->finalize (self);
}

103 104 105 106 107 108
static void
empathy_status_preset_dialog_class_init (EmpathyStatusPresetDialogClass *class)
{
	GObjectClass *gobject_class;

	gobject_class = G_OBJECT_CLASS (class);
109
	gobject_class->finalize = empathy_status_preset_dialog_finalize;
110 111 112 113 114

	g_type_class_add_private (gobject_class,
			sizeof (EmpathyStatusPresetDialogPriv));
}

115
static void
Davyd Madeley's avatar
Davyd Madeley committed
116
status_preset_dialog_presets_update (EmpathyStatusPresetDialog *self)
117 118 119
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkListStore *store;
120
	guint i;
121 122 123 124

	store = GTK_LIST_STORE (gtk_tree_view_get_model (
				GTK_TREE_VIEW (priv->presets_treeview)));

Davyd Madeley's avatar
Davyd Madeley committed
125 126
	gtk_list_store_clear (store);

Davyd Madeley's avatar
Davyd Madeley committed
127
	for (i = 0; i < G_N_ELEMENTS (states); i++) {
128 129 130 131
		GList *presets, *l;
		const char *icon_name;

		icon_name = empathy_icon_name_for_presence (states[i]);
132 133
		presets = empathy_status_presets_get (states[i], -1);
		presets = g_list_sort (presets, (GCompareFunc) g_utf8_collate);
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149

		for (l = presets; l; l = l->next) {
			char *preset = (char *) l->data;

			gtk_list_store_insert_with_values (store,
					NULL, -1,
					PRESETS_STORE_STATE, states[i],
					PRESETS_STORE_ICON_NAME, icon_name,
					PRESETS_STORE_STATUS, preset,
					-1);
		}

		g_list_free (presets);
	}
}

Davyd Madeley's avatar
Davyd Madeley committed
150 151 152 153
static void
status_preset_add_combo_reset (EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
154 155 156 157
	GtkWidget *entry;

	entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox));
	gtk_entry_set_text (GTK_ENTRY (entry), "");
Davyd Madeley's avatar
Davyd Madeley committed
158

159 160
	gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->add_combobox),
			&priv->selected_iter);
Davyd Madeley's avatar
Davyd Madeley committed
161 162 163 164 165 166 167 168 169
}

static void
status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkWidget *combobox = priv->add_combobox;
	GtkListStore *store;
	GtkCellRenderer *renderer;
170
	guint i;
Davyd Madeley's avatar
Davyd Madeley committed
171 172

	store = gtk_list_store_new (ADD_COMBO_N_COLS,
173
			G_TYPE_UINT,		/* ADD_COMBO_STATE */
Davyd Madeley's avatar
Davyd Madeley committed
174 175 176 177 178 179 180 181
			G_TYPE_STRING,		/* ADD_COMBO_ICON_NAME */
			G_TYPE_STRING,		/* ADD_COMBO_STATUS */
			G_TYPE_STRING);		/* ADD_COMBO_DEFAULT_TEXT */

	gtk_combo_box_set_model (GTK_COMBO_BOX (combobox),
				 GTK_TREE_MODEL (store));
	g_object_unref (store);

182
	gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (combobox),
Davyd Madeley's avatar
Davyd Madeley committed
183 184 185 186 187 188 189
			ADD_COMBO_DEFAULT_TEXT);

	for (i = 0; i < G_N_ELEMENTS (states); i++) {
		gtk_list_store_insert_with_values (store, NULL, -1,
				ADD_COMBO_STATE, states[i],
				ADD_COMBO_ICON_NAME, empathy_icon_name_for_presence (states[i]),
				ADD_COMBO_STATUS, empathy_presence_get_default_message (states[i]),
190
				ADD_COMBO_DEFAULT_TEXT, "",
Davyd Madeley's avatar
Davyd Madeley committed
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
				-1);
	}

	gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox));

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE);
	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer,
			"icon-name", ADD_COMBO_ICON_NAME);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combobox), renderer,
			"text", ADD_COMBO_STATUS);
	g_object_set (renderer,
			"style", PANGO_STYLE_ITALIC,
			"foreground", "Gray", /* FIXME - theme */
			NULL);

210
	gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
Davyd Madeley's avatar
Davyd Madeley committed
211 212
}

213 214 215 216 217 218 219 220 221 222
static void
status_preset_dialog_status_edited (GtkCellRendererText *renderer,
				    char *path_str,
				    char *new_status,
				    EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeIter iter;
223
	TpConnectionPresenceType state;
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
	char *old_status;
	gboolean valid;

	if (strlen (new_status) == 0) {
		/* status is empty, ignore */
		return;
	}

	model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->presets_treeview));
	path = gtk_tree_path_new_from_string (path_str);
	valid = gtk_tree_model_get_iter (model, &iter, path);
	gtk_tree_path_free (path);

	if (!valid) return;

	gtk_tree_model_get (model, &iter,
			PRESETS_STORE_STATE, &state,
			PRESETS_STORE_STATUS, &old_status,
			-1);

	if (!strcmp (old_status, new_status)) {
		/* statuses are the same */
		g_free (old_status);
		return;
	}

	DEBUG ("EDITED STATUS (%s) -> (%s)\n", old_status, new_status);

	empathy_status_presets_remove (state, old_status);
	empathy_status_presets_set_last (state, new_status);

	g_free (old_status);

	status_preset_dialog_presets_update (self);
}

260 261 262 263 264 265 266 267 268 269
static void
status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkWidget *treeview = priv->presets_treeview;
	GtkListStore *store;
	GtkTreeViewColumn *column;
	GtkCellRenderer *renderer;

	store = gtk_list_store_new (PRESETS_STORE_N_COLS,
270
			G_TYPE_UINT,		/* PRESETS_STORE_STATE */
271 272 273 274 275 276 277
			G_TYPE_STRING,		/* PRESETS_STORE_ICON_NAME */
			G_TYPE_STRING);		/* PRESETS_STORE_STATUS */

	gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
				 GTK_TREE_MODEL (store));
	g_object_unref (store);

Davyd Madeley's avatar
Davyd Madeley committed
278
	status_preset_dialog_presets_update (self);
279 280 281 282 283 284 285 286 287 288 289 290 291

	column = gtk_tree_view_column_new ();
	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

	renderer = gtk_cell_renderer_pixbuf_new ();
	gtk_tree_view_column_pack_start (column, renderer, FALSE);
	gtk_tree_view_column_add_attribute (column, renderer,
			"icon-name", PRESETS_STORE_ICON_NAME);

	renderer = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, renderer, TRUE);
	gtk_tree_view_column_add_attribute (column, renderer,
			"text", PRESETS_STORE_STATUS);
292 293 294
	g_object_set (renderer,
			"editable", TRUE,
			NULL);
295 296
	g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

297 298
	g_signal_connect (renderer, "edited",
			G_CALLBACK (status_preset_dialog_status_edited), self);
299 300 301 302 303 304 305 306 307 308 309
}

static void
status_preset_dialog_preset_selection_changed (GtkTreeSelection *selection,
					       GtkWidget *remove_button)
{
	/* update the sensitivity of the Remove button */
	gtk_widget_set_sensitive (remove_button,
			gtk_tree_selection_get_selected (selection, NULL, NULL));
}

Davyd Madeley's avatar
Davyd Madeley committed
310
static void
Davyd Madeley's avatar
Davyd Madeley committed
311
status_preset_dialog_preset_remove (GtkButton *button,
Davyd Madeley's avatar
Davyd Madeley committed
312 313 314 315 316 317
				    EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreeIter iter;
318
	TpConnectionPresenceType state;
Davyd Madeley's avatar
Davyd Madeley committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
	char *status;

	selection = gtk_tree_view_get_selection (
			GTK_TREE_VIEW (priv->presets_treeview));

	g_return_if_fail (gtk_tree_selection_get_selected (selection,
				&model, &iter));

	gtk_tree_model_get (model, &iter,
			PRESETS_STORE_STATE, &state,
			PRESETS_STORE_STATUS, &status,
			-1);

	DEBUG ("REMOVE PRESET (%i, %s)\n", state, status);
	empathy_status_presets_remove (state, status);

	g_free (status);

Davyd Madeley's avatar
Davyd Madeley committed
337
	status_preset_dialog_presets_update (self);
Davyd Madeley's avatar
Davyd Madeley committed
338 339
}

340 341 342 343 344 345 346 347 348 349 350 351 352 353
static void
status_preset_dialog_set_add_combo_changed (EmpathyStatusPresetDialog *self,
					    gboolean state,
					    gboolean reset_text)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkWidget *entry;

	entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox));

	priv->add_combo_changed = state;
	gtk_widget_set_sensitive (priv->add_button, state);

	if (state) {
354
		gtk_widget_override_color (entry, 0, NULL);
355
	} else {
356
		GdkRGBA color;
357

358 359
		if (gdk_rgba_parse (&color, "Gray")) /* FIXME - theme */
			gtk_widget_override_color (entry, 0, &color);
360 361 362 363 364 365 366 367 368 369

		if (reset_text) {
			priv->block_add_combo_changed++;
			gtk_entry_set_text (GTK_ENTRY (entry),
					_("Enter Custom Message"));
			priv->block_add_combo_changed--;
		}
	}
}

Davyd Madeley's avatar
Davyd Madeley committed
370 371 372 373 374 375 376 377 378
static void
status_preset_dialog_add_combo_changed (GtkComboBox *combo,
					EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	GtkWidget *entry;
	GtkTreeModel *model;
	GtkTreeIter iter;

379 380
	if (priv->block_add_combo_changed) return;

Davyd Madeley's avatar
Davyd Madeley committed
381 382 383 384 385 386
	model = gtk_combo_box_get_model (combo);
	entry = gtk_bin_get_child (GTK_BIN (combo));

	if (gtk_combo_box_get_active_iter (combo, &iter)) {
		char *icon_name;

387
		priv->selected_iter = iter;
Davyd Madeley's avatar
Davyd Madeley committed
388 389 390 391 392 393 394 395 396 397
		gtk_tree_model_get (model, &iter,
				PRESETS_STORE_ICON_NAME, &icon_name,
				-1);

		gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
				GTK_ENTRY_ICON_PRIMARY,
				icon_name);

		g_free (icon_name);

398
		status_preset_dialog_set_add_combo_changed (self, FALSE, TRUE);
399 400 401 402
		if (priv->saved_status && strlen (priv->saved_status) > 0) {
			gtk_entry_set_text (GTK_ENTRY (entry),
					priv->saved_status);
		}
Davyd Madeley's avatar
Davyd Madeley committed
403
	} else {
404 405 406
		g_free (priv->saved_status);
		priv->saved_status = g_strdup (
				gtk_entry_get_text (GTK_ENTRY (entry)));
407 408

		status_preset_dialog_set_add_combo_changed (self,
409
				strlen (priv->saved_status) > 0, FALSE);
Davyd Madeley's avatar
Davyd Madeley committed
410 411 412 413 414 415 416 417
	}
}

static void
status_preset_dialog_add_preset (GtkWidget *widget,
				 EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
418
	GtkTreeModel *model;
419
	GtkTreeIter iter;
Davyd Madeley's avatar
Davyd Madeley committed
420
	GtkWidget *entry;
421
	TpConnectionPresenceType state, cstate;
Davyd Madeley's avatar
Davyd Madeley committed
422
	const char *status;
423 424
	char *cstatus;
	gboolean valid, match = FALSE;
Davyd Madeley's avatar
Davyd Madeley committed
425 426 427

	g_return_if_fail (priv->add_combo_changed);

428
	model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->add_combobox));
Davyd Madeley's avatar
Davyd Madeley committed
429
	entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox));
430

Davyd Madeley's avatar
Davyd Madeley committed
431
	status = gtk_entry_get_text (GTK_ENTRY (entry));
432 433 434
	gtk_tree_model_get (model, &priv->selected_iter,
			PRESETS_STORE_STATE, &state,
			-1);
Davyd Madeley's avatar
Davyd Madeley committed
435

436 437
	DEBUG ("ADD PRESET (%i, %s)\n", state, status);
	empathy_status_presets_set_last (state, status);
Davyd Madeley's avatar
Davyd Madeley committed
438

Davyd Madeley's avatar
Davyd Madeley committed
439
	status_preset_dialog_presets_update (self);
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467

	/* select the added status*/
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->presets_treeview));
	for (valid = gtk_tree_model_get_iter_first (model, &iter);
             valid;
             valid = gtk_tree_model_iter_next (model, &iter)) {

		gtk_tree_model_get (model, &iter,
				PRESETS_STORE_STATE, &cstate,
				PRESETS_STORE_STATUS, &cstatus,
				-1);

		match = (cstate == state) && (strcmp (cstatus, status) == 0);

		g_free (cstatus);

		if (match) {
			GtkTreePath *path;

			path = gtk_tree_model_get_path (model, &iter);

			gtk_tree_selection_select_iter (
				gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->presets_treeview)),
				&iter);
			gtk_tree_view_scroll_to_cell (
					GTK_TREE_VIEW (priv->presets_treeview),
					path, NULL,
					FALSE, 0., 0.);
468
			gtk_tree_path_free (path);
469 470 471
			break;
		}
        }
472 473 474 475

	if (!match) g_warning ("No match");

	status_preset_add_combo_reset (self);
Davyd Madeley's avatar
Davyd Madeley committed
476 477
}

478 479 480 481 482
static gboolean
status_preset_dialog_add_combo_press_event (GtkWidget *widget,
					    GdkEventButton *event,
					    EmpathyStatusPresetDialog *self)
{
483
	if (!gtk_widget_has_focus (widget)) {
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
		/* if the widget isn't focused, focus it and select the text */
		gtk_widget_grab_focus (widget);
		gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);

		return TRUE;
	}

	return FALSE;
}

static gboolean
status_preset_dialog_add_combo_focus_out (GtkWidget *widget,
					  GdkEventFocus *event,
					  EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = GET_PRIV (self);
	const char *status;

	gtk_editable_set_position (GTK_EDITABLE (widget), 0);

	status = gtk_entry_get_text (GTK_ENTRY (widget));
	status_preset_dialog_set_add_combo_changed (self,
			priv->add_combo_changed && strlen (status) > 0,
			TRUE);

	return FALSE;
}

512 513 514 515 516 517 518
static void
empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self)
{
	EmpathyStatusPresetDialogPriv *priv = self->priv =
		G_TYPE_INSTANCE_GET_PRIVATE (self,
			EMPATHY_TYPE_STATUS_PRESET_DIALOG,
			EmpathyStatusPresetDialogPriv);
519
	GtkBuilder *gui;
520
	GtkWidget *toplevel_vbox, *remove_button, *entry;
521 522
	char *filename;

523 524
	gtk_window_set_title (GTK_WINDOW (self),
			_("Edit Custom Messages"));
525 526 527 528 529 530 531 532 533
	gtk_dialog_add_button (GTK_DIALOG (self),
			GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);

	filename = empathy_file_lookup ("empathy-status-preset-dialog.ui",
			"libempathy-gtk");
	gui = empathy_builder_get_file (filename,
			"toplevel-vbox", &toplevel_vbox,
			"presets-treeview", &priv->presets_treeview,
			"remove-button", &remove_button,
Davyd Madeley's avatar
Davyd Madeley committed
534 535
			"add-combobox", &priv->add_combobox,
			"add-button", &priv->add_button,
536 537 538 539 540 541 542 543
			NULL);
	g_free (filename);

	g_signal_connect (gtk_tree_view_get_selection (
				GTK_TREE_VIEW (priv->presets_treeview)),
			"changed",
			G_CALLBACK (status_preset_dialog_preset_selection_changed),
			remove_button);
Davyd Madeley's avatar
Davyd Madeley committed
544

545 546 547 548 549 550 551 552
	entry = gtk_bin_get_child (GTK_BIN (priv->add_combobox));
	g_signal_connect (entry, "activate",
			G_CALLBACK (status_preset_dialog_add_preset), self);
	g_signal_connect (entry, "button-press-event",
			G_CALLBACK (status_preset_dialog_add_combo_press_event),
			self);
	g_signal_connect (entry, "focus-out-event",
			G_CALLBACK (status_preset_dialog_add_combo_focus_out),
Davyd Madeley's avatar
Davyd Madeley committed
553 554
			self);

Davyd Madeley's avatar
Davyd Madeley committed
555 556
	empathy_builder_connect (gui, self,
			"remove-button", "clicked", status_preset_dialog_preset_remove,
Davyd Madeley's avatar
Davyd Madeley committed
557 558
			"add-combobox", "changed", status_preset_dialog_add_combo_changed,
			"add-button", "clicked", status_preset_dialog_add_preset,
Davyd Madeley's avatar
Davyd Madeley committed
559
			NULL);
560

Davyd Madeley's avatar
Davyd Madeley committed
561 562 563
	status_preset_dialog_setup_presets_treeview (self);
	status_preset_dialog_setup_add_combobox (self);

564 565
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))),
	    toplevel_vbox, TRUE, TRUE, 0);
566

567
	g_object_unref (gui);
568 569
}

Davyd Madeley's avatar
Davyd Madeley committed
570 571 572 573 574 575 576 577 578
/**
 * empathy_status_preset_dialog_new:
 * @parent: the parent window of this dialog (or NULL)
 *
 * Creates a new #EmpathyStatusPresetDialog that allows the user to
 * add/remove/edit their saved status messages.
 *
 * Returns: the newly constructed dialog.
 */
579 580 581 582 583 584 585 586 587 588 589 590
GtkWidget *
empathy_status_preset_dialog_new (GtkWindow *parent)
{
	GtkWidget *self = g_object_new (EMPATHY_TYPE_STATUS_PRESET_DIALOG,
			NULL);

	if (parent) {
		gtk_window_set_transient_for (GTK_WINDOW (self), parent);
	}

	return self;
}