Commit d4835f02 authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

* gladeui/glade-app.[ch]:

	  - Removed "update-ui" signal, This signal was encouraging bad behaviour and too much
	    action on every project change.
	  - Removed glade_app_create_undo/redo_button().

	* gladeui/glade-project.c: Stop calling glade_app_update_ui ().

	* gladeui/glade-window.c:
	  - Listen to GladeProject::changed instead of update-ui and only update the
	    undo/redo actions when the active project changes.
	  - Remove the preview toolbutton
	  - Add tooltips to important actions

	* plugins/gtk+/gtk+.xml.in: Mark the "preview" action as "important" so it shows
	  up in the app toolbar automatically.
parent 6fa69cb8
2011-01-03 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-app.[ch]:
- Removed "update-ui" signal, This signal was encouraging bad behaviour and too much
action on every project change.
- Removed glade_app_create_undo/redo_button().
* gladeui/glade-project.c: Stop calling glade_app_update_ui ().
* gladeui/glade-window.c:
- Listen to GladeProject::changed instead of update-ui and only update the
undo/redo actions when the active project changes.
- Remove the preview toolbutton
- Add tooltips to important actions
* plugins/gtk+/gtk+.xml.in: Mark the "preview" action as "important" so it shows
up in the app toolbar automatically.
2011-01-02 Tristan Van Berkom <tristanvb@openismus.com>
* gladeui/glade-project.c: Fixed GladeProject to only ever report widgets that are
......
......@@ -57,7 +57,6 @@
enum
{
UPDATE_UI,
SIGNAL_EDITOR_CREATED,
LAST_SIGNAL
};
......@@ -89,7 +88,6 @@ struct _GladeAppPrivate
* GladeWidgets.
*/
GtkAccelGroup *accel_group; /* Default acceleration group for this app */
GList *undo_list, *redo_list; /* Lists of buttons to refresh in update-ui signal */
GladePointerMode pointer_mode; /* Current mode for the pointer in the workspace */
......@@ -249,47 +247,6 @@ glade_app_get_property (GObject * object,
/*****************************************************************
* GladeAppClass *
*****************************************************************/
static void
glade_app_refresh_undo_redo_button (GladeApp * app,
GtkWidget * button, gboolean undo)
{
GladeCommand *command = NULL;
GladeProject *project;
gchar *desc;
if ((project = glade_app_get_project ()) != NULL)
{
if (undo)
command = glade_project_next_undo_item (project);
else
command = glade_project_next_redo_item (project);
}
/* Change tooltips */
desc = g_strdup_printf ((undo) ? _("Undo: %s") : _("Redo: %s"),
command ? command->
description : _("the last action"));
gtk_widget_set_tooltip_text (button, desc);
g_free (desc);
/* Set sensitivity on the button */
gtk_widget_set_sensitive (button, command != NULL);
}
static void
glade_app_update_ui_default (GladeApp * app)
{
GList *list;
for (list = app->priv->undo_list; list; list = list->next)
if (list->data)
glade_app_refresh_undo_redo_button (app, list->data, TRUE);
for (list = app->priv->redo_list; list; list = list->next)
if (list->data)
glade_app_refresh_undo_redo_button (app, list->data, FALSE);
}
static void
glade_app_signal_editor_created_default (GladeApp * app,
GladeSignalEditor * signal_editor)
......@@ -447,9 +404,6 @@ glade_app_init (GladeApp * app)
/* Load the configuration file */
app->priv->config = glade_app_config_load (app);
/* Undo/Redo button list */
app->priv->undo_list = app->priv->redo_list = NULL;
}
static void
......@@ -465,35 +419,20 @@ glade_app_class_init (GladeAppClass * klass)
object_class->get_property = glade_app_get_property;
object_class->set_property = glade_app_set_property;
klass->update_ui_signal = glade_app_update_ui_default;
klass->signal_editor_created = glade_app_signal_editor_created_default;
klass->show_properties = NULL;
klass->hide_properties = NULL;
/**
* GladeApp::update-ui:
* @gladeapp: the #GladeApp which received the signal.
*
* Emitted when a project name changes or a cut/copy/paste/delete occurred.
*/
glade_app_signals[UPDATE_UI] =
g_signal_new ("update-ui",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GladeAppClass,
update_ui_signal),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeApp::signal-editor-created:
* @gladeapp: the #GladeApp which received the signal.
* @signal_editor: the new #GladeSignalEditor.
*
* Emitted when a new signal editor created.
* A tree view is created in the default handler.
* Connect your handler before the default handler for setting a custom column or renderer
* and after it for connecting to the tree view signals
*/
/**
* GladeApp::signal-editor-created:
* @gladeapp: the #GladeApp which received the signal.
* @signal_editor: the new #GladeSignalEditor.
*
* Emitted when a new signal editor created.
* A tree view is created in the default handler.
* Connect your handler before the default handler for setting a custom column or renderer
* and after it for connecting to the tree view signals
*/
glade_app_signals[SIGNAL_EDITOR_CREATED] =
g_signal_new ("signal-editor-created",
G_TYPE_FROM_CLASS (object_class),
......@@ -691,14 +630,6 @@ glade_app_get (void)
return singleton_app;
}
void
glade_app_update_ui (void)
{
GladeApp *app = glade_app_get ();
g_signal_emit (G_OBJECT (app), glade_app_signals[UPDATE_UI], 0);
}
void
glade_app_set_window (GtkWidget * window)
{
......@@ -1021,9 +952,6 @@ glade_app_set_project (GladeProject * project)
/* refresh palette for active project */
glade_palette_refresh (glade_app_get_palette ());
/* Update UI */
glade_app_update_ui ();
g_object_notify (G_OBJECT (app), "active-project");
}
......@@ -1088,10 +1016,7 @@ glade_app_command_copy (void)
}
if (failed == FALSE && widgets != NULL)
{
glade_command_copy (widgets);
glade_app_update_ui ();
}
glade_command_copy (widgets);
else if (widgets == NULL)
glade_util_ui_message (glade_app_get_window (),
GLADE_UI_INFO, NULL, _("No widget selected."));
......@@ -1129,10 +1054,7 @@ glade_app_command_cut (void)
}
if (failed == FALSE && widgets != NULL)
{
glade_command_cut (widgets);
glade_app_update_ui ();
}
glade_command_cut (widgets);
else if (widgets == NULL)
glade_util_ui_message (glade_app_get_window (),
GLADE_UI_INFO, NULL, _("No widget selected."));
......@@ -1273,7 +1195,6 @@ glade_app_command_paste (GladePlaceholder * placeholder)
}
glade_command_paste (clipboard->selection, parent, placeholder);
glade_app_update_ui ();
}
......@@ -1302,10 +1223,7 @@ glade_app_command_delete (void)
}
if (failed == FALSE && widgets != NULL)
{
glade_command_delete (widgets);
glade_app_update_ui ();
}
glade_command_delete (widgets);
else if (widgets == NULL)
glade_util_ui_message (glade_app_get_window (),
GLADE_UI_INFO, NULL, _("No widget selected."));
......@@ -1334,34 +1252,6 @@ glade_app_command_delete_clipboard (void)
}
glade_command_delete (clipboard->selection);
glade_app_update_ui ();
}
void
glade_app_command_undo (void)
{
GladeApp *app = glade_app_get ();
if (app->priv->active_project)
{
glade_project_undo (app->priv->active_project);
glade_editor_refresh (app->priv->editor);
/* Update UI. */
glade_app_update_ui ();
}
}
void
glade_app_command_redo (void)
{
GladeApp *app = glade_app_get ();
if (app->priv->active_project)
{
glade_project_redo (app->priv->active_project);
glade_editor_refresh (app->priv->editor);
/* Update UI. */
glade_app_update_ui ();
}
}
/*
......@@ -1388,75 +1278,6 @@ glade_app_get_accel_group (void)
return glade_app_get ()->priv->accel_group;
}
static gboolean
glade_app_undo_button_destroyed (GtkWidget * button, GladeApp * app)
{
app->priv->undo_list = g_list_remove (app->priv->undo_list, button);
return FALSE;
}
static gboolean
glade_app_redo_button_destroyed (GtkWidget * button, GladeApp * app)
{
app->priv->redo_list = g_list_remove (app->priv->redo_list, button);
return FALSE;
}
static GtkWidget *
glade_app_undo_redo_button_new (GladeApp * app, gboolean undo)
{
GtkWidget *button;
button = gtk_button_new_from_stock ((undo) ? GTK_STOCK_UNDO : GTK_STOCK_REDO);
g_signal_connect_swapped (button, "clicked",
(undo) ? G_CALLBACK (glade_app_command_undo) :
G_CALLBACK (glade_app_command_redo), app);
if (undo)
{
app->priv->undo_list = g_list_prepend (app->priv->undo_list, button);
g_signal_connect (button, "destroy",
G_CALLBACK (glade_app_undo_button_destroyed), app);
}
else
{
app->priv->redo_list = g_list_prepend (app->priv->redo_list, button);
g_signal_connect (button, "destroy",
G_CALLBACK (glade_app_redo_button_destroyed), app);
}
glade_app_refresh_undo_redo_button (app, button, undo);
return button;
}
/*
* glade_app_undo_button_new:
*
* Creates a new GtkButton undo widget.
* The button will be automatically updated with @app's undo stack.
*/
GtkWidget *
glade_app_undo_button_new (void)
{
GladeApp *app = glade_app_get ();
return glade_app_undo_redo_button_new (app, TRUE);
}
/*
* glade_app_redo_button_new:
*
* Creates a new GtkButton redo widget.
* The button will be automatically updated with @app's redo stack.
*/
GtkWidget *
glade_app_redo_button_new (void)
{
GladeApp *app = glade_app_get ();
return glade_app_undo_redo_button_new (app, FALSE);
}
GList *
glade_app_get_selection (void)
{
......
......@@ -80,8 +80,7 @@ struct _GladeAppClass
void (* hide_properties) (GladeApp* app);
/* signals */
void (* update_ui_signal) (GladeApp *app);
void (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
void (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
};
......@@ -93,8 +92,6 @@ GType glade_pointer_mode_get_type (void) G_GNUC_CONST;
GladeApp* glade_app_get (void);
void glade_app_update_ui (void);
void glade_app_set_window (GtkWidget *window);
GtkWidget* glade_app_get_window (void);
......@@ -162,12 +159,7 @@ GtkWindow *glade_app_get_transient_parent (void);
void glade_app_set_accel_group (GtkAccelGroup *accel_group);
GtkAccelGroup *glade_app_get_accel_group (void);
GtkWidget *glade_app_undo_button_new (void);
GtkWidget *glade_app_redo_button_new (void);
GList *glade_app_get_selection (void);
......
......@@ -537,7 +537,6 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
{
GladeCommand *cmd1 = priv->prev_redo_item->data;
if (glade_command_unifies (cmd1, cmd))
{
glade_command_collapse (cmd1, cmd);
......@@ -550,10 +549,12 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
glade_project_free_undo_item (project, tmp_redo_item);
priv->undo_stack =
g_list_delete_link (priv->undo_stack, tmp_redo_item);
cmd1 = NULL;
}
g_signal_emit (G_OBJECT (project),
glade_project_signals[CHANGED], 0, NULL, TRUE);
glade_project_signals[CHANGED], 0, cmd1, TRUE);
return;
}
}
......@@ -566,7 +567,6 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
else
priv->prev_redo_item = g_list_next (priv->prev_redo_item);
g_signal_emit (G_OBJECT (project),
glade_project_signals[CHANGED], 0, cmd, TRUE);
}
......@@ -649,7 +649,6 @@ glade_project_changed_impl (GladeProject * project,
else
glade_project_set_modified (project, TRUE);
}
glade_app_update_ui ();
}
......@@ -744,13 +743,13 @@ glade_project_class_init (GladeProjectClass * klass)
klass->close = glade_project_close_impl;
klass->changed = glade_project_changed_impl;
/**
* GladeProject::add-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was added to @gladeproject.
*
* Emitted when a widget is added to a project.
*/
/**
* GladeProject::add-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was added to @gladeproject.
*
* Emitted when a widget is added to a project.
*/
glade_project_signals[ADD_WIDGET] =
g_signal_new ("add_widget",
G_TYPE_FROM_CLASS (object_class),
......@@ -760,13 +759,13 @@ glade_project_class_init (GladeProjectClass * klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
/**
* GladeProject::remove-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was removed from @gladeproject.
*
* Emitted when a widget is removed from a project.
*/
/**
* GladeProject::remove-widget:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget that was removed from @gladeproject.
*
* Emitted when a widget is removed from a project.
*/
glade_project_signals[REMOVE_WIDGET] =
g_signal_new ("remove_widget",
G_TYPE_FROM_CLASS (object_class),
......@@ -777,13 +776,13 @@ glade_project_class_init (GladeProjectClass * klass)
G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
/**
* GladeProject::widget-name-changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget who's name changed.
*
* Emitted when @gwidget's name changes.
*/
/**
* GladeProject::widget-name-changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeWidget who's name changed.
*
* Emitted when @gwidget's name changes.
*/
glade_project_signals[WIDGET_NAME_CHANGED] =
g_signal_new ("widget_name_changed",
G_TYPE_FROM_CLASS (object_class),
......@@ -794,12 +793,12 @@ glade_project_class_init (GladeProjectClass * klass)
G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
/**
* GladeProject::selection-changed:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject selection list changes.
*/
/**
* GladeProject::selection-changed:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject selection list changes.
*/
glade_project_signals[SELECTION_CHANGED] =
g_signal_new ("selection_changed",
G_TYPE_FROM_CLASS (object_class),
......@@ -808,13 +807,13 @@ glade_project_class_init (GladeProjectClass * klass)
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::close:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when a project is closing (a good time to clean up
* any associated resources).
*/
/**
* GladeProject::close:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when a project is closing (a good time to clean up
* any associated resources).
*/
glade_project_signals[CLOSE] =
g_signal_new ("close",
G_TYPE_FROM_CLASS (object_class),
......@@ -822,14 +821,14 @@ glade_project_class_init (GladeProjectClass * klass)
G_STRUCT_OFFSET (GladeProjectClass, close),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeCommand that was executed
* @arg2: whether the command was executed or undone.
*
* Emitted when a @gladeproject's state changes via a #GladeCommand.
*/
/**
* GladeProject::changed:
* @gladeproject: the #GladeProject which received the signal.
* @arg1: the #GladeCommand that was executed
* @arg2: whether the command was executed or undone.
*
* Emitted when a @gladeproject's state changes via a #GladeCommand.
*/
glade_project_signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_CLASS (object_class),
......@@ -839,12 +838,12 @@ glade_project_class_init (GladeProjectClass * klass)
glade_marshal_VOID__OBJECT_BOOLEAN,
G_TYPE_NONE, 2, GLADE_TYPE_COMMAND, G_TYPE_BOOLEAN);
/**
* GladeProject::parse-began:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing starts.
*/
/**
* GladeProject::parse-began:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing starts.
*/
glade_project_signals[PARSE_BEGAN] =
g_signal_new ("parse-began",
G_TYPE_FROM_CLASS (object_class),
......@@ -852,12 +851,12 @@ glade_project_class_init (GladeProjectClass * klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::parse-finished:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing has finished.
*/
/**
* GladeProject::parse-finished:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject parsing has finished.
*/
glade_project_signals[PARSE_FINISHED] =
g_signal_new ("parse-finished",
G_TYPE_FROM_CLASS (object_class),
......@@ -865,12 +864,12 @@ glade_project_class_init (GladeProjectClass * klass)
G_STRUCT_OFFSET (GladeProjectClass, parse_finished),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::targets-changed:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject target versions change.
*/
/**
* GladeProject::targets-changed:
* @gladeproject: the #GladeProject which received the signal.
*
* Emitted when @gladeproject target versions change.
*/
glade_project_signals[TARGETS_CHANGED] =
g_signal_new ("targets-changed",
G_TYPE_FROM_CLASS (object_class),
......@@ -878,14 +877,14 @@ glade_project_class_init (GladeProjectClass * klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
/**
* GladeProject::load-progress:
* @gladeproject: the #GladeProject which received the signal.
* @objects_total: the total amount of objects to load
* @objects_loaded: the current amount of loaded objects
*
* Emitted while @project is loading.
*/
/**
* GladeProject::load-progress:
* @gladeproject: the #GladeProject which received the signal.
* @objects_total: the total amount of objects to load
* @objects_loaded: the current amount of loaded objects
*
* Emitted while @project is loading.
*/
glade_project_signals[LOAD_PROGRESS] =
g_signal_new ("load-progress",
G_TYPE_FROM_CLASS (object_class),
......@@ -1542,9 +1541,6 @@ glade_project_load_internal (GladeProject * project)
*/
glade_project_verify_project_for_ui (project);
/* Update various things in the UI */
glade_app_update_ui ();
return TRUE;
}
......
......@@ -28,7 +28,7 @@
</signals>
<actions>
<action id="preview" _name="Preview snapshot"/>
<action id="preview" _name="Preview snapshot" stock="gtk-execute" important="True"/>
<action id="edit_separate" _name="Edit Separately" stock="gtk-edit"/>
<action id="remove_parent" _name="Remove Parent" stock="gtk-remove"/>
<action id="add_parent" _name="Add Parent" stock="gtk-add">
......
......@@ -120,7 +120,6 @@ struct _GladeWindowPrivate
gchar *default_path; /* the default path for open/save operations */
GtkToggleToolButton *selector_button; /* the widget selector button (replaces the one in the palette) */
GtkToolButton *preview_button; /* the project preview button (replaces the one in the palette) */
GtkToggleToolButton *drag_resize_button; /* sets the pointer to drag/resize mode */
gboolean setting_pointer_mode; /* avoid feedback signal loops */
......@@ -139,7 +138,7 @@ struct _GladeWindowPrivate
ToolDock docks[N_DOCKS];
};
static void refresh_undo_redo (GladeWindow * window);
static void refresh_undo_redo (GladeWindow *window, GladeProject *project);
static void recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
GladeWindow * window);
......@@ -427,11 +426,12 @@ add_actions (GladeWindow * window, GladeWidget * widget, GList * actions)
continue;
}
item =
gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->
stock : "gtk-execute");
item = gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->stock : "gtk-execute");
if (a->klass->label)
gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), a->klass->label);
{
gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), a->klass->label);
gtk_widget_set_tooltip_text (GTK_WIDGET (item), a->klass->label);
}
g_object_set_data (G_OBJECT (item), "glade-widget", widget);