aboutsummaryrefslogtreecommitdiffstats
path: root/lib/egg/egg-menu-merge.h
blob: f4c44070685addcff615d58f9b33349ba74e1a96 (plain) (blame)
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
#ifndef EGG_MENU_MERGE_H
#define EGG_MENU_MERGE_H

#include <glib.h>
#include <glib-object.h>

#include <egg-action.h>
#include <egg-action-group.h>

#define EGG_TYPE_MENU_MERGE            (egg_menu_merge_get_type ())
#define EGG_MENU_MERGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_MENU_MERGE, EggMenuMerge))
#define EGG_MENU_MERGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_MENU_MERGE, EggMenuMergeClass))
#define EGG_IS_MENU_MERGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_MENU_MERGE))
#define EGG_IS_MENU_MERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EGG_TYPE_MENU_MERGE))
#define EGG_MENU_MERGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), EGG_TYPE_MENU_MERGE, EggMenuMergeClass))

typedef struct _EggMenuMerge      EggMenuMerge;
typedef struct _EggMenuMergeClass EggMenuMergeClass;
typedef struct _EggMenuMergeNode  EggMenuMergeNode;

typedef enum {
  EGG_MENU_MERGE_UNDECIDED,
  EGG_MENU_MERGE_ROOT,
  EGG_MENU_MERGE_MENUBAR,
  EGG_MENU_MERGE_MENU,
  EGG_MENU_MERGE_TOOLBAR,
  EGG_MENU_MERGE_MENU_PLACEHOLDER,
  EGG_MENU_MERGE_TOOLBAR_PLACEHOLDER,
  EGG_MENU_MERGE_POPUPS,
  EGG_MENU_MERGE_MENUITEM,
  EGG_MENU_MERGE_TOOLITEM,
  EGG_MENU_MERGE_SEPARATOR,
} EggMenuMergeNodeType;

struct _EggMenuMerge {
  GObject parent;

  GtkAccelGroup *accel_group;

  GNode *root_node;
  GList *action_groups;

  guint last_merge_id;

  guint update_tag;
};

struct _EggMenuMergeClass {
  GObjectClass parent_class;

  void (* add_widget) (EggMenuMerge *merge, GtkWidget *widget);
  void (* remove_widget) (EggMenuMerge *merge, GtkWidget *widget);
};

struct _EggMenuMergeNode {
  EggMenuMergeNodeType type;

  const gchar *name;

  GQuark action_name;
  EggAction *action;
  GtkWidget *proxy;
  GtkWidget *extra; /*GtkMenu for submenus, second separator for placeholders*/

  GList *uifiles;

  guint dirty : 1;
};

GType         egg_menu_merge_get_type            (void);
EggMenuMerge *egg_menu_merge_new                 (void);

/* these two functions will dirty all merge nodes, as they may need to
 * be connected up to different actions */
void          egg_menu_merge_insert_action_group (EggMenuMerge *self,
                          EggActionGroup *action_group,
                          gint pos);
void          egg_menu_merge_remove_action_group (EggMenuMerge *self,
                          EggActionGroup*action_group);


GtkWidget    *egg_menu_merge_get_widget          (EggMenuMerge *self,
                          const gchar *path);

/* these two functions are for adding UI elements to the merged user
 * interface */
guint         egg_menu_merge_add_ui_from_string  (EggMenuMerge *self,
                          const gchar *buffer,
                          guint length,
                          GError **error);
guint         egg_menu_merge_add_ui_from_file    (EggMenuMerge *self,
                          const gchar *filename,
                          GError **error);
void          egg_menu_merge_remove_ui           (EggMenuMerge *self,
                          guint merge_id);

void          egg_menu_merge_ensure_update       (EggMenuMerge *self);


#endif /* EGG_MENU_MERGE_H */