Login


 
Newsletter
Werbung

Mo, 22. November 1999, 00:00

GNOME-Workshop: Die Menüleiste

Eine einfache Menüleiste

/* 001 */ #include <gnome.h>
/* 002 */
/* 003 */ GtkWidget *fenster;
/* 004 */ GtkWidget *feld;
/* 005 */
/* 006 */ void quit_prgm(GtkWidget *widget, gpointer data)
/* 007 */ {
/* 008 */ gtk_main_quit();
/* 009 */ }
/* 010 */
/* 011 */ void about(GtkWidget *widget, gpointer data)
/* 012 */ {}
/* 013 */
/* 014 */ GnomeUIInfo filemenu&#91;&#93; = {
/* 015 */ GNOMEUIINFO_SEPARATOR,
/* 016 */ GNOMEUIINFO_MENU_EXIT_ITEM(quit_prgm, NULL),
/* 017 */ GNOMEUIINFO_END
/* 018 */ };
/* 019 */
/* 020 */ GnomeUIInfo helpmenu&#91;&#93; = {
/* 021 */ GNOMEUIINFO_MENU_ABOUT_ITEM(about, NULL),
/* 022 */ GNOMEUIINFO_END
/* 023 */ };
/* 024 */
/* 025 */ GnomeUIInfo mainmenu&#91;&#93; = {
/* 026 */ GNOMEUIINFO_MENU_FILE_TREE(filemenu),
/* 027 */ GNOMEUIINFO_MENU_HELP_TREE(helpmenu),
/* 028 */ GNOMEUIINFO_END
/* 029 */ };
/* 030 */
/* 031 */ int main (int argc, char *argv&#91;&#93;)
/* 032 */ {
/* 033 */ GnomeAppBar *appbar;
/* 034 */
/* 035 */ gnome_init_with_popt_table("", NULL, argc, argv, NULL, 0, NULL);
/* 036 */ fenster = gnome_app_new("", _("Hello World!"));
/* 037 */ gnome_app_create_menus(GNOME_APP(fenster), mainmenu);
/* 038 */ appbar = GNOME_APPBAR (gnome_appbar_new(FALSE, FALSE, FALSE));
/* 039 */ gnome_app_set_statusbar(GNOME_APP (fenster), GTK_WIDGET (appbar));
/* 040 */ gtk_signal_connect(GTK_OBJECT(fenster), "delete_event",
/* 041 */ GTK_SIGNAL_FUNC(quit_prgm), NULL);
/* 042 */ gtk_window_set_policy(GTK_WINDOW(fenster), TRUE, TRUE, FALSE);
/* 043 */ feld = gtk_drawing_area_new();
/* 044 */ gnome_app_set_contents(GNOME_APP(fenster), feld);
/* 045 */ gtk_drawing_area_size(GTK_DRAWING_AREA(feld), 400, 300);
/* 046 */ gtk_widget_show(fenster);
/* 047 */ gtk_main();
/* 048 */ return 0;
/* 049 */ }
Befehlszeile deutscher Text
GNOMEUIINFO_END { oblig. Schluß }
GNOMEUIINFO_SEPARATOR { Trennlinie }
GNOMEUIINFO_MENU_FILE_TREE(mymenu) Datei
GNOMEUIINFO_MENU_SETTINGS_TREE(mymenu) Einstellungen
GNOMEUIINFO_MENU_HELP_TREE(mymenu) Hilfe
GNOMEUIINFO_MENU_GAME_TREE(mymenu) Spiel
GNOMEUIINFO_MENU_SELECT_ALL_ITEM(mymenu,NULL) Alle auswählen
GNOMEUIINFO_MENU_CUT_ITEM(mymenu,NULL) _Ausschneiden
GNOMEUIINFO_MENU_EXIT_ITEM(mymenu, NULL) _Beenden
GNOMEUIINFO_MENU_PRINT_ITEM(mymenu,NULL) _Drucken
GNOMEUIINFO_MENU_PASTE_ITEM(mymenu,NULL) E_infügen
GNOMEUIINFO_MENU_PREFERENCES_ITEM(mymenu, NULL) Einstellungen...
GNOMEUIINFO_MENU_REPLACE_ITEM(mymenu,NULL) E_rsetzen...
GNOMEUIINFO_MENU_HINT_ITEM(mymenu, NULL) _Hinweis
GNOMEUIINFO_MENU_ABOUT_ITEM(mymenu, NULL) _Info...
GNOMEUIINFO_MENU_COPY_ITEM(mymenu,NULL) _Kopieren
GNOMEUIINFO_MENU_NEW_GAME_ITEM(mymenu, NULL) _Neues Spiel
GNOMEUIINFO_MENU_SCORES_ITEM(mymenu, NULL) Rangliste
GNOMEUIINFO_MENU_UNDO_ITEM(mymenu,NULL) _Rückgängig
GNOMEUIINFO_MENU_CLOSE_ITEM(mymenu,NULL) S_chließen
GNOMEUIINFO_MENU_SAVE_ITEM(mymenu, NULL) _Speichern
GNOMEUIINFO_MENU_SAVE_AS_ITEM(mymenu, NULL) Speichern _unter...
GNOMEUIINFO_MENU_RESTART_GAME_ITEM(mymenu, NULL) Spiel neu starten
GNOMEUIINFO_MENU_FIND_ITEM(mymenu,NULL) _Suchen...
GNOMEUIINFO_MENU_FIND_AGAIN_ITEM(mymenu,NULL) Weitersuchen
GNOMEUIINFO_MENU_REDO_ITEM(mymenu,NULL) _Wiederherstellen
GNOMEUIINFO_MENU_REDO_MOVE_ITEM(mymenu, NULL) Zug wiederherstellen
GNOMEUIINFO_MENU_UNDO_MOVE_ITEM(mymenu, NULL) Zug zurücknehemen

Eine geSTOCKte Menüleiste

#include <gnome.h>
GtkWidget *fenster;
GtkWidget *feld;
void quit_prgm(GtkWidget *widget, gpointer data)
{
 gtk_main_quit();
}
void about(GtkWidget *widget, gpointer data)
{}
GnomeUIInfo filemenu&#91;&#93; = {
 GNOMEUIINFO_SEPARATOR,
 GNOMEUIINFO_ITEM_STOCK(N_("_Beenden"), N_("beendet Programm"),
 quit_prgm, GNOME_STOCK_PIXMAP_REDO),
 GNOMEUIINFO_END
};
GnomeUIInfo helpmenu&#91;&#93; = {
 GNOMEUIINFO_ITEM_STOCK(N_("_Info..."), N_("Info"),
 about, GNOME_STOCK_PIXMAP_REDO),
 GNOMEUIINFO_END
};
GnomeUIInfo mainmenu&#91;&#93; = {
 GNOMEUIINFO_MENU_FILE_TREE(filemenu),
 GNOMEUIINFO_MENU_HELP_TREE(helpmenu),
 GNOMEUIINFO_END
};
int main (int argc, char *argv&#91;&#93;)
{
 GnomeAppBar *appbar;
 gnome_init_with_popt_table("", NULL, argc, argv, NULL, 0, NULL);
 fenster = gnome_app_new("", _("Hello World!"));
 gnome_app_create_menus(GNOME_APP(fenster), mainmenu);
 appbar = GNOME_APPBAR (gnome_appbar_new(FALSE, FALSE, FALSE));
 gnome_app_set_statusbar(GNOME_APP (fenster), GTK_WIDGET (appbar));
 gtk_signal_connect(GTK_OBJECT(fenster), "delete_event",
 GTK_SIGNAL_FUNC(quit_prgm), NULL);
 gtk_window_set_policy(GTK_WINDOW(fenster), TRUE, TRUE, FALSE);
 feld = gtk_drawing_area_new();
 gnome_app_set_contents(GNOME_APP(fenster), feld);
 gtk_drawing_area_size(GTK_DRAWING_AREA(feld), 400, 300);
 gtk_widget_show(fenster);
 gtk_main();
 return 0;
}

Für den besonderen Fall

#include <gnome.h>
GtkWidget *fenster;
GtkWidget *feld;
void quit_prgm(GtkWidget *widget, gpointer data)
{
 gtk_main_quit();
}
void about(GtkWidget *widget, gpointer data)
{}
GnomeUIInfo filemenu&#91;&#93; = {
 GNOMEUIINFO_SEPARATOR,
 {
 GNOME_APP_UI_ITEM,
 N_("Beende Programm"), N_("beendet Programm"),
 quit_prgm, NULL, NULL,
 GNOME_APP_PIXMAP_NONE, NULL,
 0, GDK_CONTROL_MASK, NULL
 },
 GNOMEUIINFO_END
};
GnomeUIInfo helpmenu&#91;&#93; = {
 {
 GNOME_APP_UI_ITEM,
 N_("mein About"), N_("über"),
 about, NULL, NULL,
 GNOME_APP_PIXMAP_NONE, NULL,
 0, GDK_CONTROL_MASK, NULL
 },
 GNOMEUIINFO_END
};
GnomeUIInfo mainmenu&#91;&#93; = {
 GNOMEUIINFO_MENU_FILE_TREE(filemenu),
 GNOMEUIINFO_MENU_HELP_TREE(helpmenu),
 GNOMEUIINFO_END
};
int main (int argc, char *argv&#91;&#93;)
{
 GnomeAppBar *appbar;
 gnome_init_with_popt_table("", NULL, argc, argv, NULL, 0, NULL);
 fenster = gnome_app_new("", _("Hello World!"));
 gnome_app_create_menus(GNOME_APP(fenster), mainmenu);
 appbar = GNOME_APPBAR (gnome_appbar_new(FALSE, FALSE, FALSE));
 gnome_app_set_statusbar(GNOME_APP (fenster), GTK_WIDGET (appbar));
 gtk_signal_connect(GTK_OBJECT(fenster), "delete_event",
 GTK_SIGNAL_FUNC(quit_prgm), NULL);
 gtk_window_set_policy(GTK_WINDOW(fenster), TRUE, TRUE, FALSE);
 feld = gtk_drawing_area_new();
 gnome_app_set_contents(GNOME_APP(fenster), feld);
 gtk_drawing_area_size(GTK_DRAWING_AREA(feld), 400, 300);
 gtk_widget_show(fenster);
 gtk_main();
 return 0;
}
Kommentare (Insgesamt: 0 || Kommentieren )
Pro-Linux
Pro-Linux @Facebook
Neue Nachrichten
Werbung