Some MDI questions



Hi all,

I started rewriting GTop to use the MDI interface a few days ago
(it's in CVS with tag GTOP_MDI_BRANCH), looked at the source code
of gnome-mdi and ghex but still have some questions about it.

First, I start everything with

	mdi = GNOME_MDI (gnome_mdi_new ("gtop", _("GNOME System Monitor")));

	/* set up MDI menus */
	gnome_mdi_set_menu_template (mdi, mainMenu);

	/* and document menu and document list paths */
	gnome_mdi_set_child_menu_path (mdi, _("File"));
	gnome_mdi_set_child_list_path (mdi, _("Pages/"));

	/* set MDI mode */
	gnome_mdi_set_mode(mdi, mdi_mode);

continue with

	window = gnome_app_new (argv0, _("GNOME System Monitor"));
	gtk_widget_set_name (GTK_WIDGET (window), "GTop");
	gtk_window_set_wmclass (GTK_WINDOW (window), "gtop", "gtop");

	gnome_app_create_menus (GNOME_APP(window), mainMenu);

That's the basic setup in main.c.

Now I created a new GtkWidget `GTopPage' which is child of GnomeMDIChild.

Somewhere in gtop-page.c I'm using this code:

	case GTOP_PAGE_FSUSAGE:
		switch ((FsUsageType) subtype) {
		case FSUSAGE_TYPE_TOTAL:
			label = _("Filesystems (total)");
			break;
		case FSUSAGE_TYPE_USED:
			label = _("Filesystems (used)");
			break;
		case FSUSAGE_TYPE_FREE:
			label = _("Filesystems (free)");
			break;
		}
		gnome_mdi_child_set_name
			(GNOME_MDI_CHILD (page), label);

After some search in the gnome-mdi source code I found that this stores
the name of the child in `mdi_child->name'.

First Question:
  How can I set the title of the notebook page to `Filesystems' but the
  menu item to `Filesystems (total)' ?

I continue with this code:

static GtkWidget *
gtop_page_create_view (GnomeMDIChild *child)
{
        GtkWidget *new_view = NULL;

        printf ("gtop_page_create_view (%p) - %d\n", child,
                GTOP_PAGE (child)->type);

        switch (GTOP_PAGE (child)->type) {
        case GTOP_PAGE_FSUSAGE: 
                new_view = gtop_fsusage_new (GTOP_PAGE (child),
                                             GTOP_PAGE (child)->subtype);
                break;
        }

        return new_view;
}

which calls

GtkWidget *
gtop_fsusage_new (GTopPage *owner, gint ftype)
{
        GTopFsUsage *fsusage = gtk_type_new (gtop_fsusage_get_type ());

        fsusage->page = owner;
        fsusage->ftype = (FsUsageType) ftype;

        printf ("gtop_fsusage_new (%p) = %p\n", owner, fsusage);

        addFsUsageView (&fsusage->data, GTK_WIDGET (fsusage), fsusage->ftype)
;

        return GTK_WIDGET (fsusage);
}

and finally (removed some stuff from it):

void *
addFsUsageView (FsUsageData *d, GtkWidget *widget, gint ftype)
{
        GTopFsUsage *fsusage = GTOP_FSUSAGE (widget);

        d->sw = GTK_WIDGET (GTK_SCROLLED_WINDOW (fsusage));
        gtk_widget_set_name (d->sw, "FsUsageGraph");

        d->f = gtk_frame_new (NULL);
        gtk_container_add (GTK_CONTAINER (d->sw), d->f);
}

Now my Question:
  What is the full name of the `d->f' widget in addFsUsageView () above -
  I'd like to set some resources for it in my gtoprc.

Well, to summarize a little bit, I have a GtkWidget of class GTopFsUsage
with a parent of GTopPage with a parent of GnomeMDIChild.

Next Question:
  In the GTopFsUsage widget I need to catch to configure event of the MDI
  notebook page it is in. Well, I need to get a callback every time the
  user attempts to resize the notebook page so that I can recalculate the
  GTopGraph to fit into the new size (make it smaller or bigger).

Thanks for any help,

Martin

-- 
----------------------------------------------------------------
   Martin Baulig - Angewandte Mathematik - Universitaet Trier
   
   baulig@castor.uni-trier.de, http://www.home-of-linux.com/
   Key: 1024-bit key with ID C8178435 created 1997/01/24 
   ID:  67 C1 84 A0 47 F5 11 C5  5F 68 4C 84 99 05 C3 92
   Finger baulig@math38 or fetch mykey.asc from the url above
-----------------------------------------------------------------



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]