aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-03-10 09:06:18 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-03-10 09:06:18 +0800
commit7a92d9cc82b7775a0f5cb1fde233119d435a79b6 (patch)
tree0bf446e28f6068a36dc3164725d3c37b05db4f6c /e-util
parentf963cc39a7d21f64f578dae50fd08c44181a3bf6 (diff)
downloadgsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar.gz
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar.bz2
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar.lz
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar.xz
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.tar.zst
gsoc2013-evolution-7a92d9cc82b7775a0f5cb1fde233119d435a79b6.zip
Add e_lookup_action() and e_lookup_action_group() to e-util, so
I don't have to keep writing the algorithm over and over again. Add EFileActivity, which provides a GCancellable for GIO operations. Cancelling the activity cancels the GIO operation, and vice versa. Also provides a handy GFileProgressCallback function which updates the activity's "percent" property. svn path=/branches/kill-bonobo/; revision=37396
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c80
-rw-r--r--e-util/e-util.h4
2 files changed, 84 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 32f6169bd5..e4e9a3ac32 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -213,6 +213,86 @@ e_file_open_tmp (gchar **name_used,
}
/**
+ * e_lookup_action:
+ * @ui_manager: a #GtkUIManager
+ * @action_name: the name of an action
+ *
+ * Returns the first #GtkAction named @action_name by traversing the
+ * list of action groups in @ui_manager. If no such action exists, the
+ * function emits a critical warning before returning %NULL, since this
+ * probably indicates a programming error and most code is not prepared
+ * to deal with lookup failures.
+ *
+ * Returns: the first #GtkAction named @action_name
+ **/
+GtkAction *
+e_lookup_action (GtkUIManager *ui_manager,
+ const gchar *action_name)
+{
+ GtkAction *action = NULL;
+ GList *iter;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (ui_manager), NULL);
+ g_return_val_if_fail (action_name != NULL, NULL);
+
+ iter = gtk_ui_manager_get_action_groups (ui_manager);
+
+ while (iter != NULL) {
+ GtkActionGroup *action_group = iter->data;
+
+ action = gtk_action_group_get_action (
+ action_group, action_name);
+ if (action != NULL)
+ return action;
+
+ iter = g_list_next (iter);
+ }
+
+ g_critical ("%s: action `%s' not found", G_STRFUNC, action_name);
+
+ return NULL;
+}
+
+/**
+ * e_lookup_action_group:
+ * @ui_manager: a #GtkUIManager
+ * @group_name: the name of an action group
+ *
+ * Returns the #GtkActionGroup in @ui_manager named @group_name. If no
+ * such action group exists, the function emits a critical warnings before
+ * returning %NULL, since this probably indicates a programming error and
+ * most code is not prepared to deal with lookup failures.
+ *
+ * Returns: the #GtkActionGroup named @group_name
+ **/
+GtkActionGroup *
+e_lookup_action_group (GtkUIManager *ui_manager,
+ const gchar *group_name)
+{
+ GList *iter;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (ui_manager), NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+
+ iter = gtk_ui_manager_get_action_groups (ui_manager);
+
+ while (iter != NULL) {
+ GtkActionGroup *action_group = iter->data;
+ const gchar *name;
+
+ name = gtk_action_group_get_name (action_group);
+ if (strcmp (name, group_name) == 0)
+ return action_group;
+
+ iter = g_list_next (iter);
+ }
+
+ g_critical ("%s: action group `%s' not found", G_STRFUNC, group_name);
+
+ return NULL;
+}
+
+/**
* e_load_ui_definition:
* @ui_manager: a #GtkUIManager
* @basename: basename of the UI definition file
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 5f431156eb..744b4a7a9d 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -48,6 +48,10 @@ void e_display_help (GtkWindow *parent,
const gchar *link_id);
gint e_file_open_tmp (gchar **name_used,
GError **error);
+GtkAction * e_lookup_action (GtkUIManager *ui_manager,
+ const gchar *action_name);
+GtkActionGroup *e_lookup_action_group (GtkUIManager *ui_manager,
+ const gchar *group_name);
guint e_load_ui_definition (GtkUIManager *ui_manager,
const gchar *basename);
gint e_action_compare_by_label (GtkAction *action1,