RE: Question about the default title of a GTK window
- From: easyfan <zheng easyfan gmail com>
- To: gtk-devel-list gnome org
- Subject: RE: Question about the default title of a GTK window
- Date: Wed, 21 Oct 2009 18:26:52 -0700 (PDT)
Well, I gonna love you, you just give a light!
Thanks a lot!
sbaka wrote:
>
>
>> Hey pals, I am a new comer on GTK things.
>> I have some questions about it, would any one have time taking me over
>> it?
>> Here is it:
>> 1, What is the default title of a GTK window? I mean, if there is no
>> string
>> was assigned to title of a GTK window, what will be exposed in the title
>> bar
>> of said window?
>
> I got curious so I looked. All three implementation Win32, X11, and my
> favorite Quartz (Next Step, just cause that's what I'm working on now)
> implements gdk_window_new based on the underlying platform and are
> somewhat different. From what I can gather this is the part that gets the
> title and use the implementation specific library functions to set the
> actual title, with the text coming from this tidbit of code based on glib:
>
> in gdk_window_new_internal(){
>
> ....(implementation specific code)....
>
> if (attributes_mask & GDK_WA_TITLE)
> title = attributes->title;
> else
> title = get_default_title ();
>
> ....(implementation specific code)......
>
>
> }
>
> with the function get_default_title defined as:
>
> static const gchar *
> get_default_title (void)
> {
> const char *title;
> title = g_get_application_name ();
> if (!title)
> title = g_get_prgname ();
>
> return title;
> }
>
> in all implementation, thus the answer being, the executable name.
>
>> 2, Whether there is another interface for developers on setting title on
>> GTK
>> window except gtk_window_set_title?
>
> I suppose you could use g_set_prgname() look at
> http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Utility-Functions.html
>
>> 3, More specifications, will GTK framework take application name from
>> anywhere and set it as title into any untitled window in the application?
>> That all. Thanks alot.
>
> Take application name from anywhere? Huh? I can't say the function below
> is straight forward, I can only imaging its convolution is do the WIN32,
> but from what I can gather g_prgname is a global variable within the file,
> and as as mentioned initialized in gdk_init. Actually it comes from
> g_option_context_parse() in goption.c.
> Basically the function (very compiler depended) finds the program name and
> sets it, which intern becomes your very changeable window title.
>
> **
> * g_get_prgname:
> *
> * Gets the name of the program. This name should <emphasis>not</emphasis>
> * be localized, contrast with g_get_application_name().
> * (If you are using GDK or GTK+ the program name is set in gdk_init(),
> * which is called by gtk_init(). The program name is found by taking
> * the last component of <literal>argv[0]</literal>.)
> *
> * Returns: the name of the program. The returned string belongs
> * to GLib and must not be modified or freed.
> */
> gchar*
> g_get_prgname (void)
> {
> gchar* retval;
>
> G_LOCK (g_prgname);
> #ifdef G_OS_WIN32
> if (g_prgname == NULL)
> {
> static gboolean beenhere = FALSE;
>
> if (!beenhere)
> {
> gchar *utf8_buf = NULL;
> wchar_t buf[MAX_PATH+1];
>
> beenhere = TRUE;
> if (GetModuleFileNameW (GetModuleHandle (NULL),
> buf, G_N_ELEMENTS (buf)) > 0)
> utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
>
> if (utf8_buf)
> {
> g_prgname = g_path_get_basename (utf8_buf);
> g_free (utf8_buf);
> }
> }
> }
> #endif
> retval = g_prgname;
> G_UNLOCK (g_prgname);
>
> return retval;
> }
>
>
> I hope this answers your question. It sure helped me to answer it :)
>
>
>
> EMAILING FOR THE GREATER GOOD
> Join me
>
>> Date: Mon, 19 Oct 2009 08:30:56 -0700
>> From: zheng easyfan gmail com
>> To: gtk-devel-list gnome org
>> Subject: Question about the default title of a GTK window
>>
>>
>> Hey pals, I am a new comer on GTK things.
>> I have some questions about it, would any one have time taking me over
>> it?
>> Here is it:
>> 1, What is the default title of a GTK window? I mean, if there is no
>> string
>> was assigned to title of a GTK window, what will be exposed in the title
>> bar
>> of said window?
>> 2, Whether there is another interface for developers on setting title on
>> GTK
>> window except gtk_window_set_title?
>> 3, More specifications, will GTK framework take application name from
>> anywhere and set it as title into any untitled window in the application?
>> That all. Thanks alot.
>> --
>> View this message in context:
>> http://www.nabble.com/Question-about-the-default-title-of-a-GTK-window-tp25960347p25960347.html
>> Sent from the Gtk+ - Dev - General mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> gtk-devel-list mailing list
>> gtk-devel-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
>
--
View this message in context: http://www.nabble.com/Question-about-the-default-title-of-a-GTK-window-tp25960347p26002733.html
Sent from the Gtk+ - Dev - General mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]