Commit e32ac51a authored by Christian Hergert's avatar Christian Hergert
Browse files

glade: move action state changed tracking to view

parent 1300bda1
......@@ -39,6 +39,7 @@ struct _GbpGladeView
void _gbp_glade_view_init_actions (GbpGladeView *self);
void _gbp_glade_view_init_shortcuts (GtkWidget *widget);
void _gbp_glade_view_update_actions (GbpGladeView *self);
gboolean _gbp_glade_view_save (GbpGladeView *self,
GError **error);
......
......@@ -149,21 +149,17 @@ static GActionEntry actions[] = {
{ "pointer-mode", gbp_glade_view_action_pointer_mode, "s" },
};
static void
gbp_glade_view_update_actions_cb (GbpGladeView *self,
GladeCommand *command,
gboolean execute,
GladeProject *project)
void
_gbp_glade_view_update_actions (GbpGladeView *self)
{
GladeCommand *redo;
GladeCommand *undo;
g_assert (GBP_IS_GLADE_VIEW (self));
g_assert (!command || GLADE_IS_COMMAND (command));
g_assert (GLADE_IS_PROJECT (project));
g_assert (GLADE_IS_PROJECT (self->project));
redo = glade_project_next_redo_item (project);
undo = glade_project_next_undo_item (project);
redo = glade_project_next_redo_item (self->project);
undo = glade_project_next_undo_item (self->project);
dzl_gtk_widget_action_set (GTK_WIDGET (self), "glade-view", "undo",
"enabled", undo != NULL,
......@@ -189,10 +185,5 @@ _gbp_glade_view_init_actions (GbpGladeView *self)
"glade-view",
G_ACTION_GROUP (group));
g_signal_connect_object (self->project,
"changed",
G_CALLBACK (gbp_glade_view_update_actions_cb),
self,
G_CONNECT_SWAPPED);
gbp_glade_view_update_actions_cb (self, NULL, FALSE, self->project);
_gbp_glade_view_update_actions (self);
}
......@@ -42,6 +42,22 @@ gbp_glade_view_new (void)
return g_object_new (GBP_TYPE_GLADE_VIEW, NULL);
}
static void
gbp_glade_view_changed_cb (GbpGladeView *self,
GladeCommand *command,
gboolean execute,
GladeProject *project)
{
g_assert (GBP_IS_GLADE_VIEW (self));
g_assert (!command || GLADE_IS_COMMAND (command));
g_assert (GLADE_IS_PROJECT (project));
if (project != self->project)
return;
_gbp_glade_view_update_actions (self);
}
gboolean
_gbp_glade_view_save (GbpGladeView *self,
GError **error)
......@@ -171,6 +187,11 @@ gbp_glade_view_init (GbpGladeView *self)
ide_layout_view_set_menu_id (IDE_LAYOUT_VIEW (self), "gbp-glade-view-document-menu");
self->project = glade_project_new ();
g_signal_connect_object (self->project,
"changed",
G_CALLBACK (gbp_glade_view_changed_cb),
self,
G_CONNECT_SWAPPED);
box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_VERTICAL,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment