~ubuntu-branches/ubuntu/maverick/conglomerate/maverick

« back to all changes in this revision

Viewing changes to src/cong-property-page.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-08 05:07:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108050706-bcg60nwqf1z3w0d6
Tags: 0.9.1-1ubuntu1
* Resynchronise with Debian (Closes: #4397).
  - Thanks, Jordan Mantha.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
 
 
3
/*
 
4
 * cong-property-page.c
 
5
 *
 
6
 * Copyright (C) 2005 David Malcolm
 
7
 *
 
8
 * Conglomerate is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License as
 
10
 * published by the Free Software Foundation; either version 2 of the
 
11
 * License, or (at your option) any later version.
 
12
 *
 
13
 * Conglomerate is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
21
 *
 
22
 * Authors: David Malcolm <david@davemalcolm.demon.co.uk>
 
23
 */
 
24
 
 
25
#include "global.h"
 
26
#include <glib.h>
 
27
#include "cong-property-page.h"
 
28
#include "cong-eel.h"
 
29
#include "cong-util.h"
 
30
#include "cong-command.h"
 
31
 
 
32
#define PRIVATE(x) ((x)->private)
 
33
 
 
34
/* Internal types: */
 
35
struct CongPropertyPageDetails
 
36
{
 
37
        CongDocument *doc;
 
38
        gulong handler_id_selection_change;
 
39
};
 
40
 
 
41
/* Internal function declarations: */
 
42
static void
 
43
finalize (GObject *object);
 
44
 
 
45
static void
 
46
dispose (GObject *object);
 
47
 
 
48
static void
 
49
on_selection_change (CongDocument *doc, 
 
50
                     CongPropertyPage *property_page);
 
51
 
 
52
/* Exported function definitions: */
 
53
GNOME_CLASS_BOILERPLATE(CongPropertyPage, 
 
54
                        cong_property_page,
 
55
                        GtkHBox,
 
56
                        GTK_TYPE_HBOX);
 
57
 
 
58
CONG_EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (cong_property_page, selection_change_handler);
 
59
 
 
60
static void
 
61
cong_property_page_class_init (CongPropertyPageClass *klass)
 
62
{
 
63
        CONG_EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass,
 
64
                                              cong_property_page,
 
65
                                              selection_change_handler);
 
66
        G_OBJECT_CLASS (klass)->finalize = finalize;
 
67
        G_OBJECT_CLASS (klass)->dispose = dispose;
 
68
}
 
69
 
 
70
static void
 
71
cong_property_page_instance_init (CongPropertyPage *property_page)
 
72
{
 
73
        property_page->private = g_new0(CongPropertyPageDetails,1);
 
74
}
 
75
 
 
76
/**
 
77
 * cong_property_page_construct:
 
78
 * @property_page:
 
79
 * @doc:
 
80
 * @node:
 
81
 * @ns_ptr:
 
82
 * @property_name:
 
83
 *
 
84
 * TODO: Write me
 
85
 * Returns:
 
86
 */
 
87
CongPropertyPage*
 
88
cong_property_page_construct (CongPropertyPage *property_page,
 
89
                              CongDocument *doc)
 
90
{
 
91
        g_return_val_if_fail (IS_CONG_PROPERTY_PAGE(property_page), NULL);
 
92
 
 
93
        PRIVATE(property_page)->doc = doc;
 
94
        g_object_ref(doc);
 
95
 
 
96
        PRIVATE(property_page)->handler_id_selection_change = g_signal_connect_after (G_OBJECT(doc),
 
97
                                                                                      "selection_change",
 
98
                                                                                      G_CALLBACK(on_selection_change),
 
99
                                                                                      property_page);
 
100
        return CONG_PROPERTY_PAGE (property_page);
 
101
}
 
102
 
 
103
/**
 
104
 * cong_property_page_get_document:
 
105
 * @property_page:
 
106
 *
 
107
 * TODO: Write me
 
108
 * Returns:
 
109
 */
 
110
CongDocument*
 
111
cong_property_page_get_document (CongPropertyPage *property_page)
 
112
{
 
113
        g_return_val_if_fail (IS_CONG_PROPERTY_PAGE(property_page), NULL);
 
114
 
 
115
        return PRIVATE(property_page)->doc; 
 
116
}
 
117
 
 
118
/* Internal function definitions: */
 
119
static void
 
120
finalize (GObject *object)
 
121
{
 
122
        CongPropertyPage *property_page = CONG_PROPERTY_PAGE(object);
 
123
        
 
124
        g_free (property_page->private);
 
125
        property_page->private = NULL;
 
126
        
 
127
        G_OBJECT_CLASS (parent_class)->finalize (object);
 
128
}
 
129
 
 
130
static void
 
131
dispose (GObject *object)
 
132
{
 
133
        CongPropertyPage *property_page = CONG_PROPERTY_PAGE(object);
 
134
 
 
135
        if (PRIVATE(property_page)->doc) {
 
136
        
 
137
                g_signal_handler_disconnect (G_OBJECT (PRIVATE(property_page)->doc),
 
138
                                             PRIVATE(property_page)->handler_id_selection_change);
 
139
                PRIVATE(property_page)->handler_id_selection_change = 0;
 
140
 
 
141
                g_object_unref (G_OBJECT (PRIVATE(property_page)->doc));
 
142
                PRIVATE(property_page)->doc = NULL;
 
143
        }
 
144
                
 
145
        GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
 
146
}
 
147
 
 
148
static void
 
149
on_selection_change (CongDocument *doc, 
 
150
                     CongPropertyPage *property_page)
 
151
{
 
152
        g_return_if_fail (IS_CONG_PROPERTY_PAGE(property_page));
 
153
 
 
154
        CONG_EEL_CALL_METHOD (CONG_PROPERTY_PAGE_CLASS,
 
155
                              property_page,
 
156
                              selection_change_handler, 
 
157
                              (property_page));
 
158
}