?? listing.html
字號:
{ gint x, y, w, h; if ( gnome_parse_geometry( geometry, &x, &y, &w, &h ) ) { if (x != -1) { gtk_widget_set_uposition(app, x, y); } if (w != -1) { gtk_window_set_default_size(GTK_WINDOW(app), w, h); } } else { g_error(_("Could not parse geometry string `%s'"), geometry); } } if (greet != NULL) { GtkWidget* dialog; gchar* greetings = g_strdup(_("Special Greetings to:\n")); GSList* tmp = greet; while (tmp != NULL) { gchar* old = greetings; greetings = g_strconcat(old, (gchar*) tmp->data, "\n", NULL); g_free(old); tmp = g_slist_next(tmp); } dialog = gnome_ok_dialog(greetings); g_free(greetings); gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app)); } app_list = g_slist_prepend(app_list, app); return app;}void hello_app_close(GtkWidget* app){ g_return_if_fail(GNOME_IS_APP(app)); app_list = g_slist_remove(app_list, app); gtk_widget_destroy(app); if (app_list == NULL) { /* No windows remaining */ gtk_main_quit(); }}static gint delete_event_cb(GtkWidget* window, GdkEventAny* e, gpointer data){ hello_app_close(window); /* Prevent the window's destruction, since we destroyed it * ourselves with hello_app_close() */ return TRUE;}static void button_click_cb(GtkWidget* w, gpointer data){ GtkWidget* label; gchar* text; gchar* tmp; label = GTK_WIDGET(data); gtk_label_get(GTK_LABEL(label), &text); tmp = g_strdup(text); g_strreverse(tmp); gtk_label_set_text(GTK_LABEL(label), tmp); g_free(tmp);} </pre> </td> </tr> </table> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z873"><tt class="FILENAME">menus.h</tt></a> </h2> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> #ifndef GNOMEHELLO_MENUS_H#define GNOMEHELLO_MENUS_H#include <gnome.h>void hello_install_menus_and_toolbar(GtkWidget* app); #endif </pre> </td> </tr> </table> </div> <div class="SECT2"> <h2 class="SECT2"> <a name="Z874"><tt class="FILENAME">menus.c</tt></a> </h2> <table border="0" bgcolor="#E0E0E0" width="100%"> <tr> <td><pre class="PROGRAMLISTING"> #include <config.h>#include "menus.h"#include "app.h"static void nothing_cb(GtkWidget* widget, gpointer data);static void new_app_cb(GtkWidget* widget, gpointer data);static void close_cb (GtkWidget* widget, gpointer data);static void exit_cb (GtkWidget* widget, gpointer data);static void about_cb (GtkWidget* widget, gpointer data);static GnomeUIInfo file_menu [] = { GNOMEUIINFO_MENU_NEW_ITEM(N_("_New Hello"), N_("Create a new hello"), new_app_cb, NULL), GNOMEUIINFO_MENU_OPEN_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_SAVE_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_SAVE_AS_ITEM(nothing_cb, NULL), GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_MENU_CLOSE_ITEM(close_cb, NULL), GNOMEUIINFO_MENU_EXIT_ITEM(exit_cb, NULL), GNOMEUIINFO_END};static GnomeUIInfo edit_menu [] = { GNOMEUIINFO_MENU_CUT_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_COPY_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_PASTE_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_SELECT_ALL_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_CLEAR_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_UNDO_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_REDO_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_FIND_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_FIND_AGAIN_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_REPLACE_ITEM(nothing_cb, NULL), GNOMEUIINFO_MENU_PROPERTIES_ITEM(nothing_cb, NULL), GNOMEUIINFO_END};static GnomeUIInfo help_menu [] = { GNOMEUIINFO_HELP ("gnome-hello"), GNOMEUIINFO_MENU_ABOUT_ITEM(about_cb, NULL), GNOMEUIINFO_END};static GnomeUIInfo menu [] = { GNOMEUIINFO_MENU_FILE_TREE(file_menu), GNOMEUIINFO_MENU_EDIT_TREE(edit_menu), GNOMEUIINFO_MENU_HELP_TREE(help_menu), GNOMEUIINFO_END};static GnomeUIInfo toolbar [] = { GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new hello"), nothing_cb, GNOME_STOCK_PIXMAP_NEW), GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Previous hello"), nothing_cb, GNOME_STOCK_PIXMAP_BACK), GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Next hello"), nothing_cb, GNOME_STOCK_PIXMAP_FORWARD), GNOMEUIINFO_END};void hello_install_menus_and_toolbar(GtkWidget* app){ gnome_app_create_toolbar_with_data(GNOME_APP(app), toolbar, app); gnome_app_create_menus_with_data(GNOME_APP(app), menu, app); gnome_app_install_menu_hints(GNOME_APP(app), menu);}static void nothing_cb(GtkWidget* widget, gpointer data){ GtkWidget* dialog; GtkWidget* app; app = (GtkWidget*) data; dialog = gnome_ok_dialog_parented( _("This does nothing; it is only a demonstration."), GTK_WINDOW(app));}static void new_app_cb(GtkWidget* widget, gpointer data){ GtkWidget* app; app = hello_app_new(_("Hello, World!"), NULL, NULL); gtk_widget_show_all(app);}static void close_cb(GtkWidget* widget, gpointer data){ GtkWidget* app; app = (GtkWidget*) data; hello_app_close(app);}static void exit_cb(GtkWidget* widget, gpointer data){ gtk_main_quit();}static void about_cb(GtkWidget* widget, gpointer data){ static GtkWidget* dialog = NULL; GtkWidget* app; app = (GtkWidget*) data; if (dialog != NULL) { g_assert(GTK_WIDGET_REALIZED(dialog)); gdk_window_show(dialog->window); gdk_window_raise(dialog->window); } else { const gchar *authors[] = { "Havoc Pennington <hp@pobox.com>", NULL }; gchar* logo = gnome_pixmap_file("gnome-hello-logo.png"); dialog = gnome_about_new (_("GnomeHello"), VERSION, "(C) 1999 Havoc Pennington", authors, _("A sample GNOME application."), logo); g_free(logo); gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); gnome_dialog_set_parent(GNOME_DIALOG(dialog), GTK_WINDOW(app)); gtk_widget_show(dialog); }} </pre> </td> </tr> </table> </div> </div> </div> <div class="NAVFOOTER"> <br> <br> <table width="100%" border="0" bgcolor="#ffffff" cellpadding= "1" cellspacing="0"> <tr> <td width="25%" bgcolor="#ffffff" align="left"> <a href="z866.html"><font color="#0000ff" size="2"><b> <<< Previous</b></font></a> </td> <td width="25%" colspan="2" bgcolor="#ffffff" align= "center"> <font color="#0000ff" size="2"><b><a href="ggad.html"> <font color="#0000ff" size="2"><b> Home</b></font></a></b></font> </td> <td width="25%" bgcolor="#ffffff" align="right"> <a href="z875.html"><font color="#0000ff" size="2"><b> Next >>></b></font></a> </td> </tr> <tr> <td colspan="2" align="left"> <font color="#000000" size="2"><b>This Book</b></font> </td> <td colspan="2" align="right"> <font color="#000000" size="2"><b>The <tt class= "CLASSNAME">GtkEv</tt> Widget</b></font> </td> </tr> </table> </div> </body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -