[planner: 23/61] planner-task-popup: Port to GtkUIManager
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 23/61] planner-task-popup: Port to GtkUIManager
- Date: Sat, 12 Jun 2021 17:30:24 +0000 (UTC)
commit b0308dd1012f6a1343008ba8bce7cae70ffb0e06
Author: Mart Raudsepp <leio gentoo org>
Date: Fri Dec 25 21:18:50 2020 +0200
planner-task-popup: Port to GtkUIManager
GtkItemFactory doesn't exist in GTK3, while GtkUIManager exists in both
GTK2 and GTK3, so port to the latter for now as an iterative step, despite
GtkUIManager itself being deprecated in early GTK3.
As this is more of a temporary step until we can move over to GAction and
co, make PlannerTaskTree maintain its own GtkUIManager for its popup menu
instead of combining with the main PlannerWindow manager and its existing
"Insert Task" and other actions for a more straightforward port away from
GtkItemFactory.
Use Planner stock icons for the menu items for which we have stock icons,
to match the menubar/toolbar icons, instead of using GTK_STOCK_DELETE for
just "Remove task" like GtkItemFactory did. Other than that, the end
result in functionality and behaviour seems to match with the old
implementation.
This leaves the popup menu setup in planner-task-popup files, which isn't
ideal (in particular due to the naming) - but again, this is meant to be
a temporary step, so not spending time moving this cleanly into
planner-task-tree - it'll be easier to move to GAction and co later when
it remains separated out.
glib minimum requirement is raised to 2.50 for the g_abort() usage.
meson.build | 2 +-
src/planner-gantt-chart.c | 1 -
src/planner-gantt-row.c | 27 ++-----
src/planner-gantt-row.h | 2 -
src/planner-task-popup.c | 193 ++++++++++++++++++++++++----------------------
src/planner-task-popup.h | 20 ++---
src/planner-task-tree.c | 91 +++++++++++++---------
src/planner-task-tree.h | 2 +
8 files changed, 170 insertions(+), 168 deletions(-)
---
diff --git a/meson.build b/meson.build
index 664c7b4e..dfe6883a 100644
--- a/meson.build
+++ b/meson.build
@@ -43,7 +43,7 @@ libplanner_inc = include_directories('libplanner')
eds_req = '>= 3.6'
-glib_dep = dependency('glib-2.0', version: '>= 2.38.0')
+glib_dep = dependency('glib-2.0', version: '>= 2.50.0')
gmodule_dep = dependency('gmodule-2.0')
gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gobject-2.0')
diff --git a/src/planner-gantt-chart.c b/src/planner-gantt-chart.c
index 68447544..aa110827 100644
--- a/src/planner-gantt-chart.c
+++ b/src/planner-gantt-chart.c
@@ -1065,7 +1065,6 @@ gantt_chart_insert_task (PlannerGanttChart *chart,
"scale", SCALE (priv->zoom),
"zoom", priv->zoom,
NULL);
- planner_gantt_row_init_menu (PLANNER_GANTT_ROW (item));
tree_node = gantt_chart_tree_node_new ();
tree_node->item = item;
diff --git a/src/planner-gantt-row.c b/src/planner-gantt-row.c
index c9540986..bb53b4b4 100644
--- a/src/planner-gantt-row.c
+++ b/src/planner-gantt-row.c
@@ -167,9 +167,6 @@ struct _PlannerGanttRowPriv {
/* Cached positions of each assigned resource. */
GArray *resource_widths;
-
- /* FIXME: Don't need this per row. */
- GtkItemFactory *popup_factory;
};
static void gantt_row_class_init (PlannerGanttRowClass *class);
@@ -2559,6 +2556,7 @@ gantt_row_event (GnomeCanvasItem *item, GdkEvent *event)
GtkTreeView *tree_view;
GtkTreeIter iter;
GList *tasks;
+ GtkUIManager *popup_ui_manager;
chart = g_object_get_data (G_OBJECT (item->canvas), "chart");
tree = planner_gantt_chart_get_view (chart);
@@ -2581,14 +2579,13 @@ gantt_row_event (GnomeCanvasItem *item, GdkEvent *event)
}
tasks = gantt_row_get_selected_tasks (selection);
- planner_task_popup_update_sensitivity (priv->popup_factory, tasks);
+
+ popup_ui_manager = planner_task_tree_get_popup_ui_manager (tree);
+ planner_task_popup_update_sensitivity (popup_ui_manager, tasks);
g_list_free (tasks);
- gtk_item_factory_popup (priv->popup_factory,
- event->button.x_root,
- event->button.y_root,
- 0,
- gtk_get_current_event_time ());
+ gtk_menu_popup (GTK_MENU (gtk_ui_manager_get_widget (popup_ui_manager,
"/TaskPopup")),
+ NULL, NULL, NULL, NULL, event->button.button,
event->button.time);
return TRUE;
}
@@ -3184,18 +3181,6 @@ gantt_row_get_resource_by_index (PlannerGanttRow *row,
return TRUE;
}
-void
-planner_gantt_row_init_menu (PlannerGanttRow *row)
-{
- PlannerGanttChart *chart;
- PlannerTaskTree *tree;
-
- chart = g_object_get_data (G_OBJECT (GNOME_CANVAS_ITEM (row)->canvas), "chart");
- tree = planner_gantt_chart_get_view (chart);
-
- row->priv->popup_factory = planner_task_popup_new (tree);
-}
-
/* Save this code for later. */
#if 0
gdouble wx1, wx2;
diff --git a/src/planner-gantt-row.h b/src/planner-gantt-row.h
index 4cabfa71..912b43d9 100644
--- a/src/planner-gantt-row.h
+++ b/src/planner-gantt-row.h
@@ -58,6 +58,4 @@ void planner_gantt_row_get_geometry (PlannerGanttRow *row,
void planner_gantt_row_set_visible (PlannerGanttRow *row,
gboolean is_visible);
-void planner_gantt_row_init_menu (PlannerGanttRow *row);
-
#endif /* __PLANNER_GANTT_ROW_H__ */
diff --git a/src/planner-task-popup.c b/src/planner-task-popup.c
index 42cb4a31..a47ee6a2 100644
--- a/src/planner-task-popup.c
+++ b/src/planner-task-popup.c
@@ -26,137 +26,144 @@
#include "planner-task-popup.h"
-static void task_popup_insert_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void task_popup_insert_subtask_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void task_popup_remove_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void task_popup_edit_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void task_popup_edit_task_resources_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-static void task_popup_unlink_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget);
-
-
-#define GIF_CB(x) ((GtkItemFactoryCallback)(x))
-
-static GtkItemFactoryEntry popup_menu_items[] = {
- { N_("/_Insert task"), NULL, GIF_CB (task_popup_insert_task_cb),
- PLANNER_TASK_POPUP_INSERT, "<Item>", NULL
+static void task_popup_insert_task_cb (GtkAction *action,
+ gpointer callback_data);
+static void task_popup_insert_subtask_cb (GtkAction *action,
+ gpointer callback_data);
+static void task_popup_remove_task_cb (GtkAction *action,
+ gpointer callback_data);
+static void task_popup_edit_task_cb (GtkAction *action,
+ gpointer callback_data);
+static void task_popup_edit_task_resources_cb (GtkAction *action,
+ gpointer callback_data);
+static void task_popup_unlink_task_cb (GtkAction *action,
+ gpointer callback_data);
+
+
+static GtkActionEntry popup_menu_entries[] = {
+ { "InsertTask", "planner-stock-insert-task",
+ N_("_Insert task"), NULL, NULL,
+ G_CALLBACK (task_popup_insert_task_cb)
},
- { N_("/Insert _subtask"), NULL, GIF_CB (task_popup_insert_subtask_cb),
- PLANNER_TASK_POPUP_SUBTASK, "<Item>", NULL
+ { "InsertSubtask", NULL,
+ N_("Insert _subtask"), NULL, NULL,
+ G_CALLBACK (task_popup_insert_subtask_cb)
},
- { N_("/_Remove task"), NULL, GIF_CB (task_popup_remove_task_cb),
- PLANNER_TASK_POPUP_REMOVE, "<StockItem>", GTK_STOCK_DELETE
+ { "RemoveTask", "planner-stock-remove-task",
+ N_("_Remove task"), NULL, NULL,
+ G_CALLBACK (task_popup_remove_task_cb)
},
- { "/sep1", NULL, 0, PLANNER_TASK_POPUP_NONE, "<Separator>"
+ { "UnlinkTask", "planner-stock-unlink-task",
+ N_("_Unlink task"), NULL, NULL,
+ G_CALLBACK (task_popup_unlink_task_cb)
},
- { N_("/_Unlink task"), NULL, GIF_CB (task_popup_unlink_task_cb),
- PLANNER_TASK_POPUP_UNLINK, "<Item>", NULL
+ { "AssignResources", NULL,
+ N_("Assign _resources..."), NULL, NULL,
+ G_CALLBACK (task_popup_edit_task_resources_cb)
},
- { "/sep2", NULL, 0, PLANNER_TASK_POPUP_NONE, "<Separator>"
+ { "EditTask", NULL,
+ N_("_Edit task..."), NULL, NULL,
+ G_CALLBACK (task_popup_edit_task_cb)
},
- { N_("/Assign _resources..."), NULL, GIF_CB (task_popup_edit_task_resources_cb),
- PLANNER_TASK_POPUP_EDIT_RESOURCES, "<Item>", NULL
- },
- { N_("/_Edit task..."), NULL, GIF_CB (task_popup_edit_task_cb),
- PLANNER_TASK_POPUP_EDIT_TASK, "<Item>", NULL
- }
};
-static char *
-task_tree_item_factory_trans (const char *path, gpointer data)
-{
- return _((gchar *)path);
-}
+static const char *popup_menu =
+"<ui>"
+ "<popup name='TaskPopup'>"
+ "<menuitem action='InsertTask'/>"
+ "<menuitem action='InsertSubtask'/>"
+ "<menuitem action='RemoveTask'/>"
+ "<separator/>"
+ "<menuitem action='UnlinkTask'/>"
+ "<separator/>"
+ "<menuitem action='AssignResources'/>"
+ "<menuitem action='EditTask'/>"
+ "</popup>"
+"</ui>";
static void
-task_popup_insert_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+task_popup_insert_task_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_insert_task (callback_data);
}
static void
-task_popup_insert_subtask_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+task_popup_insert_subtask_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_insert_subtask (callback_data);
}
static void
-task_popup_remove_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+task_popup_remove_task_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_remove_task (callback_data);
}
static void
-task_popup_edit_task_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+task_popup_edit_task_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_edit_task (callback_data,
PLANNER_TASK_DIALOG_PAGE_GENERAL);
}
static void
-task_popup_edit_task_resources_cb (gpointer callback_data,
- guint action,
- GtkWidget *widget)
+task_popup_edit_task_resources_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_edit_task (callback_data,
PLANNER_TASK_DIALOG_PAGE_RESOURCES);
}
static void
-task_popup_unlink_task_cb (gpointer callback_data, guint action,
- GtkWidget *widget)
+task_popup_unlink_task_cb (GtkAction *action,
+ gpointer callback_data)
{
planner_task_tree_unlink_task (callback_data);
}
-GtkItemFactory *
+GtkUIManager *
planner_task_popup_new (PlannerTaskTree *tree)
{
- GtkItemFactory *item_factory;
-
- item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", NULL);
- gtk_item_factory_set_translate_func (item_factory,
- task_tree_item_factory_trans,
- NULL, NULL);
-
- gtk_item_factory_create_items (item_factory,
- G_N_ELEMENTS (popup_menu_items),
- popup_menu_items, tree);
-
- return item_factory;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GError *error;
+
+ action_group = gtk_action_group_new ("TaskPopupActions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ popup_menu_entries,
+ G_N_ELEMENTS (popup_menu_entries),
+ tree);
+
+ ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+
+ error = NULL;
+ if (!gtk_ui_manager_add_ui_from_string (ui_manager, popup_menu, -1, &error))
+ {
+ g_critical ("Building task popup menu failed: %s", error->message);
+ g_error_free (error);
+ g_abort ();
+ }
+ return ui_manager;
}
-static void
-task_popup_set_sensitive (GtkItemFactory *factory, gint id, gboolean sensitive)
+void
+planner_task_popup_set_sensitive (GtkUIManager *ui_manager, const gchar *path, gboolean sensitive)
{
- GtkWidget *widget;
+ GtkAction *action;
- widget = gtk_item_factory_get_widget_by_action (factory, id);
- gtk_widget_set_sensitive (widget, sensitive);
+ action = gtk_ui_manager_get_action (ui_manager, path);
+ gtk_action_set_sensitive (action, sensitive);
}
void
-planner_task_popup_update_sensitivity (GtkItemFactory *factory,
- GList *tasks)
+planner_task_popup_update_sensitivity (GtkUIManager *ui_manager,
+ GList *tasks)
{
gint length;
MrpTask *task;
@@ -166,15 +173,15 @@ planner_task_popup_update_sensitivity (GtkItemFactory *factory,
length = g_list_length (tasks);
/* Can always insert task. */
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_INSERT, TRUE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/InsertTask", TRUE);
/* Nothing else when nothing is selected. */
if (length == 0) {
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_SUBTASK, FALSE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_REMOVE, FALSE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_UNLINK, FALSE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_EDIT_TASK, FALSE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_EDIT_RESOURCES, FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/InsertSubtask", FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/RemoveTask", FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/UnlinkTask", FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/AssignResources", FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/EditTask", FALSE);
return;
}
@@ -184,14 +191,14 @@ planner_task_popup_update_sensitivity (GtkItemFactory *factory,
type = mrp_task_get_task_type (task);
milestone = (type == MRP_TASK_TYPE_MILESTONE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_SUBTASK, !milestone);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/InsertSubtask", !milestone);
} else {
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_SUBTASK, FALSE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/InsertSubtask", FALSE);
}
/* The rest are always sensitive when one more more tasks are selected. */
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_REMOVE, TRUE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_UNLINK, TRUE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_EDIT_TASK, TRUE);
- task_popup_set_sensitive (factory, PLANNER_TASK_POPUP_EDIT_RESOURCES, TRUE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/RemoveTask", TRUE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/UnlinkTask", TRUE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/AssignResources", TRUE);
+ planner_task_popup_set_sensitive (ui_manager, "/TaskPopup/EditTask", TRUE);
}
diff --git a/src/planner-task-popup.h b/src/planner-task-popup.h
index e3698f8c..c55d13ad 100644
--- a/src/planner-task-popup.h
+++ b/src/planner-task-popup.h
@@ -21,20 +21,14 @@
#define __PLANNER_TASK_POPUP_H__
#include <gtk/gtk.h>
+#include "planner-task-tree.h"
-typedef enum {
- PLANNER_TASK_POPUP_NONE,
- PLANNER_TASK_POPUP_INSERT,
- PLANNER_TASK_POPUP_SUBTASK,
- PLANNER_TASK_POPUP_REMOVE,
- PLANNER_TASK_POPUP_UNLINK,
- PLANNER_TASK_POPUP_EDIT_TASK,
- PLANNER_TASK_POPUP_EDIT_RESOURCES
-} PlannerTaskPopupItem;
-
-GtkItemFactory *planner_task_popup_new (PlannerTaskTree *tree);
-void planner_task_popup_update_sensitivity (GtkItemFactory *factory,
- GList *tasks);
+GtkUIManager *planner_task_popup_new (PlannerTaskTree *tree);
+void planner_task_popup_set_sensitive (GtkUIManager *ui_manager,
+ const gchar *path,
+ gboolean sensitive);
+void planner_task_popup_update_sensitivity (GtkUIManager *ui_manager,
+ GList *tasks);
#endif
diff --git a/src/planner-task-tree.c b/src/planner-task-tree.c
index 598fcba7..60626ea4 100644
--- a/src/planner-task-tree.c
+++ b/src/planner-task-tree.c
@@ -52,7 +52,7 @@ enum {
};
struct _PlannerTaskTreePriv {
- GtkItemFactory *popup_factory;
+ GtkUIManager *popup_ui_manager;
gboolean custom_properties;
MrpProject *project;
GHashTable *property_to_column;
@@ -1043,7 +1043,7 @@ task_tree_init (PlannerTaskTree *tree)
tree->priv = priv;
priv->property_to_column = g_hash_table_new (NULL, NULL);
- priv->popup_factory = planner_task_popup_new (tree);
+ priv->popup_ui_manager = planner_task_popup_new (tree);
priv->anchor = NULL;
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (tree), FALSE);
@@ -1068,6 +1068,8 @@ task_tree_finalize (GObject *object)
tree = PLANNER_TASK_TREE (object);
priv = tree->priv;
+ g_clear_object (&tree->priv->popup_ui_manager);
+
g_hash_table_destroy (priv->property_to_column);
planner_task_tree_set_anchor (tree, NULL);
@@ -1204,46 +1206,58 @@ task_tree_task_removed_cb (PlannerGanttModel *model,
}
static void
-task_tree_tree_view_popup_menu (GtkWidget *widget,
- PlannerTaskTree *tree)
+task_tree_menu_position_on_current_cell (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
{
- GList *tasks;
+ PlannerTaskTree *tree;
GtkTreePath *path;
GtkTreeViewColumn *column;
GdkRectangle rect;
- gint x, y;
-
- tasks = planner_task_tree_get_selected_tasks (tree);
- planner_task_popup_update_sensitivity (tree->priv->popup_factory, tasks);
- g_list_free (tasks);
+ gint pos_x, pos_y;
+ tree = PLANNER_TASK_TREE (user_data);
gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree), &path, &column);
gtk_tree_view_get_cell_area (GTK_TREE_VIEW (tree),
path,
column,
&rect);
- x = rect.x;
- y = rect.y;
+ pos_x = rect.x;
+ pos_y = rect.y;
/* Note: this is not perfect, but good enough for now. */
- gdk_window_get_root_origin (GTK_WIDGET (tree)->window, &x, &y);
- rect.x += x;
- rect.y += y;
+ gdk_window_get_root_origin (GTK_WIDGET (tree)->window, &pos_x, &pos_y);
+ rect.x += pos_x;
+ rect.y += pos_y;
gtk_widget_translate_coordinates (GTK_WIDGET (tree),
gtk_widget_get_toplevel (GTK_WIDGET (tree)),
rect.x, rect.y,
- &x, &y);
+ &pos_x, &pos_y);
/* Offset so it's not overlapping the cell. */
- rect.x = x + 20;
- rect.y = y + 20;
+ *x = pos_x + 20;
+ *y = pos_y + 20;
+ *push_in = TRUE;
+}
- gtk_item_factory_popup (tree->priv->popup_factory,
- rect.x, rect.y,
- 0,
- gtk_get_current_event_time ());
+static void
+task_tree_tree_view_popup_menu (GtkWidget *widget,
+ PlannerTaskTree *tree)
+{
+ GList *tasks;
+
+ tasks = planner_task_tree_get_selected_tasks (tree);
+ planner_task_popup_update_sensitivity (tree->priv->popup_ui_manager, tasks);
+ g_list_free (tasks);
+
+ gtk_menu_popup (GTK_MENU (gtk_ui_manager_get_widget (tree->priv->popup_ui_manager, "/TaskPopup")),
+ NULL, NULL,
+ task_tree_menu_position_on_current_cell, tree,
+ 0, gtk_get_current_event_time ());
}
static gboolean
@@ -1253,12 +1267,12 @@ task_tree_tree_view_button_press_event (GtkTreeView *tv,
{
GtkTreePath *path;
PlannerTaskTreePriv *priv;
- GtkItemFactory *factory;
+ GtkUIManager *popup_ui_manager;
GtkTreeIter iter;
GList *tasks;
priv = tree->priv;
- factory = priv->popup_factory;
+ popup_ui_manager = priv->popup_ui_manager;
if (event->button == 3) {
gtk_widget_grab_focus (GTK_WIDGET (tree));
@@ -1272,7 +1286,7 @@ task_tree_tree_view_button_press_event (GtkTreeView *tv,
}
tasks = planner_task_tree_get_selected_tasks (tree);
- planner_task_popup_update_sensitivity (factory, tasks);
+ planner_task_popup_update_sensitivity (popup_ui_manager, tasks);
g_list_free (tasks);
planner_task_tree_set_anchor (tree, path);
@@ -1280,22 +1294,17 @@ task_tree_tree_view_button_press_event (GtkTreeView *tv,
} else {
gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (tv));
- gtk_widget_set_sensitive (
- gtk_item_factory_get_widget_by_action (factory, PLANNER_TASK_POPUP_SUBTASK),
FALSE);
- gtk_widget_set_sensitive (
- gtk_item_factory_get_widget_by_action (factory, PLANNER_TASK_POPUP_REMOVE),
FALSE);
- gtk_widget_set_sensitive (
- gtk_item_factory_get_widget_by_action (factory, PLANNER_TASK_POPUP_UNLINK),
FALSE);
- gtk_widget_set_sensitive (
- gtk_item_factory_get_widget_by_action (factory,
PLANNER_TASK_POPUP_EDIT_RESOURCES), FALSE);
- gtk_widget_set_sensitive (
- gtk_item_factory_get_widget_by_action (factory,
PLANNER_TASK_POPUP_EDIT_TASK), FALSE);
+ planner_task_popup_set_sensitive (popup_ui_manager, "/TaskPopup/InsertSubtask",
FALSE);
+ planner_task_popup_set_sensitive (popup_ui_manager, "/TaskPopup/RemoveTask", FALSE);
+ planner_task_popup_set_sensitive (popup_ui_manager, "/TaskPopup/UnlinkTask", FALSE);
+ planner_task_popup_set_sensitive (popup_ui_manager, "/TaskPopup/AssignResources",
FALSE);
+ planner_task_popup_set_sensitive (popup_ui_manager, "/TaskPopup/EditTask", FALSE);
planner_task_tree_set_anchor (tree, NULL);
}
- gtk_item_factory_popup (factory, event->x_root, event->y_root,
- event->button, event->time);
+ gtk_menu_popup (GTK_MENU (gtk_ui_manager_get_widget (popup_ui_manager, "/TaskPopup")),
+ NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE;
}
else if (event->button == 1) {
@@ -3720,3 +3729,11 @@ planner_task_tree_get_window (PlannerTaskTree *tree)
return tree->priv->main_window;
}
+
+GtkUIManager *
+planner_task_tree_get_popup_ui_manager (PlannerTaskTree *tree)
+{
+ g_return_val_if_fail (PLANNER_IS_TASK_TREE (tree), NULL);
+
+ return tree->priv->popup_ui_manager;
+}
diff --git a/src/planner-task-tree.h b/src/planner-task-tree.h
index ee630283..b0576f2e 100644
--- a/src/planner-task-tree.h
+++ b/src/planner-task-tree.h
@@ -101,4 +101,6 @@ PlannerCmd* planner_task_tree_task_cmd_link (PlannerTaskTree *tr
/* Temporal functions. We need to approve them. */
PlannerWindow * planner_task_tree_get_window (PlannerTaskTree *tree);
+GtkUIManager * planner_task_tree_get_popup_ui_manager (PlannerTaskTree *tree);
+
#endif /* __PLANNER_TASK_TREE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]