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
|
/*
* Tabbed notebook
*
* Copyright (C) 2017 Patrick McDermott
*
* This file is part of Marquee.
*
* Marquee 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 3 of the License, or
* (at your option) any later version.
*
* Marquee 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 Marquee. If not, see <http://www.gnu.org/licenses/>.
*/
#include "notebook.h"
#include <glib.h>
#include <gtk/gtk.h>
#include "window.h"
struct _MqNotebook {
GtkNotebook parent_instance;
MqWindow *window;
};
enum {
PROP_WINDOW = 1,
N_PROPERTIES
};
static GParamSpec *obj_properties[N_PROPERTIES] = {NULL,};
struct _MqNotebookClass {
GtkNotebookClass parent_class;
};
G_DEFINE_TYPE(MqNotebook, mq_notebook, GTK_TYPE_NOTEBOOK)
static void
get_property(GObject *object, guint property_id, GValue *value,
GParamSpec *param_spec)
{
MqNotebook *notebook;
notebook = MQ_NOTEBOOK(object);
switch (property_id) {
case PROP_WINDOW:
g_value_set_object(value, notebook->window);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
param_spec);
break;
}
}
static void
set_property(GObject *object, guint property_id, const GValue *value,
GParamSpec *param_spec)
{
MqNotebook *notebook;
notebook = MQ_NOTEBOOK(object);
switch (property_id) {
case PROP_WINDOW:
notebook->window = g_value_get_object(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
param_spec);
break;
}
}
static void
mq_notebook_class_init(MqNotebookClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->get_property = get_property;
object_class->set_property = set_property;
obj_properties[PROP_WINDOW] = g_param_spec_object(
"window",
"MqWindow",
"The parent MqWindow instance",
MQ_TYPE_WINDOW,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
g_object_class_install_properties(object_class, N_PROPERTIES,
obj_properties);
}
static void
mq_notebook_init(MqNotebook *notebook)
{
gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), TRUE);
gtk_notebook_set_group_name(GTK_NOTEBOOK(notebook), "mq-tabs");
gtk_widget_set_can_focus(GTK_WIDGET(notebook), FALSE);
}
GtkWidget *
mq_notebook_new(MqWindow *window)
{
return g_object_new(MQ_TYPE_NOTEBOOK,
"window", window,
NULL);
}
|