dia r3994 - in trunk: . app plug-ins/python
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r3994 - in trunk: . app plug-ins/python
- Date: Sat, 10 May 2008 11:20:15 +0100 (BST)
Author: hans
Date: Sat May 10 10:20:14 2008
New Revision: 3994
URL: http://svn.gnome.org/viewvc/dia?rev=3994&view=rev
Log:
2008-05-10 Hans Breuer <hans breuer org>
* plug-ins/python/select_empty.py : allows to find objects with empty
bounding boxes like empty text. See bug #99375.
* plug-ins/python/Makefile.am : install it
* app/display.c(selection_changed) : update menu sensitivity in the
signal handler for selection changed. Could replace a lot of explicit
updates, but is needed when the selection is changed from a plug-in
* app/diagram.c(diagram_update_menu_sensitivity) : maybe called with
ddisplay_active() returning NULL, don't crash on that.
Added:
trunk/plug-ins/python/select_empty.py (contents, props changed)
Modified:
trunk/ChangeLog
trunk/app/diagram.c
trunk/app/display.c
trunk/plug-ins/python/Makefile.am
Modified: trunk/app/diagram.c
==============================================================================
--- trunk/app/diagram.c (original)
+++ trunk/app/diagram.c Sat May 10 10:20:14 2008
@@ -501,6 +501,8 @@
gint selected_count = g_list_length (dia->data->selected);
DDisplay *ddisp = ddisplay_active();
gboolean focus_active = (get_active_focus(dia->data) != NULL);
+ gboolean textedit_active = ddisp ? textedit_mode(ddisp) : FALSE;
+
/* Edit menu */
gtk_action_set_sensitive (items->undo,
undo_available(dia->undo, TRUE));
@@ -508,15 +510,15 @@
undo_available(dia->undo, FALSE));
gtk_action_set_sensitive (items->copy,
- textedit_mode(ddisp) || selected_count > 0);
+ textedit_active || selected_count > 0);
gtk_action_set_sensitive (items->cut,
textedit_mode(ddisp) || selected_count > 0);
gtk_action_set_sensitive (items->paste,
- textedit_mode(ddisp) || cnp_exist_stored_objects());
+ textedit_active || cnp_exist_stored_objects());
gtk_action_set_sensitive (items->edit_delete,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->edit_duplicate,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->copy_text, focus_active);
gtk_action_set_sensitive (items->cut_text, focus_active);
@@ -524,67 +526,67 @@
/* Objects menu */
gtk_action_set_sensitive (items->send_to_back,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->bring_to_front,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->send_backwards,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->bring_forwards,
- !textedit_mode(ddisp) && selected_count > 0);
+ !textedit_active && selected_count > 0);
gtk_action_set_sensitive (items->parent,
- !textedit_mode(ddisp) && diagram_selected_can_parent (dia));
+ !textedit_active && diagram_selected_can_parent (dia));
gtk_action_set_sensitive (items->unparent,
- !textedit_mode(ddisp) && diagram_selected_any_children (dia));
+ !textedit_active && diagram_selected_any_children (dia));
gtk_action_set_sensitive (items->unparent_children,
- !textedit_mode(ddisp) && diagram_selected_any_parents (dia));
+ !textedit_active && diagram_selected_any_parents (dia));
gtk_action_set_sensitive (items->group,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->ungroup,
- !textedit_mode(ddisp) && diagram_selected_any_groups (dia));
+ !textedit_active && diagram_selected_any_groups (dia));
gtk_action_set_sensitive (items->properties, selected_count > 0);
/* Objects->Align menu */
gtk_action_set_sensitive (items->align_h_l,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_h_c,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_h_r,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_h_e,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_h_a,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_v_t,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_v_c,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_v_b,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_v_e,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
gtk_action_set_sensitive (items->align_v_a,
- !textedit_mode(ddisp) && selected_count > 1);
+ !textedit_active && selected_count > 1);
/* Select menu */
- gtk_action_set_sensitive (items->select_all, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_none, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_invert, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_transitive, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_connected, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_same_type, !textedit_mode(ddisp));
-
- gtk_action_set_sensitive (items->select_replace, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_union, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_intersection, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_remove, !textedit_mode(ddisp));
- gtk_action_set_sensitive (items->select_inverse, !textedit_mode(ddisp));
+ gtk_action_set_sensitive (items->select_all, !textedit_active);
+ gtk_action_set_sensitive (items->select_none, !textedit_active);
+ gtk_action_set_sensitive (items->select_invert, !textedit_active);
+ gtk_action_set_sensitive (items->select_transitive, !textedit_active);
+ gtk_action_set_sensitive (items->select_connected, !textedit_active);
+ gtk_action_set_sensitive (items->select_same_type, !textedit_active);
+
+ gtk_action_set_sensitive (items->select_replace, !textedit_active);
+ gtk_action_set_sensitive (items->select_union, !textedit_active);
+ gtk_action_set_sensitive (items->select_intersection, !textedit_active);
+ gtk_action_set_sensitive (items->select_remove, !textedit_active);
+ gtk_action_set_sensitive (items->select_inverse, !textedit_active);
}
void diagram_update_menubar_sensitivity(Diagram *dia, UpdatableMenuItems *items)
{
- diagram_update_menu_sensitivity (dia, items);
+ diagram_update_menu_sensitivity (dia, items);
}
Modified: trunk/app/display.c
==============================================================================
--- trunk/app/display.c (original)
+++ trunk/app/display.c Sat May 10 10:20:14 2008
@@ -128,6 +128,8 @@
{
gtk_statusbar_pop (statusbar, context_id);
}
+ /* selection-changed signal can also be emitted from outside of the dia core */
+ ddisplay_do_update_menu_sensitivity (ddisp);
}
static void
@@ -1511,7 +1513,7 @@
Focus *
ddisplay_active_focus(DDisplay *ddisp)
{
- return ddisp->active_focus;
+ return ddisp ? ddisp->active_focus : NULL;
}
/** Set the currently active focus for this display. This field should be
Modified: trunk/plug-ins/python/Makefile.am
==============================================================================
--- trunk/plug-ins/python/Makefile.am (original)
+++ trunk/plug-ins/python/Makefile.am Sat May 10 10:20:14 2008
@@ -72,7 +72,8 @@
otypes.py \
pydiadoc.py \
scascale.py \
- select_by.py
+ select_by.py \
+ select_empty.py
endif
Added: trunk/plug-ins/python/select_empty.py
==============================================================================
--- (empty file)
+++ trunk/plug-ins/python/select_empty.py Sat May 10 10:20:14 2008
@@ -0,0 +1,30 @@
+# Select empyt objects
+# Copyright (c) 2008, Hans Breuer <hans breuer org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import dia
+
+def select_empty_cb (data, flags) :
+ diagram = dia.active_display().diagram
+ objs = data.active_layer.objects
+ for o in objs :
+ if o.bounding_box.right == o.bounding_box.left \
+ or o.bounding_box.top == o.bounding_box.bottom :
+ diagram.select (o)
+
+dia.register_action ("SelectEmpty", "Empty",
+ "/DisplayMenu/Select/By/SelectByExtensionStart",
+ select_empty_cb)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]