]> www.fi.muni.cz Git - evince.git/blob - cut-n-paste/recent-files/egg-recent-view-uimanager.c
Use pango ellipsisation.
[evince.git] / cut-n-paste / recent-files / egg-recent-view-uimanager.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /**
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * Authors:
19  *   James Willcox <jwillcox@cs.indiana.edu>
20  *   Paolo Bacchilega <paobac@cvs.gnome.org>
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include <gtk/gtk.h>
31 #include <libgnomevfs/gnome-vfs.h>
32 #ifndef USE_STABLE_LIBGNOMEUI
33 #include <libgnomeui/gnome-icon-theme.h>
34 #endif
35 #include <gconf/gconf-client.h>
36 #include "egg-recent-model.h"
37 #include "egg-recent-view.h"
38 #include "egg-recent-view-uimanager.h"
39 #include "egg-recent-util.h"
40 #include "egg-recent-item.h"
41
42 #define EGG_RECENT_NAME_PREFIX "EggRecentAction"
43 #define EGG_RECENT_ACTION "EggRecentFile"
44 #define EGG_RECENT_SEPARATOR (NULL)
45
46 #define LABEL_WIDTH_CHARS 32
47
48 struct _EggRecentViewUIManager {
49         GObject         parent_instance;
50
51         GCallback       action_callback;
52         gpointer        action_user_data;
53
54         gboolean        leading_sep;
55         gboolean        trailing_sep;
56
57         GtkUIManager   *uimanager;
58         GtkActionGroup *action_group;
59         guint           merge_id;
60         gulong          changed_cb_id;
61
62         gchar          *path;
63
64         gboolean        show_icons;
65         gboolean        show_numbers;
66 #ifndef USE_STABLE_LIBGNOMEUI
67         GnomeIconTheme *theme;
68 #endif
69
70         EggUIManagerTooltipFunc tooltip_func;
71         gpointer        tooltip_func_data;
72
73         EggRecentModel *model;
74         GConfClient    *client;
75         GtkIconSize     icon_size;
76 };
77
78
79 struct _EggRecentViewUIManagerMenuData {
80         EggRecentViewUIManager *view;
81         EggRecentItem *item;
82 };
83
84 typedef struct _EggRecentViewUIManagerMenuData EggRecentViewUIManagerMenuData;
85
86 enum {
87         ACTIVATE,
88         LAST_SIGNAL
89 };
90
91 /* GObject properties */
92 enum {
93         PROP_BOGUS,
94         PROP_UIMANAGER,
95         PROP_PATH,
96         PROP_SHOW_ICONS,
97         PROP_SHOW_NUMBERS
98 };
99
100 static guint view_signals[LAST_SIGNAL] = { 0 };
101
102 static void
103 egg_recent_view_uimanager_clear (EggRecentViewUIManager *view)
104 {
105         if (view->merge_id != 0) {
106                 gtk_ui_manager_remove_ui (view->uimanager, view->merge_id);
107                 view->merge_id = 0;
108         }
109
110         if (view->action_group != NULL) {
111                 gtk_ui_manager_remove_action_group (view->uimanager, view->action_group);
112                 g_object_unref (view->action_group);
113                 view->action_group = NULL;
114         }
115
116         gtk_ui_manager_ensure_update (view->uimanager);
117 }
118
119 static void
120 connect_proxy_cb (GtkActionGroup *action_group,
121                   GtkAction *action,
122                   GtkWidget *proxy)
123 {
124         if (GTK_IS_MENU_ITEM (proxy))
125         {
126                 GtkLabel *label;
127
128                 label = (GtkLabel *) ((GtkBin *) proxy)->child;
129
130                 gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
131                 gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS);
132         }
133 }
134                 
135
136 static void
137 egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list)
138 {
139         GList  *scan;
140         guint   index = 1;
141
142         g_return_if_fail (view);
143
144         egg_recent_view_uimanager_clear (view);
145
146         if (view->merge_id == 0)
147                 view->merge_id = gtk_ui_manager_new_merge_id (view->uimanager);
148
149         if (view->action_group == NULL) {
150                 gchar *group = g_strdup_printf ("EggRecentActions%u", 
151                                                 view->merge_id);
152                 view->action_group = gtk_action_group_new (group);
153                 g_signal_connect (view->action_group, "connect-proxy",
154                                   G_CALLBACK (connect_proxy_cb), view);
155                 gtk_ui_manager_insert_action_group (view->uimanager, view->action_group, -1);
156                 g_free (group);
157         }
158
159         if (view->leading_sep) {
160                 gchar *action = g_strdup_printf ("EggRecentLeadingSeparator%u",
161                                                  view->merge_id);
162                 gtk_ui_manager_add_ui (view->uimanager, 
163                                        view->merge_id, 
164                                        view->path,
165                                        action,
166                                        EGG_RECENT_SEPARATOR,
167                                        GTK_UI_MANAGER_AUTO, 
168                                        FALSE);
169                 g_free (action);
170         }
171
172         for (scan = list; scan; scan = scan->next, index++) {
173                 EggRecentItem *item = scan->data;
174                 GtkAction     *action;
175                 gchar         *name;
176                 gchar         *uri;
177                 gchar         *basename;
178                 gchar         *escaped;
179                 gchar         *label;
180                 gchar         *tooltip = NULL;
181
182                 uri = egg_recent_item_get_uri_for_display (item);
183                 if (uri == NULL)
184                         continue;
185
186                 name = g_strdup_printf (EGG_RECENT_NAME_PREFIX"%u-%u", 
187                                         view->merge_id,
188                                         index);
189
190                 if (view->tooltip_func != NULL)
191                         tooltip = (*view->tooltip_func) (item, view->tooltip_func_data);
192
193                 basename = g_path_get_basename (uri);
194                 escaped = egg_recent_util_escape_underlines (basename);
195                 g_free (basename);
196                 g_free (uri);
197
198                 if (view->show_numbers) {
199                         if (index >= 10)
200                                 label = g_strdup_printf ("%d.  %s", 
201                                                          index, 
202                                                          escaped);
203                         else
204                                 label = g_strdup_printf ("_%d.  %s", 
205                                                          index, 
206                                                          escaped);
207                         g_free (escaped);
208                 } else 
209                         label = basename;
210
211                 action = g_object_new (GTK_TYPE_ACTION,
212                                        "name", name,
213                                        "label", label,
214                                        (view->show_icons)? "stock_id": NULL, 
215                                        GTK_STOCK_OPEN,
216                                        NULL);
217                 if (tooltip != NULL) {
218                         g_object_set (action, "tooltip", tooltip, NULL);
219                         g_free (tooltip);
220                 }
221                 egg_recent_item_ref (item);
222                 g_object_set_data_full (G_OBJECT (action), 
223                                         "egg_recent_uri", 
224                                         item, 
225                                         (GFreeFunc) egg_recent_item_unref);
226
227                 if (view->action_callback != NULL) {
228                         GClosure *closure;
229                         closure = g_cclosure_new (view->action_callback, view->action_user_data, NULL);
230                         g_signal_connect_closure (action, "activate", closure, FALSE);
231                 }
232
233                 gtk_action_group_add_action (view->action_group, action);
234                 g_object_unref (action);
235
236                 gtk_ui_manager_add_ui (view->uimanager, 
237                                        view->merge_id, 
238                                        view->path,
239                                        name,
240                                        name,
241                                        GTK_UI_MANAGER_AUTO, 
242                                        FALSE);
243
244                 g_free (name);
245                 g_free (label);
246         }
247
248         if (view->trailing_sep) {
249                 gchar *action = g_strdup_printf ("EggRecentTrailingSeparator%u",
250                                                 view->merge_id);
251                 gtk_ui_manager_add_ui (view->uimanager, 
252                                        view->merge_id, 
253                                        view->path,
254                                        action,
255                                        EGG_RECENT_SEPARATOR,
256                                        GTK_UI_MANAGER_AUTO, 
257                                        FALSE);
258                 g_free (action);
259         }
260 }
261
262 static void
263 model_changed_cb (EggRecentModel         *model,  
264                   GList                  *list, 
265                   EggRecentViewUIManager *view)
266 {
267         if (list != NULL)
268                 egg_recent_view_uimanager_set_list (view, list);
269         else
270                 egg_recent_view_uimanager_clear (view);
271         gtk_ui_manager_ensure_update (view->uimanager);
272 }
273
274 static EggRecentModel *
275 egg_recent_view_uimanager_get_model (EggRecentView *view_parent)
276 {
277         EggRecentViewUIManager *view;
278         
279         g_return_val_if_fail (view_parent != NULL, NULL);
280         view = EGG_RECENT_VIEW_UIMANAGER (view_parent);
281         return view->model;
282 }
283
284 static void
285 egg_recent_view_uimanager_set_model (EggRecentView  *view_parent,
286                                      EggRecentModel *model)
287 {
288         EggRecentViewUIManager *view;
289         
290         g_return_if_fail (view_parent != NULL);
291         view = EGG_RECENT_VIEW_UIMANAGER (view_parent);
292
293         if (view->model != NULL) {
294                 if (view->changed_cb_id != 0)
295                         g_signal_handler_disconnect (G_OBJECT (view->model),
296                                                      view->changed_cb_id);
297                 g_object_unref (view->model);
298         }
299         
300         view->model = model;
301         g_object_ref (view->model);
302
303         view->changed_cb_id = g_signal_connect_object (G_OBJECT (model),
304                                                        "changed",
305                                                        G_CALLBACK (model_changed_cb),
306                                                        view, 0);
307
308         egg_recent_model_changed (view->model);
309 }
310
311 void
312 egg_recent_view_uimanager_set_leading_sep (EggRecentViewUIManager *view, 
313                                            gboolean                val)
314 {
315         view->leading_sep = val;
316         egg_recent_view_uimanager_clear (view);
317         if (view->model)
318                 egg_recent_model_changed (view->model);
319 }
320
321 void
322 egg_recent_view_uimanager_set_trailing_sep (EggRecentViewUIManager *view,
323                                             gboolean                val)
324 {
325         view->trailing_sep = val;
326         egg_recent_view_uimanager_clear (view);
327         if (view->model)
328                 egg_recent_model_changed (view->model);
329 }
330
331 static void
332 egg_recent_view_uimanager_set_property (GObject      *object,
333                                         guint         prop_id,
334                                         const GValue *value,
335                                         GParamSpec   *pspec)
336 {
337         EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object);
338
339         switch (prop_id) {
340         case PROP_UIMANAGER:
341                 egg_recent_view_uimanager_set_uimanager (view, (GtkUIManager*)g_value_get_object (value));
342                 break;
343         case PROP_PATH:
344                 egg_recent_view_uimanager_set_path (view, g_value_get_string (value));
345                 break;
346         case PROP_SHOW_ICONS:
347                 egg_recent_view_uimanager_show_icons (view, g_value_get_boolean (value));
348                 break;
349         case PROP_SHOW_NUMBERS:
350                 egg_recent_view_uimanager_show_numbers (view, g_value_get_boolean (value));
351                 break;
352         default:
353                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
354                 break;
355         }
356 }
357
358 static void
359 egg_recent_view_uimanager_get_property (GObject    *object,
360                                         guint       prop_id,
361                                         GValue     *value,
362                                         GParamSpec *pspec)
363 {
364         EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object);
365
366         switch (prop_id) {
367         case PROP_UIMANAGER:
368                 g_value_set_object (value, view->uimanager);
369                 break;
370         case PROP_PATH:
371                 g_value_set_string (value, view->path);
372                 break;
373         case PROP_SHOW_ICONS:
374                 g_value_set_boolean (value, view->show_icons);
375                 break;
376         case PROP_SHOW_NUMBERS:
377                 g_value_set_boolean (value, view->show_numbers);
378                 break;
379         default:
380                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
381                 break;
382         }
383 }
384
385 static void
386 egg_recent_view_uimanager_finalize (GObject *object)
387 {
388         EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object);
389
390         if (view->changed_cb_id != 0) {
391                 g_signal_handler_disconnect (G_OBJECT (view->model),
392                                              view->changed_cb_id);
393                 view->changed_cb_id = 0;
394         }
395
396         g_free (view->path);
397
398         egg_recent_view_uimanager_clear (view);
399
400         if (view->action_group != NULL) {
401                 g_object_unref (view->action_group);
402                 view->action_group = NULL;
403         }
404
405         if (view->uimanager != NULL) {
406                 g_object_unref (view->uimanager);
407                 view->uimanager = NULL;
408         }
409
410         if (view->model != NULL) {
411                 g_object_unref (view->model);
412                 view->model = NULL;
413         }
414
415 #ifndef USE_STABLE_LIBGNOMEUI
416         if (view->theme != NULL) {
417                 g_object_unref (view->theme);
418                 view->theme = NULL;
419         }
420 #endif
421
422         if (view->client != NULL) {
423                 g_object_unref (view->client);
424                 view->client = NULL;
425         }
426 }
427
428 static void
429 egg_recent_view_uimanager_class_init (EggRecentViewUIManagerClass * klass)
430 {
431         GObjectClass *object_class;
432
433         object_class = G_OBJECT_CLASS (klass);
434
435         object_class->set_property = egg_recent_view_uimanager_set_property;
436         object_class->get_property = egg_recent_view_uimanager_get_property;
437         object_class->finalize     = egg_recent_view_uimanager_finalize;
438
439         view_signals[ACTIVATE] = g_signal_new ("activate",
440                                                G_OBJECT_CLASS_TYPE (object_class),
441                                                G_SIGNAL_RUN_LAST,
442                                                G_STRUCT_OFFSET (EggRecentViewUIManagerClass, activate),
443                                                NULL, NULL,
444                                                g_cclosure_marshal_VOID__BOXED,
445                                                G_TYPE_NONE, 1,
446                                                EGG_TYPE_RECENT_ITEM);
447
448         g_object_class_install_property (object_class,
449                                          PROP_UIMANAGER,
450                                          g_param_spec_object ("uimanager",
451                                                               "UI Manager",
452                                                               "The UI manager this object will use to update.the UI",
453                                                               GTK_TYPE_UI_MANAGER,
454                                                               G_PARAM_READWRITE));
455         g_object_class_install_property (object_class,
456                                          PROP_PATH,
457                                          g_param_spec_string ("path",
458                                                               "Path",
459                                                               "The UI path this object will update.",
460                                                               NULL,
461                                                               G_PARAM_READWRITE));
462         g_object_class_install_property (object_class,
463                                          PROP_SHOW_ICONS,
464                                          g_param_spec_boolean ("show-icons",
465                                                                "Show Icons",
466                                                                "Whether or not to show icons",
467                                                                FALSE,
468                                                                G_PARAM_READWRITE));
469         
470         g_object_class_install_property (object_class,
471                                          PROP_SHOW_NUMBERS,
472                                          g_param_spec_boolean ("show-numbers",
473                                                                "Show Numbers",
474                                                                "Whether or not to show numbers",
475                                                                TRUE,
476                                                                G_PARAM_READWRITE));
477
478         klass->activate = NULL;
479 }
480
481 static void
482 egg_recent_view_init (EggRecentViewClass *iface)
483 {
484         iface->do_get_model = egg_recent_view_uimanager_get_model;
485         iface->do_set_model = egg_recent_view_uimanager_set_model;
486 }
487
488 static void
489 show_menus_changed_cb (GConfClient            *client,
490                        guint                   cnxn_id,
491                        GConfEntry             *entry,
492                        EggRecentViewUIManager *view)
493 {
494         GConfValue *value;
495
496         value = gconf_entry_get_value (entry);
497         g_return_if_fail (value->type == GCONF_VALUE_BOOL);
498
499         egg_recent_view_uimanager_show_icons (view, gconf_value_get_bool (value));
500 }
501
502 #ifndef USE_STABLE_LIBGNOMEUI
503 static void
504 theme_changed_cb (GnomeIconTheme         *theme, 
505                   EggRecentViewUIManager *view)
506 {
507         if (view->model != NULL)
508                 egg_recent_model_changed (view->model);
509 }
510 #endif
511
512 static void
513 egg_recent_view_uimanager_init (EggRecentViewUIManager * view)
514 {
515         view->client = gconf_client_get_default ();
516
517         view->show_icons = gconf_client_get_bool (view->client,
518                                                   "/desktop/gnome/interface/menus_have_icons",
519                                                   NULL);
520         
521         gconf_client_add_dir (view->client, "/desktop/gnome/interface",
522                               GCONF_CLIENT_PRELOAD_NONE,
523                               NULL);
524         gconf_client_notify_add (view->client,
525                                  "/desktop/gnome/interface/menus_have_icons",
526                                  (GConfClientNotifyFunc)show_menus_changed_cb,
527                                  view, NULL, NULL);
528
529
530         view->leading_sep = FALSE;
531         view->trailing_sep = FALSE;
532         view->show_numbers = TRUE;
533
534         view->uimanager = NULL;
535         view->action_group = NULL;
536         view->merge_id = 0;
537         view->changed_cb_id = 0;
538
539         view->path = NULL;
540
541 #ifndef USE_STABLE_LIBGNOMEUI
542         view->theme = gnome_icon_theme_new ();
543         gnome_icon_theme_set_allow_svg (view->theme, TRUE);
544         g_signal_connect_object (view->theme, "changed",
545                                  G_CALLBACK (theme_changed_cb), view, 0);
546 #endif
547
548         view->tooltip_func = NULL;
549         view->tooltip_func_data = NULL;
550
551         view->icon_size = GTK_ICON_SIZE_MENU;
552 }
553
554 void
555 egg_recent_view_uimanager_set_icon_size (EggRecentViewUIManager *view,
556                                          GtkIconSize             icon_size)
557 {
558         if (view->icon_size != icon_size) {
559                 view->icon_size = icon_size;
560                 egg_recent_model_changed (view->model);
561         } else {
562                 view->icon_size = icon_size;
563         }
564 }
565
566 GtkIconSize
567 egg_recent_view_uimanager_get_icon_size (EggRecentViewUIManager *view)
568 {
569         return view->icon_size;
570 }
571
572 void
573 egg_recent_view_uimanager_show_icons (EggRecentViewUIManager *view,
574                                       gboolean                show)
575 {
576         view->show_icons = show;
577         if (view->model != NULL)
578                 egg_recent_model_changed (view->model);
579 }
580
581 void
582 egg_recent_view_uimanager_show_numbers (EggRecentViewUIManager *view, 
583                                         gboolean                show)
584 {
585         view->show_numbers = show;
586         if (view->model != NULL)
587                 egg_recent_model_changed (view->model);
588 }
589
590 void
591 egg_recent_view_uimanager_set_tooltip_func (EggRecentViewUIManager   *view,
592                                             EggUIManagerTooltipFunc   func,
593                                             gpointer                  user_data)
594 {
595         view->tooltip_func = func;
596         view->tooltip_func_data = user_data;
597         if (view->model)
598                 egg_recent_model_changed (view->model);
599 }
600
601 /**
602  * egg_recent_view_uimanager_set_uimanager:
603  * @view: A EggRecentViewUIManager object.
604  * @uimanager: The ui manager used to put the menu items in.
605  *
606  * Use this function to change the ui manager used to update the menu.
607  *
608  */
609 void
610 egg_recent_view_uimanager_set_uimanager (EggRecentViewUIManager *view,
611                                          GtkUIManager           *uimanager)
612 {
613         g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view));
614         g_return_if_fail (uimanager != NULL);
615
616         if (view->uimanager != NULL)
617                 g_object_unref (view->uimanager);
618         view->uimanager = uimanager;
619         g_object_ref (view->uimanager);
620 }
621
622 /**
623  * egg_recent_view_uimanager_get_uimanager:
624  * @view: A EggRecentViewUIManager object.
625  *
626  */
627 GtkUIManager*
628 egg_recent_view_uimanager_get_uimanager (EggRecentViewUIManager *view)
629 {
630         g_return_val_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view), NULL);
631         return view->uimanager;
632 }
633
634 /**
635  * egg_recent_view_uimanager_set_path:
636  * @view: A EggRecentViewUIManager object.
637  * @path: The path to put the menu items in.
638  *
639  * Use this function to change the path where the recent
640  * documents appear in.
641  *
642  */
643 void
644 egg_recent_view_uimanager_set_path (EggRecentViewUIManager *view,
645                                     const gchar            *path)
646 {
647         g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view));
648         g_return_if_fail (path);
649
650         g_free (view->path);
651         view->path = g_strdup (path);
652 }
653
654 /**
655  * egg_recent_view_uimanager_get_path:
656  * @view: A EggRecentViewUIManager object.
657  *
658  */
659 G_CONST_RETURN gchar*
660 egg_recent_view_uimanager_get_path (EggRecentViewUIManager *view)
661 {
662         g_return_val_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view), NULL);
663         return view->path;
664 }
665
666 void
667 egg_recent_view_uimanager_set_action_func (EggRecentViewUIManager   *view,
668                                            GCallback                 callback,
669                                            gpointer                  user_data)
670 {
671         g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view));
672         view->action_callback = callback;
673         view->action_user_data = user_data;
674 }
675
676 /**
677  * egg_recent_view_uimanager_new:
678  * @appname: The name of your application.
679  * @limit:  The maximum number of items allowed.
680  *
681  * This creates a new EggRecentViewUIManager object.
682  *
683  * Returns: a EggRecentViewUIManager object
684  */
685 EggRecentViewUIManager *
686 egg_recent_view_uimanager_new (GtkUIManager  *uimanager,
687                                const gchar   *path,
688                                GCallback      callback,
689                                gpointer       user_data)
690 {
691         GObject *view;
692
693         g_return_val_if_fail (uimanager, NULL);
694         g_return_val_if_fail (path, NULL);
695
696         view = g_object_new (egg_recent_view_uimanager_get_type (),
697                              "uimanager", uimanager,
698                              "path", path,
699                              NULL);
700
701         g_return_val_if_fail (view, NULL);
702         
703         egg_recent_view_uimanager_set_action_func (EGG_RECENT_VIEW_UIMANAGER (view),
704                                                    callback,
705                                                    user_data);
706
707         return EGG_RECENT_VIEW_UIMANAGER (view);
708 }
709
710 /**
711  * egg_recent_view_uimanager_get_type:
712  * @:
713  *
714  * This returns a GType representing a EggRecentViewUIManager object.
715  *
716  * Returns: a GType
717  */
718 GType
719 egg_recent_view_uimanager_get_type (void)
720 {
721         static GType egg_recent_view_uimanager_type = 0;
722
723         if(!egg_recent_view_uimanager_type) {
724                 static const GTypeInfo egg_recent_view_uimanager_info = {
725                         sizeof (EggRecentViewUIManagerClass),
726                         NULL, /* base init */
727                         NULL, /* base finalize */
728                         (GClassInitFunc)egg_recent_view_uimanager_class_init, /* class init */
729                         NULL, /* class finalize */
730                         NULL, /* class data */
731                         sizeof (EggRecentViewUIManager),
732                         0,
733                         (GInstanceInitFunc) egg_recent_view_uimanager_init
734                 };
735
736                 static const GInterfaceInfo view_info =
737                 {
738                         (GInterfaceInitFunc) egg_recent_view_init,
739                         NULL,
740                         NULL
741                 };
742
743                 egg_recent_view_uimanager_type = g_type_register_static (G_TYPE_OBJECT,
744                                                                          "EggRecentViewUIManager",
745                                                                          &egg_recent_view_uimanager_info, 0);
746                 g_type_add_interface_static (egg_recent_view_uimanager_type,
747                                              EGG_TYPE_RECENT_VIEW,
748                                              &view_info);
749         }
750
751         return egg_recent_view_uimanager_type;
752 }
753
754 EggRecentItem*
755 egg_recent_view_uimanager_get_item (EggRecentViewUIManager   *view,
756                                     GtkAction                *action)
757 {
758         return g_object_get_data (G_OBJECT(action), "egg_recent_uri");
759 }