Re: RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM RTFM



try gtk-app-devel-list-request gnome org instead......

Bart

On 08 Apr 2001 20:44:08 -0500, schofield wrote:

----- Original Message -----
From: <gtk-app-devel-list-request gnome org>
To: <gtk-app-devel-list gnome org>
Sent: Sunday, April 08, 2001 11:05 AM
Subject: gtk-app-devel-list digest, Vol 1 #411 - 8 msgs


Send gtk-app-devel-list mailing list submissions to
gtk-app-devel-list gnome org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
or, via email, send a message with subject or body 'help' to
gtk-app-devel-list-request gnome org

You can reach the person managing the list at
gtk-app-devel-list-admin gnome org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gtk-app-devel-list digest..."


Today's Topics:

  1. Adding an icon to a program (Fabio Rotondo)
  2. Re: Adding an icon to a program (learfox furry ao net)
  3. Re: Adding an icon to a program (Wolfgang Sourdeau)
  4. Program Structure (frankc srv net)
  5. Re: Program Structure (learfox furry ao net)
  6. Re: Program Structure (frankc srv net)
  7. Re: Program Structure (rob)
  8. Re: Program Structure (learfox furry ao net)

--__--__--

Message: 1
Date: Sat, 07 Apr 2001 20:38:22 +0200
From: Fabio Rotondo <fsoft galactica it>
To: gtk-devel <gtk-app-devel-list gnome org>
Subject: Adding an icon to a program

Hi!,

  I'd like to add a custom icon to a program I am writing, so that when
my program is minimized,
that icon will be shown.
How should I do that?

Thanks.

Ciao,
  Fabio



--__--__--

Message: 2
Date: Sat, 7 Apr 2001 14:38:17 -0700 (PDT)
From: <learfox furry ao net>
Reply-To: <learfox furry ao net>
To: Fabio Rotondo <fsoft galactica it>
Cc: gtk-devel <gtk-app-devel-list gnome org>
Subject: Re: Adding an icon to a program

  I'd like to add a custom icon to a program I am writing, so that when
my program is minimized,
that icon will be shown.
How should I do that?

This is what I use:

void GUISetWMIcon(GdkWindow *w, u_int8_t **icon)
{
        GdkPixmap *pixmap;
        GdkBitmap *mask;
        GtkStyle *style;

        if(w == NULL)
            return;

        style = gtk_widget_get_default_style();
        if(style == NULL)
            return;

        pixmap = gdk_pixmap_create_from_xpm_d(
            w, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)icon
        );

        gdk_window_set_icon(w, NULL, pixmap, mask);
/*      gdk_window_set_icon_name(w, "WMHints Test Icon"); */


        /* Do not unref pixmap and mask. */

        return;
}

A few notes:

The given input icon, needs to be a pointer to XPM format data
either #included or loaded from file at run time.

I didn't set the icon name but it should be settable using
gdk_window_set_icon_name().

The given GdkWindow should be one from your GtkWindow *window's
window->window.

Note that the pixmap is not unref'ed, it will be unrefed when you exit but
if you plan to update the pixmaps for the same window you need to keep a
pointer to it and unref the old one right after you set the new one.

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/



--__--__--

Message: 3
Date: Sat, 07 Apr 2001 17:38:56 -0400
From: Wolfgang Sourdeau <wolfgang contre com>
To: gtk-devel <gtk-app-devel-list gnome org>
Subject: Re: Adding an icon to a program
gtk-devel <gtk-app-devel-list gnome org>

In article <3ACF5E9E 50509 galactica it>, Fabio Rotondo
<fsoft galactica it> writes:

    > Hi!,
    >   I'd like to add a custom icon to a program I am writing, so that
when
    > my program is minimized,
    > that icon will be shown.
    > How should I do that?

gdk_window_set_icon will help you do that.


W.


--__--__--

Message: 4
Date: Sat, 07 Apr 2001 18:02:27 -0600
From: frankc srv net
To: gtk-app-devel-list gnome org
Subject: Program Structure

I am having trouble understanding the structure of programming a GTK+
app. My biggest hangup is how do I modify a widget that is nested in a
window several levels down?  I looked at mapping to it by name or
creating a master structure containing all the widget pointers.  Neither
of these look very practical.  Another method I thought of was creating
a callback that responds to a signal manufactured by another widget.
This last I am not sure how to approach, but I am hoping I can send data
to the widget that responds to the signal.  This problem probably has a
simpler solution.  I am new to programming this way as opposed to a
linear program. I am used to having access to all my data all the time.
I would like to keep my apps object oriented, but I am not understanding
how to make widgets talk to each other easily without destroying the OO
barriers.

Thanks,
Frank



--__--__--

Message: 5
Date: Sat, 7 Apr 2001 22:15:16 -0700 (PDT)
From: <learfox furry ao net>
Reply-To: <learfox furry ao net>
To: <frankc srv net>
Cc: <gtk-app-devel-list gnome org>
Subject: Re: Program Structure

I am having trouble understanding the structure of programming a GTK+
app. My biggest hangup is how do I modify a widget that is nested in a
window several levels down?  I looked at mapping to it by name or
creating a master structure containing all the widget pointers.  Neither
of these look very practical.  Another method I thought of was creating
a callback that responds to a signal manufactured by another widget.
This last I am not sure how to approach, but I am hoping I can send data
to the widget that responds to the signal.  This problem probably has a
simpler solution.  I am new to programming this way as opposed to a
linear program. I am used to having access to all my data all the time.
I would like to keep my apps object oriented, but I am not understanding
how to make widgets talk to each other easily without destroying the OO
barriers.

Yer on the right track from the start. :)  I use structures quite a lot in
big GTK+ apps like Vertex3D and ManEdit.

Typical structure would look like:

typedef struct {

GtkWidget *toplevel; /* The toplevel GtkWindow */
GtkWidget *department_ctree;
GtkWidget *inventory_clist;
GtkWidget *close_button;

GtkCTreeNode *selected_department_item;
int selected_inventory_item;

} my_inventory_struct;

This `window' as a whole, may contain several GTK+ widgets, more than
what's listed in the struct, but they are not important and as such not
recorded.

If yer worried about deallocating memory, then you need not worry
as destroying the toplevel GtkWindow will destroy each subsequent widget.

I would prefer to destroy each item in the two lists before destroying the
toplevel window just to be formal and neat.

If from what yer implying that you have a ton of important widgets, you
may want to make a pointer array index to a list of GtkWidgets that you
created, ie:

GtkWidget **widget_list;
int total_widgets;

This pair indicates all the important widgets, where each pointer points
to a GtkWidget pointer.

Use realloc() to adjust the widget_list and be sure to update
total_widgets appropriatly.

free() the widget_list pointer array (but not each pointer) when yer done.

Hope that helps!

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/



--__--__--

Message: 6
Date: Sun, 08 Apr 2001 00:26:35 -0600
From: frankc srv net
To: learfox furry ao net
Cc: gtk-app-devel-list gnome org
Subject: Re: Program Structure

typedef struct {

        GtkWidget *toplevel;    /* The toplevel GtkWindow */
        GtkWidget *department_ctree;
        GtkWidget *inventory_clist;
        GtkWidget *close_button;

        GtkCTreeNode *selected_department_item;
        int selected_inventory_item;

} my_inventory_struct;

This `window' as a whole, may contain several GTK+ widgets, more than
what's listed in the struct, but they are not important and as such not
recorded.

I was under the impression that this destroys the widget OOP concept.
I was not wanting to make a global variable of any sort, even a structure.
I have gone ahead and passed structures or pointers by callback to each
part in my program:

/* I have to put a widget I will modify */
menu_selection_ callback (ctree_ptr)
{
    create_dialog
}

/* I have to create a structure to pass more  args */
file_selection_ok_button_callback(struct(ctree_ptr, selection_dialog_ptr))
{
    ...
}

(Note: this is not actual code)

This passing of pointers is not too bad, but creating structures just to
pass

information seems a little tedious.  Can the callbacks employ more than
one
generic pointer arg?

I guess I could make one big structure as you said and pass it through
the
chain.
That way I can reduce confusion as to what I am passsing and keep the data
from
being global.  It will have to be static though.

If from what yer implying that you have a ton of important widgets, you

Not really, I just did not understand how to access widgets after I create
my

main window.

Am I making this thing to hard?  Should I just make a bunch of globals?
Are globals really that bad?

Thanks for your reply,
Frank



--__--__--

Message: 7
Date: Sun, 8 Apr 2001 10:09:42 +0100
From: rob <mailingLists pangolin org uk>
To: gtk list <gtk-app-devel-list gnome org>
Subject: Re: Program Structure
Reply-To: mailingLists pangolin org uk

Every instance method needs to be passed a pointer to the instance
(typicaly called 'self' or 'this').

i.e
void add_to_the_label(MyClassInstance *self, gchar *charsToAdd)
{
GtkLabel *theLabel = get_theLabel(self);
gchar *oldText;
gtk_label_get(theLabel, oldText);
gchar *newText = g_strconcat(oldText, charsToAdd, '\0');
gtk_label_set_text(theLabel, newText);
g_free(oldText);
}

the get (and set) methods can delve into the containers and retrive the
widget for you or you can store a pointer to the widget in the instance
data and they just return that.

On Sun, 08 Apr 2001 01:02:27 frankc srv net wrote:
I am having trouble understanding the structure of programming a GTK+
app. My biggest hangup is how do I modify a widget that is nested in a
window several levels down?  I looked at mapping to it by name or
creating a master structure containing all the widget pointers.  Neither
of these look very practical.  Another method I thought of was creating
a callback that responds to a signal manufactured by another widget.
This last I am not sure how to approach, but I am hoping I can send data
to the widget that responds to the signal.  This problem probably has a
simpler solution.  I am new to programming this way as opposed to a
linear program. I am used to having access to all my data all the time.
I would like to keep my apps object oriented, but I am not understanding
how to make widgets talk to each other easily without destroying the OO
barriers.

Thanks,
Frank


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

rob



--__--__--

Message: 8
Date: Sun, 8 Apr 2001 02:47:07 -0700 (PDT)
From: <learfox furry ao net>
Reply-To: <learfox furry ao net>
To: <frankc srv net>
Cc: GTK Application Development List <gtk-app-devel-list gnome org>
Subject: Re: Program Structure

I was under the impression that this destroys the widget OOP concept.
I was not wanting to make a global variable of any sort, even a
structure.
I have gone ahead and passed structures or pointers by callback to each
part in my program:

Well it orients a part of yer program as one object, say one `window'
as one object. Because yer trying to make something *useful* from
something that is OOP, not make an OOP out of something already OOP
(that's often used in wrappers and portability libraries).


/* I have to put a widget I will modify */
menu_selection_ callback (ctree_ptr)
{
    create_dialog
}

/* I have to create a structure to pass more  args */
file_selection_ok_button_callback(struct(ctree_ptr,
selection_dialog_ptr))
{
    ...
}

(Note: this is not actual code)

This passing of pointers is not too bad, but creating structures just to
pass

information seems a little tedious.  Can the callbacks employ more than
one
generic pointer arg?

Oh, I use a global `core structure', ie:

typedef struct {

inventory_struct **inventory_window;
int total_inventory_window;

} core_struct;

This one is allocated in main(), then passed to each widget as the signal
callback data.  There's no global variables involved as this one is
declared locally in main().


I guess I could make one big structure as you said and pass it through
the
chain.
That way I can reduce confusion as to what I am passsing and keep the
data
from
being global.  It will have to be static though.

static can mean a lot of things in C>

But I think I know what yer trying to say, I've been writing GTK+ apps for
two years now using various styles and I've found this to be the most
practical.

Sometimes I would dereferance if the signal handler is for a widget
gauranteed to be within a structure like inventory_window.


Am I making this thing to hard?  Should I just make a bunch of globals?
Are globals really that bad?

Yes they are if you go into C++, best advice is to make one local variable
in main() called the core_struct, and dynamically allocate it.

That struct will hold pointers to all substructures, each substructure
is like a window with a bunch of GtkWidgets in there.






--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/




--__--__--

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


End of gtk-app-devel-list
Digest_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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