Commit 745b2193 authored by Tristan Van Berkom's avatar Tristan Van Berkom

- Show glade widgets in the workspace on selection changes in the project


	* src/glade-window.c: 
	  - Show glade widgets in the workspace on selection changes in the project 
	    and not on item-activated.
	  - Rename "Dock Editor" -> "Dock Properties" as per bug 487613.
	
	* gladeui/glade-design-layout.c: Fixed expose event to chain to parent class
	  after drawing an orange box (non window widgets are usualy GTK_NO_WINDOW).

	* gladeui/glade-widget.c: Made glade_widget_show() show the toplevel of any
	  GtkWidget object, also now shows toplevel non window glade widgets in the
	  workspace, if the widget is referenced by a property that as a result parents
	  the widget (i.e. bears a "parentless-widget" property reference), then the
	  referencing widget is shown instead.

	* gladeui/glade-popup.c: Added devhelp icon to documentation menu item, added
	  docs icon to normal menu.


svn path=/trunk/; revision=1928
parent 5a3e0443
2008-09-18 Tristan Van Berkom <tvb@gnome.org>
* src/glade-window.c:
- Show glade widgets in the workspace on selection changes in the project
and not on item-activated.
- Rename "Dock Editor" -> "Dock Properties" as per bug 487613.
* gladeui/glade-design-layout.c: Fixed expose event to chain to parent class
after drawing an orange box (non window widgets are usualy GTK_NO_WINDOW).
* gladeui/glade-widget.c: Made glade_widget_show() show the toplevel of any
GtkWidget object, also now shows toplevel non window glade widgets in the
workspace, if the widget is referenced by a property that as a result parents
the widget (i.e. bears a "parentless-widget" property reference), then the
referencing widget is shown instead.
* gladeui/glade-popup.c: Added devhelp icon to documentation menu item, added
docs icon to normal menu.
2008-09-18 Christian Persch <chpe@gnome.org>
* gladeui/glade-app.c: (glade_app_show_properties),
......
......@@ -1267,8 +1267,6 @@ glade_command_add_execute (GladeCommandAddRemove *me)
/* Mark the properties as recorded */
cdata->props_recorded = TRUE;
}
}
/* Toplevels get pasted to the active project */
......
......@@ -787,10 +787,12 @@ glade_design_layout_expose_event (GtkWidget *widget, GdkEventExpose *ev)
/* draw a filled rectangle in case child does not draw
* it's own background (a GTK_WIDGET_NO_WINDOW child). */
gdk_draw_rectangle (widget->window,
widget->style->fg_gc[GTK_STATE_NORMAL],
widget->style->bg_gc[GTK_STATE_NORMAL],
TRUE,
x + OUTLINE_WIDTH / 2, y + OUTLINE_WIDTH / 2,
x + OUTLINE_WIDTH / 2, y + OUTLINE_WIDTH / 2,
w - OUTLINE_WIDTH, h - OUTLINE_WIDTH);
GTK_WIDGET_CLASS (glade_design_layout_parent_class)->expose_event (widget, ev);
}
return TRUE;
......
......@@ -217,6 +217,7 @@ static GtkWidget *
glade_popup_append_item (GtkWidget *popup_menu,
const gchar *stock_id,
const gchar *label,
GtkWidget *image,
gboolean sensitive,
gpointer callback,
gpointer data)
......@@ -229,6 +230,11 @@ glade_popup_append_item (GtkWidget *popup_menu,
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item),
gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU));
}
else if (image && label)
{
menu_item = gtk_image_menu_item_new_with_mnemonic (label);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
}
else if (stock_id)
menu_item = gtk_image_menu_item_new_from_stock (stock_id, NULL);
else
......@@ -311,7 +317,7 @@ glade_popup_action_populate_menu_real (GtkWidget *menu,
item = glade_popup_append_item (menu,
a->klass->stock,
a->klass->label, TRUE,
a->klass->label, NULL, TRUE,
(a->actions) ? NULL : callback,
(a->actions) ? NULL : a->klass->path);
......@@ -398,6 +404,7 @@ glade_popup_create_menu (GladeWidget *widget,
GtkWidget *popup_menu;
gboolean sensitive;
GladePlaceholder *tmp_placeholder;
gchar *book;
sensitive = glade_palette_get_current_item (glade_app_get_palette ()) != NULL;
......@@ -411,9 +418,9 @@ glade_popup_create_menu (GladeWidget *widget,
tmp_placeholder = placeholder;
if (!tmp_placeholder && widget)
tmp_placeholder = find_placeholder (glade_widget_get_object (widget));
glade_popup_append_item (popup_menu, NULL, _("_Add widget here"), tmp_placeholder != NULL,
glade_popup_append_item (popup_menu, NULL, _("_Add widget here"), NULL, tmp_placeholder != NULL,
glade_popup_placeholder_add_cb, tmp_placeholder);
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), TRUE,
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL, TRUE,
glade_popup_root_add_cb, NULL);
}
......@@ -427,23 +434,23 @@ glade_popup_create_menu (GladeWidget *widget,
gtk_widget_show (separator);
}
glade_popup_append_item (popup_menu, NULL, _("_Select"), TRUE,
glade_popup_append_item (popup_menu, NULL, _("_Select"), NULL, TRUE,
glade_popup_select_cb, widget);
glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, NULL, TRUE,
glade_popup_cut_cb, widget);
glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, NULL, TRUE,
glade_popup_copy_cb, widget);
/* paste is placholder specific when the popup is on a placeholder */
sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
if (placeholder)
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, sensitive,
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
glade_popup_placeholder_paste_cb, placeholder);
else
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, sensitive,
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
glade_popup_paste_cb, widget);
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
glade_popup_delete_cb, widget);
......@@ -485,6 +492,21 @@ glade_popup_create_menu (GladeWidget *widget,
glade_popup_action_populate_menu (popup_menu, widget, NULL, packing);
}
g_object_get (widget->adaptor, "book", &book, NULL);
if (book)
{
GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
gtk_widget_show (separator);
glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
glade_popup_docs_cb, widget->adaptor);
}
g_free (book);
return popup_menu;
}
......@@ -498,11 +520,11 @@ glade_popup_create_clipboard_menu (GladeWidget *widget)
if (GTK_WIDGET_TOPLEVEL (glade_widget_get_object (widget)))
{
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE,
NULL, TRUE,
NULL, NULL, TRUE,
glade_popup_clipboard_paste_cb, NULL);
}
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
glade_popup_clipboard_delete_cb, widget);
return popup_menu;
......@@ -605,14 +627,17 @@ glade_popup_palette_pop (GladeWidgetAdaptor *adaptor,
popup_menu = gtk_menu_new ();
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), TRUE,
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL, TRUE,
glade_popup_root_add_cb, adaptor);
g_object_get (adaptor, "book", &book, NULL);
if (book)
glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), TRUE,
{
GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
glade_popup_docs_cb, adaptor);
}
g_free (book);
......
......@@ -1858,12 +1858,29 @@ glade_widget_show (GladeWidget *widget)
{
GladeDesignView *view;
GtkWidget *layout;
GladeProperty *property;
g_return_if_fail (GLADE_IS_WIDGET (widget));
/* Position window at saved coordinates or in the center */
if (GTK_IS_WINDOW (widget->object) && glade_widget_embed (widget))
if (GTK_IS_WIDGET (widget->object) && !widget->parent)
{
if (GTK_IS_WINDOW (widget->object) && !glade_widget_embed (widget))
{
g_warning ("Unable to embed %s\n", widget->name);
return;
}
/* Maybe a property references this widget internally, show that widget instead */
if ((property = glade_widget_get_parentless_widget_ref (widget)) != NULL)
{
/* will never happen, paranoid check to avoid endless recursion. */
if (property->widget != widget)
glade_widget_show (property->widget);
return;
}
view = glade_design_view_get_from_project (glade_widget_get_project (widget));
layout = GTK_WIDGET (glade_design_view_get_layout (view));
......@@ -1877,9 +1894,12 @@ glade_widget_show (GladeWidget *widget)
G_CALLBACK (glade_widget_add_to_layout),
widget, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
} else if (GTK_IS_WIDGET (widget->object))
}
else if (GTK_IS_WIDGET (widget->object))
{
gtk_widget_show_all (GTK_WIDGET (widget->object));
GladeWidget *toplevel = glade_widget_get_toplevel (widget);
if (toplevel != widget)
glade_widget_show (toplevel);
}
widget->visible = TRUE;
}
......@@ -3286,6 +3306,24 @@ glade_widget_set_parent (GladeWidget *widget,
g_object_notify (G_OBJECT (widget), "parent");
}
/**
* glade_widget_get_toplevel:
* @widget: A #GladeWidget
*
* Returns: The toplevel #GladeWidget in the hierarchy (or @widget)
*/
GladeWidget *
glade_widget_get_toplevel (GladeWidget *widget)
{
GladeWidget *toplevel = widget;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
while (toplevel->parent)
toplevel = toplevel->parent;
return toplevel;
}
/**
* glade_widget_set_packing_properties:
* @widget: A #GladeWidget
......
......@@ -394,6 +394,8 @@ GladeWidget *glade_widget_get_parent (GladeWidget *w
void glade_widget_set_parent (GladeWidget *widget,
GladeWidget *parent);
GladeWidget *glade_widget_get_toplevel (GladeWidget *widget);
gboolean glade_widget_superuser (void);
......
......@@ -644,19 +644,20 @@ project_selection_changed_cb (GladeProject *project, GladeWindow *window)
*/
g_return_if_fail (GLADE_IS_WINDOW (window));
/* Only update the editor if the selection has changed on
/* Only update the toolbar & workspace if the selection has changed on
* the currently active project.
*/
if (glade_app_get_editor() &&
project && (project == glade_app_get_project ()))
if (project == glade_app_get_project ())
{
list = glade_project_selection_get (project);
num = g_list_length (list);
if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
{
glade_widget = glade_widget_get_from_gobject (G_OBJECT (list->data));
glade_widget_show (glade_widget);
clean_actions (window);
if (glade_widget->actions)
add_actions (window, glade_widget, glade_widget->actions);
......@@ -1605,21 +1606,6 @@ next_project_cb (GtkAction *action, GladeWindow *window)
gtk_notebook_next_page (GTK_NOTEBOOK (window->priv->notebook));
}
static void
inspector_item_activated_cb (GladeInspector *inspector,
GladeWindow *window)
{
GList *item = glade_inspector_get_selected_items (inspector);
g_assert (GLADE_IS_WIDGET (item->data) && (item->next == NULL));
/* bring window on top since inspector may be detached */
gtk_window_present (GTK_WINDOW (window));
/* switch to this widget in the workspace */
glade_widget_show (GLADE_WIDGET (item->data));
g_list_free (item);
}
static void
notebook_switch_page_cb (GtkNotebook *notebook,
GtkNotebookPage *page,
......@@ -1695,11 +1681,7 @@ notebook_tab_added_cb (GtkNotebook *notebook,
inspector = glade_inspector_new ();
gtk_widget_show (inspector);
glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
g_signal_connect (inspector, "item-activated",
G_CALLBACK (inspector_item_activated_cb),
window);
gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), inspector, NULL);
......@@ -2265,7 +2247,7 @@ static GtkToggleActionEntry view_entries[] = {
N_("Dock the inspector into the main window"),
G_CALLBACK (toggle_dock_cb), TRUE },
{ "DockEditor", NULL, N_("Dock _Editor"), NULL,
{ "DockEditor", NULL, N_("Dock Prop_erties"), NULL,
N_("Dock the editor into the main window"),
G_CALLBACK (toggle_dock_cb), TRUE },
......
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