summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/evbp-viewer.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/src/evbp-viewer.c b/src/evbp-viewer.c
index ca94962..7ed81e7 100644
--- a/src/evbp-viewer.c
+++ b/src/evbp-viewer.c
@@ -25,31 +25,6 @@
G_DEFINE_TYPE(EvbpViewer, evbp_viewer, GTK_TYPE_BOX)
static void
-evbp_viewer_dispose(GObject *object)
-{
- EvbpViewer *viewer = EVBP_VIEWER(object);
-
- if (viewer->document) {
- g_object_unref(viewer->document);
- viewer->document = NULL;
- }
- if (viewer->model) {
- g_object_unref(viewer->model);
- viewer->model = NULL;
- }
- if (viewer->action_group) {
- g_object_unref(viewer->action_group);
- viewer->action_group = NULL;
- }
- if (viewer->ui_manager) {
- g_object_unref(viewer->ui_manager);
- viewer->ui_manager = NULL;
- }
-
- G_OBJECT_CLASS(evbp_viewer_parent_class)->dispose(object);
-}
-
-static void
evbp_viewer_zoom_best_fit(GtkToggleAction *action, EvbpViewer *viewer)
{
ev_document_model_set_sizing_mode(viewer->model,
@@ -150,11 +125,52 @@ page_action_link_activated(GtkAction *action, GObject *obj, gpointer user_data)
}
static void
+evbp_viewer_dispose(GObject *object)
+{
+ EvbpViewer *viewer = EVBP_VIEWER(object);
+
+ if (viewer->document) {
+ g_object_unref(viewer->document);
+ viewer->document = NULL;
+ }
+ if (viewer->model) {
+ g_object_unref(viewer->model);
+ viewer->model = NULL;
+ }
+ if (viewer->action_group) {
+ g_object_unref(viewer->action_group);
+ viewer->action_group = NULL;
+ }
+ if (viewer->ui_manager) {
+ g_object_unref(viewer->ui_manager);
+ viewer->ui_manager = NULL;
+ }
+
+ G_OBJECT_CLASS(evbp_viewer_parent_class)->dispose(object);
+}
+
+static void
+evbp_viewer_hierarchy_changed(GtkWidget *widget, GtkWidget *previous_toplevel)
+{
+ EvbpViewer *viewer = EVBP_VIEWER(widget);
+ GtkWidget *toplevel;
+ GtkAccelGroup *accel_group;
+
+ toplevel = gtk_widget_get_toplevel(widget);
+ if (gtk_widget_is_toplevel(toplevel)) {
+ accel_group = gtk_ui_manager_get_accel_group(viewer->ui_manager);
+ gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_group);
+ }
+}
+
+static void
evbp_viewer_class_init(EvbpViewerClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS(class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
object_class->dispose = evbp_viewer_dispose;
+ widget_class->hierarchy_changed = evbp_viewer_hierarchy_changed;
}
static const GtkActionEntry action_entries[] = {
@@ -203,6 +219,7 @@ evbp_viewer_init(EvbpViewer *viewer)
GError *error = NULL;
GtkWidget *toolbar;
GtkAction *action;
+ GList *actions;
gtk_orientable_set_orientation(GTK_ORIENTABLE(viewer),
GTK_ORIENTATION_VERTICAL);
@@ -244,6 +261,12 @@ evbp_viewer_init(EvbpViewer *viewer)
gtk_box_pack_start(GTK_BOX(viewer), toolbar, FALSE, FALSE, 0);
gtk_widget_show(toolbar);
+ /* connect the accelerators since GtkUIManager only does that for menus */
+ gtk_ui_manager_ensure_update(viewer->ui_manager);
+ actions = gtk_action_group_list_actions(viewer->action_group);
+ g_list_foreach(actions, (GFunc)gtk_action_connect_accelerator, NULL);
+ g_list_free(actions);
+
/* wire up toolbar callbacks */
sizing_mode_handler(G_OBJECT(viewer->model), NULL, viewer);
continuous_handler(G_OBJECT(viewer->model), NULL, viewer);