[dia] Bug 680688 - disable most top menu items when there is no display
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Bug 680688 - disable most top menu items when there is no display
- Date: Thu, 25 Sep 2014 19:25:58 +0000 (UTC)
commit c7e6676fddc6f017b3d1e13212ab954cafa2d5b7
Author: Hans Breuer <hans breuer org>
Date: Mon Sep 22 22:40:57 2014 +0200
Bug 680688 - disable most top menu items when there is no display
there was almost everything needed with display_actions, just some common_entries
not to be included for the integrated UI case, otherwise we could not load a
diagram or quit anymore.
app/diagram.c | 12 ++++++------
app/display.c | 2 ++
app/menus.c | 19 +++++++++++++------
app/menus.h | 2 ++
4 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/app/diagram.c b/app/diagram.c
index 7f0a3bc..fde83fe 100644
--- a/app/diagram.c
+++ b/app/diagram.c
@@ -541,9 +541,9 @@ object_within_parent(DiaObject *obj, DiaObject *p)
void
diagram_update_menu_sensitivity (Diagram *dia)
{
- gint selected_count = g_list_length (dia->data->selected);
+ gint selected_count = dia ? g_list_length (dia->data->selected) : 0;
DDisplay *ddisp = ddisplay_active();
- gboolean focus_active = (get_active_focus(dia->data) != NULL);
+ gboolean focus_active = dia ? (get_active_focus(dia->data) != NULL) : FALSE;
gboolean textedit_active = ddisp ? textedit_mode(ddisp) : FALSE;
GtkAction *action;
@@ -588,13 +588,13 @@ diagram_update_menu_sensitivity (Diagram *dia)
if ((action = menus_get_action ("ObjectsGroup")) != NULL)
gtk_action_set_sensitive (action, !textedit_active && selected_count > 1);
if ((action = menus_get_action ("ObjectsUngroup")) != NULL)
- gtk_action_set_sensitive (action, !textedit_active && diagram_selected_any_groups (dia));
+ gtk_action_set_sensitive (action, !textedit_active && dia && diagram_selected_any_groups (dia));
if ((action = menus_get_action ("ObjectsParent")) != NULL)
- gtk_action_set_sensitive (action, !textedit_active && diagram_selected_can_parent (dia));
+ gtk_action_set_sensitive (action, !textedit_active && dia && diagram_selected_can_parent (dia));
if ((action = menus_get_action ("ObjectsUnparent")) != NULL)
- gtk_action_set_sensitive (action, !textedit_active && diagram_selected_any_children (dia));
+ gtk_action_set_sensitive (action, !textedit_active && dia && diagram_selected_any_children (dia));
if ((action = menus_get_action ("ObjectsUnparentchildren")) != NULL)
- gtk_action_set_sensitive (action, !textedit_active && diagram_selected_any_parents (dia));
+ gtk_action_set_sensitive (action, !textedit_active && dia && diagram_selected_any_parents (dia));
if ((action = menus_get_action ("ObjectsProperties")) != NULL)
gtk_action_set_sensitive (action, selected_count > 0);
diff --git a/app/display.c b/app/display.c
index 053e804..f8f99c0 100644
--- a/app/display.c
+++ b/app/display.c
@@ -1375,8 +1375,10 @@ ddisplay_do_update_menu_sensitivity (DDisplay *ddisp)
Diagram *dia;
if (ddisp == NULL) {
+ gtk_action_group_set_sensitive (menus_get_display_actions (), FALSE);
return;
}
+ gtk_action_group_set_sensitive (menus_get_display_actions (), TRUE);
dia = ddisp->diagram;
diagram_update_menu_sensitivity (dia);
}
diff --git a/app/menus.c b/app/menus.c
index fc748dd..994fada 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -874,15 +874,16 @@ _ui_manager_connect_proxy (GtkUIManager *manager,
}
static GtkActionGroup *
-create_or_ref_display_actions (void)
+create_or_ref_display_actions (gboolean include_common)
{
if (display_actions)
return g_object_ref (display_actions);
display_actions = gtk_action_group_new ("display-actions");
gtk_action_group_set_translation_domain (display_actions, NULL);
gtk_action_group_set_translate_func (display_actions, _dia_translate, NULL, NULL);
- gtk_action_group_add_actions (display_actions, common_entries,
- G_N_ELEMENTS (common_entries), NULL);
+ if (include_common)
+ gtk_action_group_add_actions (display_actions, common_entries,
+ G_N_ELEMENTS (common_entries), NULL);
gtk_action_group_add_actions (display_actions, display_entries,
G_N_ELEMENTS (display_entries), NULL);
gtk_action_group_add_toggle_actions (display_actions, display_toggle_entries,
@@ -985,7 +986,7 @@ menus_init(void)
g_free (uifile);
/* the display menu */
- display_actions = create_or_ref_display_actions ();
+ display_actions = create_or_ref_display_actions (TRUE);
display_ui_manager = gtk_ui_manager_new ();
g_signal_connect (G_OBJECT (display_ui_manager),
@@ -1040,7 +1041,7 @@ menus_get_integrated_ui_menubar (GtkWidget **menubar,
g_return_if_fail (_ui_manager != NULL);
/* the integrated ui menu */
- display_actions = create_or_ref_display_actions ();
+ display_actions = create_or_ref_display_actions (FALSE);
g_return_if_fail (tool_actions != NULL);
/* maybe better to put this into toolbox_actions? */
@@ -1120,7 +1121,7 @@ menus_create_display_menubar (GtkUIManager **ui_manager,
gchar *uifile;
- *actions = create_or_ref_display_actions ();
+ *actions = create_or_ref_display_actions (TRUE);
tool_actions = create_or_ref_tool_actions ();
*ui_manager = gtk_ui_manager_new ();
@@ -1149,6 +1150,12 @@ menus_get_tool_actions (void)
return tool_actions;
}
+GtkActionGroup *
+menus_get_display_actions (void)
+{
+ return display_actions;
+}
+
GtkAction *
menus_get_action (const gchar *name)
{
diff --git a/app/menus.h b/app/menus.h
index 9ae3cb1..d300bc6 100644
--- a/app/menus.h
+++ b/app/menus.h
@@ -47,6 +47,8 @@ GtkAccelGroup * menus_get_display_accels (void);
GtkWidget * menus_create_display_menubar (GtkUIManager **ui_manager, GtkActionGroup **actions);
GtkActionGroup *menus_get_tool_actions (void);
+GtkActionGroup *menus_get_display_actions (void);
+
GtkAction * menus_get_action (const gchar *name);
GtkWidget * menus_get_widget (const gchar *name);
void menus_set_recent (GtkActionGroup *actions);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]