Commit e83dd1db authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

GladeDesignView: set selected layout state

Update layout state in order to change border color with css
parent ae8827ea
...@@ -703,9 +703,7 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev) ...@@ -703,9 +703,7 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
(!glade_project_is_toplevel_active (priv->project, child) || (!glade_project_is_toplevel_active (priv->project, child) ||
ev->type == GDK_2BUTTON_PRESS)) ev->type == GDK_2BUTTON_PRESS))
{ {
_glade_design_view_freeze (priv->view);
glade_project_selection_set (priv->project, G_OBJECT (child), TRUE); glade_project_selection_set (priv->project, G_OBJECT (child), TRUE);
_glade_design_view_thaw (priv->view);
} }
return (activity != ACTIVITY_NONE); return (activity != ACTIVITY_NONE);
...@@ -2512,8 +2510,6 @@ _glade_design_layout_do_event (GladeDesignLayout *layout, GdkEvent *event) ...@@ -2512,8 +2510,6 @@ _glade_design_layout_do_event (GladeDesignLayout *layout, GdkEvent *event)
*/ */
gdl_drag_source_check (layout, mode, event, gwidget, x, y); gdl_drag_source_check (layout, mode, event, gwidget, x, y);
_glade_design_view_freeze (priv->view);
/* Try the placeholder first */ /* Try the placeholder first */
if (placeholder && gtk_widget_event (placeholder, event)) if (placeholder && gtk_widget_event (placeholder, event))
retval = TRUE; retval = TRUE;
...@@ -2522,7 +2518,5 @@ _glade_design_layout_do_event (GladeDesignLayout *layout, GdkEvent *event) ...@@ -2522,7 +2518,5 @@ _glade_design_layout_do_event (GladeDesignLayout *layout, GdkEvent *event)
else else
retval = FALSE; retval = FALSE;
_glade_design_view_thaw (priv->view);
return retval; return retval;
} }
...@@ -23,12 +23,21 @@ ...@@ -23,12 +23,21 @@
glade-design-layout { glade-design-layout {
background: none; background: none;
border: 4px solid @theme_selected_bg_color; border: 4px solid @borders;
color: @theme_selected_fg_color; color: @theme_selected_fg_color;
border-radius: 4px 4px 0px 4px; border-radius: 4px 4px 0px 4px;
} }
glade-design-layout:selected {
border: 4px solid @theme_selected_bg_color;
}
glade-design-layout.handle { glade-design-layout.handle {
background-color: @borders;
border-radius: 0px 0px 4px 4px;
}
glade-design-layout:selected.handle {
background-color: @theme_selected_bg_color; background-color: @theme_selected_bg_color;
border-radius: 0px 0px 4px 4px; border-radius: 0px 0px 4px 4px;
} }
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
G_BEGIN_DECLS G_BEGIN_DECLS
void _glade_design_view_freeze (GladeDesignView *view);
void _glade_design_view_thaw (GladeDesignView *view);
void _glade_design_layout_get_colors (GdkRGBA *c1, GdkRGBA *c2, void _glade_design_layout_get_colors (GdkRGBA *c1, GdkRGBA *c2,
GdkRGBA *c3, GdkRGBA *c4); GdkRGBA *c3, GdkRGBA *c4);
......
...@@ -105,39 +105,50 @@ on_layout_size_allocate (GtkWidget *widget, GtkAllocation *alloc, GladeDesignVie ...@@ -105,39 +105,50 @@ on_layout_size_allocate (GtkWidget *widget, GtkAllocation *alloc, GladeDesignVie
g_signal_handlers_disconnect_by_func (widget, on_layout_size_allocate, view); g_signal_handlers_disconnect_by_func (widget, on_layout_size_allocate, view);
} }
static void
glade_design_view_update_state (GList *objects, GtkStateFlags state)
{
GList *l;
for (l = objects; l && l->data; l = g_list_next (l))
{
GtkWidget *view, *widget = l->data;
if (GTK_IS_WIDGET (widget) &&
gtk_widget_get_visible (widget) &&
(view = gtk_widget_get_ancestor (widget, GLADE_TYPE_DESIGN_LAYOUT)))
{
gtk_widget_set_state_flags (view, state, TRUE);
}
}
}
static void static void
glade_design_view_selection_changed (GladeProject *project, GladeDesignView *view) glade_design_view_selection_changed (GladeProject *project, GladeDesignView *view)
{ {
GtkWidget *layout;
GList *selection; GList *selection;
glade_design_view_update_state (glade_project_toplevels (project),
GTK_STATE_FLAG_NORMAL);
if (!(selection = glade_project_selection_get (project)))
return;
glade_design_view_update_state (selection, GTK_STATE_FLAG_SELECTED);
/* Check if its only one widget selected and scroll viewport to show toplevel */ /* Check if its only one widget selected and scroll viewport to show toplevel */
if ((selection = glade_project_selection_get (project)) && if (g_list_next (selection) == NULL &&
g_list_next (selection) == NULL && GTK_IS_WIDGET (selection->data) &&
GTK_IS_WIDGET (selection->data)) (layout = gtk_widget_get_ancestor (selection->data, GLADE_TYPE_DESIGN_LAYOUT)))
{ {
GladeWidget *gwidget, *gtoplevel; GtkAllocation alloc;
GObject *toplevel; gtk_widget_get_allocation (layout, &alloc);
if (!GLADE_IS_PLACEHOLDER (selection->data) &&
(gwidget = glade_widget_get_from_gobject (G_OBJECT (selection->data))) &&
(gtoplevel = glade_widget_get_toplevel (gwidget)) &&
(toplevel = glade_widget_get_object (gtoplevel)) &&
GTK_IS_WIDGET (toplevel))
{
GtkWidget *layout;
if ((layout = gtk_widget_get_parent (GTK_WIDGET (toplevel))) &&
GLADE_IS_DESIGN_LAYOUT (layout))
{
GtkAllocation alloc;
gtk_widget_get_allocation (layout, &alloc);
if (alloc.x < 0) if (alloc.x < 0)
g_signal_connect (layout, "size-allocate", G_CALLBACK (on_layout_size_allocate), view); g_signal_connect (layout, "size-allocate", G_CALLBACK (on_layout_size_allocate), view);
else else
glade_design_layout_scroll (view, alloc.x, alloc.y, alloc.width, alloc.height); glade_design_layout_scroll (view, alloc.x, alloc.y, alloc.width, alloc.height);
}
}
} }
} }
...@@ -757,27 +768,6 @@ glade_design_view_class_init (GladeDesignViewClass *klass) ...@@ -757,27 +768,6 @@ glade_design_view_class_init (GladeDesignViewClass *klass)
G_PARAM_CONSTRUCT_ONLY)); G_PARAM_CONSTRUCT_ONLY));
} }
/* Private API */
void
_glade_design_view_freeze (GladeDesignView *view)
{
g_return_if_fail (GLADE_IS_DESIGN_VIEW (view));
g_signal_handlers_block_by_func (view->priv->project,
glade_design_view_selection_changed,
view);
}
void
_glade_design_view_thaw (GladeDesignView *view)
{
g_return_if_fail (GLADE_IS_DESIGN_VIEW (view));
g_signal_handlers_unblock_by_func (view->priv->project,
glade_design_view_selection_changed,
view);
}
/* Public API */ /* Public API */
GladeProject * GladeProject *
......
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