1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
#include <glib/gi18n.h>
30
#include <glib-object.h>
33
#include "gdm-host-chooser-dialog.h"
34
#include "gdm-host-chooser-widget.h"
36
#define GDM_HOST_CHOOSER_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_HOST_CHOOSER_DIALOG, GdmHostChooserDialogPrivate))
38
struct GdmHostChooserDialogPrivate
40
GtkWidget *chooser_widget;
49
static void gdm_host_chooser_dialog_class_init (GdmHostChooserDialogClass *klass);
50
static void gdm_host_chooser_dialog_init (GdmHostChooserDialog *host_chooser_dialog);
51
static void gdm_host_chooser_dialog_finalize (GObject *object);
53
G_DEFINE_TYPE (GdmHostChooserDialog, gdm_host_chooser_dialog, GTK_TYPE_DIALOG)
56
gdm_host_chooser_dialog_get_host (GdmHostChooserDialog *dialog)
60
g_return_val_if_fail (GDM_IS_HOST_CHOOSER_DIALOG (dialog), NULL);
62
host = gdm_host_chooser_widget_get_host (GDM_HOST_CHOOSER_WIDGET (dialog->priv->chooser_widget));
68
_gdm_host_chooser_dialog_set_kind_mask (GdmHostChooserDialog *dialog,
71
if (dialog->priv->kind_mask != kind_mask) {
72
dialog->priv->kind_mask = kind_mask;
77
gdm_host_chooser_dialog_set_property (GObject *object,
82
GdmHostChooserDialog *self;
84
self = GDM_HOST_CHOOSER_DIALOG (object);
88
_gdm_host_chooser_dialog_set_kind_mask (self, g_value_get_int (value));
91
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
97
gdm_host_chooser_dialog_get_property (GObject *object,
104
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
110
on_response (GdmHostChooserDialog *dialog,
113
switch (response_id) {
114
case GTK_RESPONSE_APPLY:
115
gdm_host_chooser_widget_refresh (GDM_HOST_CHOOSER_WIDGET (dialog->priv->chooser_widget));
116
g_signal_stop_emission_by_name (dialog, "response");
124
gdm_host_chooser_dialog_constructor (GType type,
125
guint n_construct_properties,
126
GObjectConstructParam *construct_properties)
128
GdmHostChooserDialog *dialog;
130
dialog = GDM_HOST_CHOOSER_DIALOG (G_OBJECT_CLASS (gdm_host_chooser_dialog_parent_class)->constructor (type,
131
n_construct_properties,
132
construct_properties));
135
dialog->priv->chooser_widget = gdm_host_chooser_widget_new (dialog->priv->kind_mask);
136
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->priv->chooser_widget);
137
gtk_container_set_border_width (GTK_CONTAINER (dialog->priv->chooser_widget), 5);
139
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
140
GTK_STOCK_REFRESH, GTK_RESPONSE_APPLY,
141
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
142
GTK_STOCK_CONNECT, GTK_RESPONSE_OK,
145
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
146
gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
147
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
148
gtk_window_set_title (GTK_WINDOW (dialog), _("Select System"));
149
gtk_window_set_icon_name (GTK_WINDOW (dialog), "computer");
151
g_signal_connect (dialog,
153
G_CALLBACK (on_response),
156
gtk_widget_show_all (GTK_WIDGET (dialog));
158
return G_OBJECT (dialog);
162
gdm_host_chooser_dialog_dispose (GObject *object)
164
g_debug ("Disposing host_chooser_dialog");
166
G_OBJECT_CLASS (gdm_host_chooser_dialog_parent_class)->dispose (object);
170
gdm_host_chooser_dialog_class_init (GdmHostChooserDialogClass *klass)
172
GObjectClass *object_class = G_OBJECT_CLASS (klass);
174
object_class->get_property = gdm_host_chooser_dialog_get_property;
175
object_class->set_property = gdm_host_chooser_dialog_set_property;
176
object_class->constructor = gdm_host_chooser_dialog_constructor;
177
object_class->dispose = gdm_host_chooser_dialog_dispose;
178
object_class->finalize = gdm_host_chooser_dialog_finalize;
180
g_object_class_install_property (object_class,
182
g_param_spec_int ("kind-mask",
188
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
190
g_type_class_add_private (klass, sizeof (GdmHostChooserDialogPrivate));
194
gdm_host_chooser_dialog_init (GdmHostChooserDialog *dialog)
196
dialog->priv = GDM_HOST_CHOOSER_DIALOG_GET_PRIVATE (dialog);
200
gdm_host_chooser_dialog_finalize (GObject *object)
202
GdmHostChooserDialog *host_chooser_dialog;
204
g_return_if_fail (object != NULL);
205
g_return_if_fail (GDM_IS_HOST_CHOOSER_DIALOG (object));
207
host_chooser_dialog = GDM_HOST_CHOOSER_DIALOG (object);
209
g_return_if_fail (host_chooser_dialog->priv != NULL);
211
G_OBJECT_CLASS (gdm_host_chooser_dialog_parent_class)->finalize (object);
215
gdm_host_chooser_dialog_new (int kind_mask)
219
object = g_object_new (GDM_TYPE_HOST_CHOOSER_DIALOG,
220
"kind-mask", kind_mask,
223
return GTK_WIDGET (object);