File: browser-page.c

package info (click to toggle)
libgda5 5.2.10-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,168 kB
  • sloc: ansic: 495,319; xml: 10,486; yacc: 5,165; sh: 4,451; makefile: 4,095; php: 1,416; java: 1,300; javascript: 1,298; python: 896; sql: 879; perl: 116
file content (152 lines) | stat: -rw-r--r-- 4,424 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * Copyright (C) 2009 - 2013 Vivien Malerba <malerba@gnome-db.org>
 * Copyright (C) 2010 David King <davidk@openismus.com>
 *
 * 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 Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "browser-page.h"
#include "browser-perspective.h"
static GRecMutex init_rmutex;
#define MUTEX_LOCK() g_rec_mutex_lock(&init_rmutex)
#define MUTEX_UNLOCK() g_rec_mutex_unlock(&init_rmutex)
static void browser_page_class_init (gpointer g_class);

GType
browser_page_get_type (void)
{
	static GType type = 0;

	if (G_UNLIKELY (type == 0)) {
		static const GTypeInfo info = {
			sizeof (BrowserPageIface),
			(GBaseInitFunc) browser_page_class_init,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) NULL,
			NULL,
			NULL,
			0,
			0,
			(GInstanceInitFunc) NULL,
			0
		};
		
		MUTEX_LOCK();
		if (type == 0) {
			type = g_type_register_static (G_TYPE_INTERFACE, "BrowserPage", &info, 0);
			g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
		}
		MUTEX_UNLOCK();
	}
	return type;
}

static void
browser_page_class_init (G_GNUC_UNUSED gpointer g_class)
{
	static gboolean initialized = FALSE;

	MUTEX_LOCK();
	if (! initialized) {
		initialized = TRUE;
	}
	MUTEX_UNLOCK();
}

/**
 * browser_page_get_actions_group
 * @page: an object implementing the #BrowserPage interface
 *
 * Get the #GtkActionGroup from a @page to represent its specific actions.
 *
 * Returns: a new #GtkActionGroup
 */
GtkActionGroup *
browser_page_get_actions_group (BrowserPage *page)
{
	g_return_val_if_fail (IS_BROWSER_PAGE (page), NULL);
	
	if (BROWSER_PAGE_GET_CLASS (page)->i_get_actions_group)
		return (BROWSER_PAGE_GET_CLASS (page)->i_get_actions_group) (page);
	else
		return NULL;
}

/**
 * browser_page_get_actions_ui
 * @page: an object implementing the #BrowserPage interface
 *
 * Get the UI definition from @page to represent how its specific actions (obtained
 * using browser_page_get_actions_group()) are to be integrated in a #BrowserWindow's menu
 * and toolbar.
 *
 * Returns: a read-only string
 */
const gchar *
browser_page_get_actions_ui (BrowserPage *page)
{
	g_return_val_if_fail (IS_BROWSER_PAGE (page), NULL);
	
	if (BROWSER_PAGE_GET_CLASS (page)->i_get_actions_ui)
		return (BROWSER_PAGE_GET_CLASS (page)->i_get_actions_ui) (page);
	else
		return NULL;
}

/**
 * browser_page_get_perspective
 * @page: an object implementing the #BrowserPage interface
 *
 * Finds the BrowserPerspective in which @page is. Note that the #BrowserPerspective may
 * have changed since a previous call as users are allowed to do some drag and drop between
 * browser's windows which contain different #BrowserPerspective objects.
 *
 * Returns: the #BrowserPerspective
 */
BrowserPerspective *
browser_page_get_perspective (BrowserPage *page)
{
	GtkWidget *wid;
	for (wid = gtk_widget_get_parent (GTK_WIDGET (page)); wid; wid = gtk_widget_get_parent (wid))
		if (IS_BROWSER_PERSPECTIVE (wid))
			return BROWSER_PERSPECTIVE (wid);
	return NULL;
}

/**
 * browser_page_get_tab_label
 * @page: an object implementing the #BrowserPage interface
 * @out_close_button: a place holder to hold a pointer to a close button
 *
 * Get a new widget to be packed in a notebook's tab label.
 *
 * If @out_close_button is not %NULL, then the implementation may decide to add
 * a button to close the tab; if @out_close_button is %NULL, then it should not add
 * any close button.
 *
 * Returns: a new #GtkWidget, or %NULL
 */
GtkWidget *
browser_page_get_tab_label (BrowserPage *page, GtkWidget **out_close_button)
{
	g_return_val_if_fail (IS_BROWSER_PAGE (page), NULL);
	
	if (out_close_button)
		*out_close_button = NULL;
	if (BROWSER_PAGE_GET_CLASS (page)->i_get_tab_label)
		return (BROWSER_PAGE_GET_CLASS (page)->i_get_tab_label) (page, out_close_button);
	else
		return NULL;	
}