Common/Shared properties for grouped and selected objects on a diagram
From: Philip Van Hoof <spamfrommailing freax org>
To: dia-list gnome org
Subject: Common/Shared properties for grouped and selected objects on a diagram
Date: Sun, 09 Jan 2005 15:27:10 +0100
Hi there.
I actually got frustrated by the fact that both for grouped and selected
objects on a diagram, you cannot set their shared set or properties
using one action (you basically have to select each of them individually
to set all their properties individually).
Using this one in properties.c and a call to it in commands.c I am
trying to hack together the possibility to select multiple objects and
set their common properties using one single object-properties box.
I have noticed that grouped object-properties aren't working either.
When you group objects together, you can't set the individual
object-properties anymore.
I sense a common feature of which code can be shared by both selected
and grouped such objects.
The merging of possible options is now being done using
prop_desc_lists_intersection which i discovered while browsing the
sources of dia.
So if object a has properties 1 2 and 3 and object b has properties 3, 2
and 4 it should only show 2 and 3 since those that are shared by both
objects. And not 1 and 4 for those aren't shared. So indeed, the
intersection of the properties.
If this is a bad idea or if I am going into a totally wrong direction
here, please correct me.
#include "propinternals.h"
// yes I know this is probably a private of the library "lib".
// mind however that dia's source isn't always using the best
// codestyle known to mankind. I really dislike the usage of global
// variables in many .c files. For me, as somebody who isn't a
// core developer, it's very VERY hard to follow many paths the
// code is following cause of this. A function can manipulate
// a million things that aren't defined in the function. Many
// functions set global GUI widgets that may affect stuff thats
// totally not related to the function by itself.
// And stuff like this: create_dialog ()
// and now suddenly the global pointer dialog is set.
// Why not : GtkWidget *dialog = create_a_new_dialog (); ?
// oh well...
extern gboolean pdtpp_is_visible_no_standard(const PropDescription
*pdesc);
void
properties_of_selected_show (Diagram *dia, GList *selected)
{
if (selected)
{
GtkWidget *dialog = gtk_dialog_new ();
PropDialog *pdialog = prop_dialog_new (selected->data, FALSE);
GList *have = NULL;
PropDescription *pdesc = NULL;
have = g_list_append (have, object_get_prop_descriptions
(selected->data));
while (selected)
{
DiaObject *obj = selected->data;
if (object_complies_with_stdprop (obj))
{
guint i;
GPtrArray *props = NULL;
have = g_list_append (have,
object_get_prop_descriptions (obj));
pdesc = prop_desc_lists_intersection (have);
props = prop_list_from_descs(pdesc,
pdtpp_is_visible_no_standard);
obj->ops->get_props(obj,props);
for (i = 0; i < props->len; i++) {
Property *prop =
(Property*)g_ptr_array_index(props,i);
prop_dialog_add_property(pdialog, prop);
}
}
selected = g_list_next (selected);
}
gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG
(dialog)->vbox), pdialog->widget);
gtk_widget_show_all (pdialog->widget);
gtk_dialog_run (dialog);
}
}
--
Philip Van Hoof, Software Developer @ Cronos
home: me at freax dot org
gnome: pvanhoof at gnome dot org
work: philip dot vanhoof at cronos dot be
junk: philip dot vanhoof at gmail dot com
http://www.freax.be, http://www.freax.eu.org