个人工具

“UbuntuHelp:UMEGuide/ApplicationDevelopment/OverviewOfHildonAndGtk”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/UMEGuide/ApplicationDevelopment/OverviewOfHildonAndGtk}} {{Languages|UbuntuHelp:UMEGuide/ApplicationDevelopment/OverviewOfHildonAndGtk}} == OVERVI...)
 
 
(未显示同一用户的1个中间版本)
第2行: 第2行:
 
{{Languages|UbuntuHelp:UMEGuide/ApplicationDevelopment/OverviewOfHildonAndGtk}}
 
{{Languages|UbuntuHelp:UMEGuide/ApplicationDevelopment/OverviewOfHildonAndGtk}}
 
== OVERVIEW OF Hildon and GTK ==
 
== OVERVIEW OF Hildon and GTK ==
 
 
A <code><nowiki>HildonProgram</nowiki></code> is a GObject representing the whole application. In this context it is important to note that a <code><nowiki>HildonProgram</nowiki></code> *is not* a <code><nowiki>GtkWidget</nowiki></code>.
 
A <code><nowiki>HildonProgram</nowiki></code> is a GObject representing the whole application. In this context it is important to note that a <code><nowiki>HildonProgram</nowiki></code> *is not* a <code><nowiki>GtkWidget</nowiki></code>.
 
Only one <code><nowiki>HildonProgram</nowiki></code> can be created per process. It is accessed with <code><nowiki>hildon_program_get_instance</nowiki></code>.
 
Only one <code><nowiki>HildonProgram</nowiki></code> can be created per process. It is accessed with <code><nowiki>hildon_program_get_instance</nowiki></code>.
 
 
<code><nowiki>HildonWindows</nowiki></code> are registered to the <code><nowiki>HildonProgram</nowiki></code> using <code><nowiki>hildon_program_add_window()</nowiki></code> As the method name suggests, several <code><nowiki>HildonWindows</nowiki></code> are likely to be registered to a <code><nowiki>HildonProgram</nowiki></code>.  
 
<code><nowiki>HildonWindows</nowiki></code> are registered to the <code><nowiki>HildonProgram</nowiki></code> using <code><nowiki>hildon_program_add_window()</nowiki></code> As the method name suggests, several <code><nowiki>HildonWindows</nowiki></code> are likely to be registered to a <code><nowiki>HildonProgram</nowiki></code>.  
 
 
An example 'OVERVIEW OF A PROGRAM' looks like:
 
An example 'OVERVIEW OF A PROGRAM' looks like:
 
+
<pre><nowiki>
<pre><nowiki>/* Create needed variables */
+
/* Create needed variables */
 
HildonProgram *program;
 
HildonProgram *program;
 
HildonWindow *window;
 
HildonWindow *window;
第17行: 第14行:
 
/* Create the hildon program and setup the title */
 
/* Create the hildon program and setup the title */
 
program = HILDON_PROGRAM (hildon_program_get_instance());</nowiki></pre>
 
program = HILDON_PROGRAM (hildon_program_get_instance());</nowiki></pre>
 
 
=== MENU'S ===
 
=== MENU'S ===
 
 
Menu's are created externally using <code><nowiki>GtkMenu</nowiki></code>. They are then added to a <code><nowiki>HildonWindow</nowiki></code> with <code><nowiki>hildon_window_set_menu()</nowiki></code>
 
Menu's are created externally using <code><nowiki>GtkMenu</nowiki></code>. They are then added to a <code><nowiki>HildonWindow</nowiki></code> with <code><nowiki>hildon_window_set_menu()</nowiki></code>
 
An example of this looks like:
 
An example of this looks like:
 
+
<pre><nowiki>
<pre><nowiki>GtkMenu *menu;
+
GtkMenu *menu;
 
menu = gtk_menu_new ();
 
menu = gtk_menu_new ();
 
fill_in_menu (menu);
 
fill_in_menu (menu);
 
hildon_window_set_menu (menu);</nowiki></pre>
 
hildon_window_set_menu (menu);</nowiki></pre>
 
 
=== TOOLBARS ===
 
=== TOOLBARS ===
 
 
These are created using a call to <code><nowiki>hildon_window_add_toolbar()</nowiki></code>
 
These are created using a call to <code><nowiki>hildon_window_add_toolbar()</nowiki></code>
 
An example of this looks like:
 
An example of this looks like:
 
+
<pre><nowiki>
<pre><nowiki>GtkToolbar *toolbar;
+
GtkToolbar *toolbar;
 
toolbar = create_toolbar ();
 
toolbar = create_toolbar ();
 
/* Add toolbar to the HildonWindow */
 
/* Add toolbar to the HildonWindow */
 
hildon_window_add_toolbar (window, toolbar);</nowiki></pre>
 
hildon_window_add_toolbar (window, toolbar);</nowiki></pre>
 
 
=== HIBERNATION ===
 
=== HIBERNATION ===
 
A programmer can tell the Hildon Task Navigator whether or not an application is ready to be set to hibernation (background-killed) by
 
A programmer can tell the Hildon Task Navigator whether or not an application is ready to be set to hibernation (background-killed) by
 
calling <code><nowiki>set_can_hibernate()</nowiki></code>
 
calling <code><nowiki>set_can_hibernate()</nowiki></code>
 
 
=== WINDOW SPECIFIC SETTINGS ===
 
=== WINDOW SPECIFIC SETTINGS ===
 
Window-specific commands can be sent  to the window manager and task navigator.
 
Window-specific commands can be sent  to the window manager and task navigator.
第47行: 第38行:
 
in the task navigator.
 
in the task navigator.
 
This is shown by:
 
This is shown by:
 
 
<code><nowiki>gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);</nowiki></code>
 
<code><nowiki>gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE);</nowiki></code>
 
 
Similarly applications are able to change the icon representing each of their <code><nowiki>HildonWindow</nowiki></code> in the task navigator by using the <code><nowiki>gtk_window_set _icon</nowiki></code> set of functions.
 
Similarly applications are able to change the icon representing each of their <code><nowiki>HildonWindow</nowiki></code> in the task navigator by using the <code><nowiki>gtk_window_set _icon</nowiki></code> set of functions.
 
This is shown by:
 
This is shown by:
 
+
<pre><nowiki>
<pre><nowiki>GdkPixbuf *icon = create_icon();
+
GdkPixbuf *icon = create_icon();
 
gtk_window_set_icon (GTK_WINDOW (window), icon);
 
gtk_window_set_icon (GTK_WINDOW (window), icon);
 
+
   
 
Also the title can be set per window with:
 
Also the title can be set per window with:
<code><nowiki>gtk_window_set_title (GTK_WINDOW (window), "Window Title");</nowiki></code>
+
@@code19@@
  
If the application name was set with <code><nowiki>g_set_application name()</nowiki></code>, it will precede the window title in the title bar.
+
If the application name was set with @@code20@@, it will precede the window title in the title bar.
  
=== PROGRAM WIDE SETTINGS ===
+
== PROGRAM WIDE SETTINGS ==
The <code><nowiki>HildonProgram</nowiki></code> object provides the programmer with commodities to set program-wide settings for all the registered HildonWindow's.
+
The @@code21@@ object provides the programmer with commodities to set program-wide settings for all the registered HildonWindow's.
 
The programmer can create a common menu which will be shared (memory and functionality-wise) by all the windows. A window can override this common
 
The programmer can create a common menu which will be shared (memory and functionality-wise) by all the windows. A window can override this common
 
menu by having its own menu.
 
menu by having its own menu.
  
 
This is shown by:
 
This is shown by:
<pre><nowiki>GtkMenu *common_menu = create_common_menu ();
+
{{{
 +
GtkMenu *common_menu = create_common_menu ();
 
GtkMenu *window_specific_menu = create_window_specific_menu ();
 
GtkMenu *window_specific_menu = create_window_specific_menu ();
 
+
               
 
hildon_program_set_common_menu (program, common_menu);
 
hildon_program_set_common_menu (program, common_menu);
 
hildon_window_set_menu (second_window, window_specific_menu);</nowiki></pre>
 
hildon_window_set_menu (second_window, window_specific_menu);</nowiki></pre>
 
 
Also, a common toolbar can be shared among all HildonWindow's. Windows can add window specific toolbars. The common toolbar will be displayed
 
Also, a common toolbar can be shared among all HildonWindow's. Windows can add window specific toolbars. The common toolbar will be displayed
 
on the bottom of the stack of toolbars.
 
on the bottom of the stack of toolbars.
 
 
This is shown by:
 
This is shown by:
<pre><nowiki>GtkToolbar *common_toolbar = create_common_toolbar ();
+
<pre><nowiki>
 +
GtkToolbar *common_toolbar = create_common_toolbar ();
 
GtkToolbar *window_specific_toolbar = create_window_specific_toolbar ();
 
GtkToolbar *window_specific_toolbar = create_window_specific_toolbar ();
 
hildon_program_set_common_toolbar (program, common_toolbar);
 
hildon_program_set_common_toolbar (program, common_toolbar);
 
hildon_window_add_toolbar (second_window, window_specific_toolbar);</nowiki></pre>
 
hildon_window_add_toolbar (second_window, window_specific_toolbar);</nowiki></pre>
 
 
 
 
 
 
 
.
 
.
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2009年5月15日 (五) 08:40的最新版本

OVERVIEW OF Hildon and GTK

A HildonProgram is a GObject representing the whole application. In this context it is important to note that a HildonProgram *is not* a GtkWidget. Only one HildonProgram can be created per process. It is accessed with hildon_program_get_instance. HildonWindows are registered to the HildonProgram using hildon_program_add_window() As the method name suggests, several HildonWindows are likely to be registered to a HildonProgram. An example 'OVERVIEW OF A PROGRAM' looks like:

/* Create needed variables */
HildonProgram *program;
HildonWindow *window;
/* Initialize GTK. */
gtk_init (&argc, &argv);
/* Create the hildon program and setup the title */
program = HILDON_PROGRAM (hildon_program_get_instance());

MENU'S

Menu's are created externally using GtkMenu. They are then added to a HildonWindow with hildon_window_set_menu() An example of this looks like:

GtkMenu *menu;
menu = gtk_menu_new ();
fill_in_menu (menu);
hildon_window_set_menu (menu);

TOOLBARS

These are created using a call to hildon_window_add_toolbar() An example of this looks like:

GtkToolbar *toolbar;
toolbar = create_toolbar ();
/* Add toolbar to the HildonWindow */
hildon_window_add_toolbar (window, toolbar);

HIBERNATION

A programmer can tell the Hildon Task Navigator whether or not an application is ready to be set to hibernation (background-killed) by calling set_can_hibernate()

WINDOW SPECIFIC SETTINGS

Window-specific commands can be sent to the window manager and task navigator. Applications can tell the task navigator that some window requires the user’s attention. This will trigger the blinking of the window’s icon in the task navigator. This is shown by: gtk_window_set_urgency_hint (GTK_WINDOW (window), TRUE); Similarly applications are able to change the icon representing each of their HildonWindow in the task navigator by using the gtk_window_set _icon set of functions. This is shown by:

GdkPixbuf *icon = create_icon();
gtk_window_set_icon (GTK_WINDOW (window), icon);
    
Also the title can be set per window with:
@@code19@@

If the application name was set with @@code20@@, it will precede the window title in the title bar.

== PROGRAM WIDE SETTINGS ==
The @@code21@@ object provides the programmer with commodities to set program-wide settings for all the registered HildonWindow's.
The programmer can create a common menu which will be shared (memory and functionality-wise) by all the windows. A window can override this common
menu by having its own menu.

This is shown by:
{{{
GtkMenu *common_menu = create_common_menu ();
GtkMenu *window_specific_menu = create_window_specific_menu ();
                
hildon_program_set_common_menu (program, common_menu);
hildon_window_set_menu (second_window, window_specific_menu);

Also, a common toolbar can be shared among all HildonWindow's. Windows can add window specific toolbars. The common toolbar will be displayed on the bottom of the stack of toolbars. This is shown by:

GtkToolbar *common_toolbar = create_common_toolbar ();
GtkToolbar *window_specific_toolbar = create_window_specific_toolbar ();
hildon_program_set_common_toolbar (program, common_toolbar);
hildon_window_add_toolbar (second_window, window_specific_toolbar);

.