Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
maynard
Commits
01c31060
Commit
01c31060
authored
Nov 25, 2013
by
Emilio Pozuelo Monfort
Browse files
Add a clock to the panel
parent
b6a530e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
01c31060
...
...
@@ -19,6 +19,7 @@ PKG_CHECK_MODULES([GTK], [
gtk+-3.0 >= 3.7
gtk+-wayland-3.0
libgnome-menu-3.0
gnome-desktop-3.0
])
WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
...
...
shell/Makefile.am
View file @
01c31060
...
...
@@ -13,6 +13,8 @@ weston_gtk_shell_SOURCES = \
gtk-shell.c
\
app-launcher.c
\
app-launcher.h
\
clock.c
\
clock.h
\
launcher-grid.c
\
launcher-grid.h
\
shell-app-system.c
\
...
...
shell/clock.c
0 → 100644
View file @
01c31060
/*
* Copyright (C) 2013 Collabora Ltd.
*
* Author: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
*/
#include
"config.h"
#include
"clock.h"
#include
<gtk/gtk.h>
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include
<libgnome-desktop/gnome-wall-clock.h>
enum
{
PROP_0
,
};
struct
WestonGtkClockPrivate
{
GnomeWallClock
*
wall_clock
;
};
G_DEFINE_TYPE
(
WestonGtkClock
,
weston_gtk_clock
,
GTK_TYPE_LABEL
)
static
void
update_clock
(
GnomeWallClock
*
wall_clock
,
GParamSpec
*
pspec
,
WestonGtkClock
*
self
)
{
gtk_label_set_text
(
GTK_LABEL
(
self
),
gnome_wall_clock_get_clock
(
wall_clock
));
}
static
void
weston_gtk_clock_dispose
(
GObject
*
object
)
{
WestonGtkClock
*
self
=
WESTON_GTK_CLOCK
(
object
);
g_clear_object
(
&
self
->
priv
->
wall_clock
);
G_OBJECT_CLASS
(
weston_gtk_clock_parent_class
)
->
dispose
(
object
);
}
static
void
weston_gtk_clock_init
(
WestonGtkClock
*
self
)
{
self
->
priv
=
G_TYPE_INSTANCE_GET_PRIVATE
(
self
,
WESTON_GTK_CLOCK_TYPE
,
WestonGtkClockPrivate
);
self
->
priv
->
wall_clock
=
gnome_wall_clock_new
();
g_signal_connect
(
self
->
priv
->
wall_clock
,
"notify::clock"
,
G_CALLBACK
(
update_clock
),
self
);
update_clock
(
self
->
priv
->
wall_clock
,
NULL
,
self
);
}
static
void
weston_gtk_clock_class_init
(
WestonGtkClockClass
*
klass
)
{
GObjectClass
*
object_class
=
(
GObjectClass
*
)
klass
;
object_class
->
dispose
=
weston_gtk_clock_dispose
;
g_type_class_add_private
(
object_class
,
sizeof
(
WestonGtkClockPrivate
));
}
GtkWidget
*
weston_gtk_clock_new
(
void
)
{
return
g_object_new
(
WESTON_GTK_CLOCK_TYPE
,
NULL
);
}
shell/clock.h
0 → 100644
View file @
01c31060
/*
* Copyright (C) 2013 Collabora Ltd.
*
* Author: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
*/
#ifndef __WESTON_GTK_CLOCK_H__
#define __WESTON_GTK_CLOCK_H__
#include
<gtk/gtk.h>
#define WESTON_GTK_CLOCK_TYPE (weston_gtk_clock_get_type ())
#define WESTON_GTK_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WESTON_GTK_CLOCK_TYPE, WestonGtkClock))
#define WESTON_GTK_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WESTON_GTK_CLOCK_TYPE, WestonGtkClockClass))
#define WESTON_GTK_IS_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WESTON_GTK_CLOCK_TYPE))
#define WESTON_GTK_IS_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WESTON_GTK_CLOCK_TYPE))
#define WESTON_GTK_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WESTON_GTK_CLOCK_TYPE, WestonGtkClockClass))
typedef
struct
WestonGtkClock
WestonGtkClock
;
typedef
struct
WestonGtkClockClass
WestonGtkClockClass
;
typedef
struct
WestonGtkClockPrivate
WestonGtkClockPrivate
;
struct
WestonGtkClock
{
GtkLabel
parent
;
WestonGtkClockPrivate
*
priv
;
};
struct
WestonGtkClockClass
{
GtkLabelClass
parent_class
;
};
GType
weston_gtk_clock_get_type
(
void
)
G_GNUC_CONST
;
GtkWidget
*
weston_gtk_clock_new
(
void
);
#endif
/* __WESTON_GTK_CLOCK_H__ */
shell/gtk-shell.c
View file @
01c31060
...
...
@@ -6,6 +6,7 @@
#include
"desktop-shell-client-protocol.h"
#include
"launcher-grid.h"
#include
"clock.h"
extern
char
**
environ
;
/* defined by libc */
...
...
@@ -131,7 +132,9 @@ panel_create(struct desktop *desktop)
gtk_box_pack_start
(
GTK_BOX
(
box1
),
button
,
FALSE
,
FALSE
,
0
);
gtk_widget_show
(
button
);
gtk_widget_show
(
box1
);
gtk_box_pack_end
(
GTK_BOX
(
box1
),
weston_gtk_clock_new
(),
FALSE
,
FALSE
,
6
);
gtk_widget_show_all
(
box1
);
gdk_window
=
gtk_widget_get_window
(
panel
->
window
);
gdk_wayland_window_set_use_custom_surface
(
gdk_window
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment