/* [ gui_construct ] * Create the GUI */ void gui_construct (void) { GtkWidget *tablabel; GtkWidget *statusview_page; GtkWidget *hitview_page; GtkWidget *policyview_page; gchar hostname[40]; if (!gethostname (hostname, 39)) Fortified.window = gnome_app_new (PACKAGE, g_strconcat ("Fortified ", hostname, NULL)); else Fortified.window = gnome_app_new (PACKAGE, "Fortified"); Fortified.ttips = gtk_tooltips_new (); /* Set up the main window */ g_signal_connect (G_OBJECT (Fortified.window), "delete_event", G_CALLBACK (close_main_window), NULL); gnome_window_icon_set_default_from_file ( "/usr/share/pixmaps/fortified.png"); menus_initialize (Fortified.window); /* The main application is spread out over a set of notebook pages */ notebook = gtk_notebook_new (); gnome_app_set_contents (GNOME_APP (Fortified.window), notebook); /* Set up the statusview page */ statusview_page = create_statusview_page (); tablabel = gtk_label_new (_("Status")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), statusview_page, tablabel); /* Set up the hitview page */ hitview_page = create_hitview_page (); tablabel = gtk_label_new (_("Events")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), hitview_page, tablabel); /* Set up the the policyview pages */ policyview_page = create_policyview_page (); tablabel = gtk_label_new (_("Policy")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), policyview_page, tablabel); g_signal_connect_after (G_OBJECT (notebook), "switch-page", G_CALLBACK (view_switched_cb), NULL); /* FIXME: By making the window non-resizable the expanders collapse properly, but it would be nicer if it worked with a resizable window */ //gtk_window_set_resizable (GTK_WINDOW (Fortified.window), FALSE); /* Show the tray icon */ if (preferences_get_bool (PREFS_ENABLE_TRAY_ICON)) tray_init (); }
/* * Creates a new GtkWidget of class GnomeApp, performing any specialized * initialization needed for the widget to work correctly in this environment. * If a dialog box is used to initialize the widget, return NULL from this * function, and call data->callback with your new widget when it is done. * If the widget needs a special destroy handler, add a signal here. */ static GtkWidget* gb_gnome_app_new (GbWidgetNewData *data) { GtkWidget *new_widget; gchar *project_name; project_name = glade_project_get_name (data->project); new_widget = gnome_app_new (project_name ? project_name : "", project_name); gtk_object_set_data (GTK_OBJECT (new_widget), EnableLayoutConfig, GINT_TO_POINTER (TRUE)); /* Turn off the automatic loading/saving of the configuration, and destroy the BonoboDockLayout, so that when items are added they are added straight away. If we don't do this, items don't get added to the widget tree. */ gnome_app_enable_layout_config (GNOME_APP (new_widget), FALSE); g_object_unref (G_OBJECT (GNOME_APP (new_widget)->layout)); GNOME_APP (new_widget)->layout = NULL; gtk_signal_connect (GTK_OBJECT (new_widget), "delete_event", GTK_SIGNAL_FUNC (editor_close_window), NULL); gb_widget_create_from (GNOME_APP (new_widget)->dock, data->action == GB_CREATING ? "BonoboDock" : NULL); gb_widget_set_child_name (GNOME_APP (new_widget)->dock, GladeChildGnomeAppDock); if (data->action == GB_CREATING) gb_gnome_app_setup_initial_app (new_widget); return new_widget; }
int main (int argc, char *argv[]) { GtkWidget *app; /* We must initialise the Gnome libraries */ gnome_program_init ("gnome1", "0.1", LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_NONE); /* A GnomeApp widget is a child of GtkWindow */ app = gnome_app_new("gnome1", "Menus, menus, menus"); gtk_window_set_default_size ( GTK_WINDOW(app), 300, 200); gtk_signal_connect ( GTK_OBJECT (app), "destroy", GTK_SIGNAL_FUNC ( closeApp), NULL); /* Create the menus and toolbar on the GnomeApp window */ gnome_app_create_menus ( GNOME_APP(app), menubar); gnome_app_create_toolbar ( GNOME_APP(app), submenu); gtk_widget_show(app); gtk_main(); return 0; }
int main(int argc, char *argv[]) { GtkWidget *button; GtkWidget *app; //初始化 gnome_init("Helloworld", "1.0", argc, argv); //建立主窗口 app = gnome_app_new ("hello", "Hello World Gnomified"); //gtk_widget_realize (app); gtk_signal_connect (GTK_OBJECT (app), "delete_event", GTK_SIGNAL_FUNC (quit_cb), NULL); //建立GTK按钮组件 button = gtk_button_new_with_label ("Hello World!"); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (hello_cb), NULL); gtk_container_border_width (GTK_CONTAINER (button), 60); //加入组件 gnome_app_set_contents ( GNOME_APP (app), button); //显示组件 gtk_widget_show (button); gtk_widget_show (app); gtk_main (); return 0; }
void main_window_create(void) { gnome_window_icon_set_default_from_file(PIXMAP_DIR "/" GPHPEDIT_PIXMAP_ICON); main_window.window = gnome_app_new ("gPHPEdit", "gPHPEdit"); preferences_apply(); gnome_app_create_menus (GNOME_APP (main_window.window), menubar1_uiinfo); main_window_create_appbar(); gnome_app_install_menu_hints (GNOME_APP (main_window.window), menubar1_uiinfo); main_window_update_reopen_menu(); plugin_setup_menu(); main_window_create_toolbars(); main_window_create_panes(); main_window_fill_panes(); function_list_prepare(); gtk_signal_connect (GTK_OBJECT (main_window.window), "delete_event", GTK_SIGNAL_FUNC(main_window_delete_event), NULL); gtk_signal_connect (GTK_OBJECT (main_window.window), "destroy", GTK_SIGNAL_FUNC (main_window_destroy_event), NULL); gtk_signal_connect (GTK_OBJECT (main_window.window), "key_press_event", GTK_SIGNAL_FUNC (main_window_key_press_event), NULL); gtk_signal_connect (GTK_OBJECT (main_window.window), "size_allocate", GTK_SIGNAL_FUNC (main_window_resize), NULL); gtk_signal_connect (GTK_OBJECT (main_window.window), "window-state-event", GTK_SIGNAL_FUNC (main_window_state_changed), NULL); main_window.clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_widget_show(main_window.window); update_app_title(); }
/** * Create toolbox component for distributed user interface */ void create_toolbox () { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *wrapbox; GtkWidget *menubar; GtkAccelGroup *accel_group; #ifdef HAVE_GNOME window = gnome_app_new ("Dia", _("Diagram Editor")); #else window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_ref(window); gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION); #endif gtk_window_set_role (GTK_WINDOW (window), "toolbox_window"); gtk_window_set_default_size(GTK_WINDOW(window), 146, 349); app_set_icon (GTK_WINDOW (window)); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (toolbox_delete), window); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (toolbox_destroy), window); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1); #ifdef HAVE_GNOME gnome_app_set_contents(GNOME_APP(window), main_vbox); #else gtk_container_add (GTK_CONTAINER (window), main_vbox); #endif wrapbox = toolbox_create(); gtk_box_pack_end (GTK_BOX (main_vbox), wrapbox, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (wrapbox), "drag_data_received", G_CALLBACK (dia_dnd_file_drag_data_received), NULL); /* userdata == NULL here intentionally */ gtk_widget_show (main_vbox); /* menus -- initialised afterwards, because initing the display menus * uses the tool buttons*/ menus_get_toolbox_menubar(&menubar, &accel_group); gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); #ifdef HAVE_GNOME gnome_app_set_menus(GNOME_APP(window), GTK_MENU_BAR(menubar)); #else # ifdef HAVE_MAC_INTEGRATION _create_mac_integration (); # else gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); # endif #endif persistence_register_window(GTK_WINDOW(window)); toolbox_shell = window; }
GtkWidget *newSample(const gchar *fileName) { Context *context = NEW_ARRAY(Context, 1); gchar *title; GtkWidget *app; GtkWidget *area; GtkStyle *style; int i; context->width = 600; context->height = 400; context->paragraph = pf_factory(fileName, font, guiSupport); title = prettyTitle(fileName); app = gnome_app_new("gnomeLayout", title); gtk_object_set_data(GTK_OBJECT(app), "context", context); gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); gtk_signal_connect(GTK_OBJECT(app), "delete_event", GTK_SIGNAL_FUNC(eventDelete), NULL); area = gtk_drawing_area_new(); gtk_object_set_data(GTK_OBJECT(app), "area", area); style = gtk_style_copy(gtk_widget_get_style(area)); for (i = 0; i < 5; i += 1) { style->fg[i] = style->white; } gtk_widget_set_style(area, style); gnome_app_set_contents(GNOME_APP(app), area); gtk_signal_connect(GTK_OBJECT(area), "expose_event", GTK_SIGNAL_FUNC(eventExpose), context); gtk_signal_connect(GTK_OBJECT(area), "configure_event", GTK_SIGNAL_FUNC(eventConfigure), context); appList = g_slist_prepend(appList, app); g_free(title); return app; }
int main(int argc, char *argv[]) { GtkWidget *app; GnomeAppBar *bar; GtkWidget *frame; //初始化 //setlocale(LC_ALL, ""); gnome_init(PACKAGE, "1.0", argc, argv); bindtextdomain( PACKAGE, "/usr/share/locale"); textdomain( PACKAGE ); //建立主窗口 app = gnome_app_new (PACKAGE, "GNOME Style Programming"); gtk_signal_connect (GTK_OBJECT (app), "delete_event", GTK_SIGNAL_FUNC (quit_cb), NULL); //建立菜单 gnome_app_create_menus (GNOME_APP (app), helper_main_menu); //建立按钮 gnome_app_create_toolbar (GNOME_APP (app), helper_toolbar); //建立状态条 bar = GNOME_APPBAR( gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER)); gnome_app_set_statusbar(GNOME_APP(app), GTK_WIDGET(bar)); //在状态条上显示菜单提示 gnome_app_install_appbar_menu_hints(GNOME_APPBAR(bar), helper_main_menu); //---- 主要工作区域 --------------------------- frame = gtk_frame_new (_("Main Work Area")); gtk_widget_set_usize(frame, 640, 480); gtk_widget_show (frame); //------------------------------- //加入组件 gnome_app_set_contents ( GNOME_APP (app), frame); //显示组件 gtk_widget_show (app); gtk_main (); return 0; }
/** Start program, do stuff, return 0 */ int main(int argc, char **argv) { GtkWidget *w, *notebook, *vbox, *button; signal(SIGCHLD, ignore); at_jobs = get_at_jobs(); cron_jobs = get_cron_jobs(); if (!at_jobs || !cron_jobs) return -1; /* print_jobs(at_jobs, cron_jobs);*/ gnome_init("gat", VERSION, argc, argv); w = gnome_app_new("gat", "GTK Task Scheduler"); gtk_container_border_width(GTK_CONTAINER(w), 8); gtk_signal_connect(GTK_OBJECT(w), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), 0); notebook = gtk_notebook_new(); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), make_at_page(at_jobs), gtk_label_new("One-time jobs")); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), make_cron_page(cron_jobs), gtk_label_new("Recurring jobs")); vbox = gtk_vbox_new(FALSE, 5); button = gtk_button_new_with_label("Close"); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_main_quit), 0); gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 5); gnome_app_set_contents(GNOME_APP(w), vbox); gtk_widget_show_all(w); dark_grey.red = dark_grey.green = dark_grey.blue = 0x8000; gdk_color_alloc(gdk_window_get_colormap(w->window), &dark_grey); gdk_color_black(gdk_window_get_colormap(w->window), &black); gtk_main(); return 0; }
static GtkWidget * wins_create_win (char *name, char *title, xchatwin **xw_ret) { GtkWidget *win; GtkWidget *vbox; xchatwin *xw; #ifdef USE_GNOME win = gnome_app_new ("X-Chat", title); #else win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (win), title); #endif gtk_window_set_wmclass (GTK_WINDOW (win), name, "X-Chat"); wins_set_icon (win); gtk_window_set_policy (GTK_WINDOW (win), TRUE, TRUE, FALSE); vbox = gtk_vbox_new (0, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); #ifdef USE_GNOME gnome_app_set_contents (GNOME_APP (win), vbox); #else gtk_container_add (GTK_CONTAINER (win), vbox); #endif gtk_widget_show (vbox); xw = wins_add_window (win, title, name); xw->is_toplevel = TRUE; xw->vbox = vbox; *xw_ret = xw; return win; }
/** * Create integrated user interface */ void create_integrated_ui (void) { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *hbox; GtkWidget *wrapbox; GtkWidget *menubar; GtkWidget *toolbar; GtkWidget *notebook; GtkWidget *statusbar; GtkAccelGroup *accel_group; GtkWidget *layer_view; #ifdef HAVE_GNOME window = gnome_app_new ("Dia", _("Diagram Editor")); #else window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_ref (window); gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION); #endif /* hint to window manager on X so the wm can put the window in the same as it was when the application shut down */ gtk_window_set_role (GTK_WINDOW (window), DIA_MAIN_WINDOW); gtk_window_set_default_size (GTK_WINDOW (window), 146, 349); app_set_icon (GTK_WINDOW (window)); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (toolbox_delete), window); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (toolbox_destroy), window); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1); #ifdef HAVE_GNOME gnome_app_set_contents (GNOME_APP(window), main_vbox); #else gtk_container_add (GTK_CONTAINER (window), main_vbox); #endif gtk_widget_show (main_vbox); /* Applicatioon Statusbar */ statusbar = gtk_statusbar_new (); gtk_box_pack_end (GTK_BOX (main_vbox), statusbar, FALSE, TRUE, 0); /* HBox for everything below the menubar and toolbars */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end (GTK_BOX (main_vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); /* Layer View */ layer_view = create_layer_view_widget (); gtk_box_pack_end (GTK_BOX (hbox), layer_view, FALSE, FALSE, 0); /* Diagram Notebook */ notebook = gtk_notebook_new (); gtk_box_pack_end (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_widget_show (notebook); /* Toolbox widget */ wrapbox = toolbox_create(); gtk_box_pack_start (GTK_BOX (hbox), wrapbox, FALSE, TRUE, 0); g_signal_connect (G_OBJECT (wrapbox), "drag_data_received", G_CALLBACK (dia_dnd_file_drag_data_received), NULL); /* userdata == NULL here intentionally */ /* menus -- initialised afterwards, because initing the display menus * uses the tool buttons*/ menus_get_integrated_ui_menubar(&menubar, &toolbar, &accel_group); gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); #ifdef HAVE_GNOME gnome_app_set_menus (GNOME_APP (window), GTK_MENU_BAR (menubar)); #else gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); #endif /* Toolbar */ /* TODO: maybe delete set_style(toolbar,ICONS) */ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, TRUE, 0); gtk_widget_show (toolbar); persistence_register_window(GTK_WINDOW(window)); ui.main_window = GTK_WINDOW (window); ui.toolbar = GTK_TOOLBAR (toolbar); ui.diagram_notebook = GTK_NOTEBOOK (notebook); ui.statusbar = GTK_STATUSBAR (statusbar); ui.layer_view = layer_view; /* NOTE: These functions use ui.xxx assignments above and so must come after * the user interface components are set. */ integrated_ui_toolbar_show (TRUE); integrated_ui_statusbar_show (TRUE); /* For access outside here: */ g_object_set_data (G_OBJECT (ui.main_window), DIA_MAIN_NOTEBOOK, notebook); /* TODO: Figure out what to do about toolbox_shell for integrated UI */ toolbox_shell = window; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *panel; GtkWidget *label1; GtkWidget *label1aligned; GtkWidget *label2; GtkWidget *label2aligned; GtkWidget *button; GtkWidget *buttonbar; /* Initializations. */ gnome_init (PACKAGE, VERSION, argc, argv); textdomain ("hello-c-gnome"); bindtextdomain ("hello-c-gnome", LOCALEDIR); /* Create the GUI elements. */ window = gnome_app_new ("hello-c-gnome", "Hello example"); gtk_widget_realize (window); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (quit_callback), NULL); label1 = gtk_label_new (_("Hello, world!")); label1aligned = gtk_alignment_new (0.0, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (label1aligned), label1); label2 = gtk_label_new (g_strdup_printf (_("This program is running as process number %d."), getpid ())); label2aligned = gtk_alignment_new (0.0, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (label2aligned), label2); button = gtk_button_new_with_label ("OK"); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (quit_callback), NULL); buttonbar = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbar), GTK_BUTTONBOX_END); gtk_box_pack_start_defaults (GTK_BOX (buttonbar), button); panel = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); gtk_box_pack_start_defaults (GTK_BOX (panel), label1aligned); gtk_box_pack_start_defaults (GTK_BOX (panel), label2aligned); gtk_box_pack_start_defaults (GTK_BOX (panel), buttonbar); gnome_app_set_contents (GNOME_APP (window), panel); /* Make the GUI elements visible. */ gtk_widget_show (label1); gtk_widget_show (label1aligned); gtk_widget_show (label2); gtk_widget_show (label2aligned); gtk_widget_show (button); gtk_widget_show (buttonbar); gtk_widget_show (panel); gtk_widget_show (window); /* Start the event loop. */ gtk_main (); return 0; }
int main (int argc, char *argv[]) { GtkWidget *label; GdkPixbuf *icon_pixbuf; GError *err = NULL; bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); srand (time(NULL)); gnome_program_init (APPID, APPVERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_POPT_TABLE, options, GNOME_PARAM_NONE); textbox_setup (); /* needs to be done before text boxes are created */ /* Initialize the GConf library */ if (!gconf_init (argc, argv, &err)) { fprintf (stderr, _("Failed to init GConf: %s\n"), err->message); g_error_free (err); err = NULL; } /* Start a GConf client */ gconf_client = gconf_client_get_default (); /* Add the GTetrinet directories to the list of directories that GConf client must watch */ gconf_client_add_dir (gconf_client, "/apps/gtetrinet/sound", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_add_dir (gconf_client, "/apps/gtetrinet/themes", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_add_dir (gconf_client, "/apps/gtetrinet/keys", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_add_dir (gconf_client, "/apps/gtetrinet/partyline", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); /* Request notification of change for these gconf keys */ gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/midi_player", (GConfClientNotifyFunc) sound_midi_player_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_sound", (GConfClientNotifyFunc) sound_enable_sound_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/enable_midi", (GConfClientNotifyFunc) sound_enable_midi_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/themes/theme_dir", (GConfClientNotifyFunc) themes_theme_dir_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/down", (GConfClientNotifyFunc) keys_down_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/left", (GConfClientNotifyFunc) keys_left_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/right", (GConfClientNotifyFunc) keys_right_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_left", (GConfClientNotifyFunc) keys_rotate_left_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/rotate_right", (GConfClientNotifyFunc) keys_rotate_right_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/drop", (GConfClientNotifyFunc) keys_drop_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/message", (GConfClientNotifyFunc) keys_message_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/discard", (GConfClientNotifyFunc) keys_discard_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special1", (GConfClientNotifyFunc) keys_special1_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special2", (GConfClientNotifyFunc) keys_special2_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special3", (GConfClientNotifyFunc) keys_special3_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special4", (GConfClientNotifyFunc) keys_special4_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special5", (GConfClientNotifyFunc) keys_special5_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special6", (GConfClientNotifyFunc) keys_special6_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/keys/special_self", (GConfClientNotifyFunc) keys_special_self_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", (GConfClientNotifyFunc) partyline_enable_timestamps_changed, NULL, NULL, NULL); gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list", (GConfClientNotifyFunc) partyline_enable_channel_list_changed, NULL, NULL, NULL); /* load settings */ config_loadconfig (); /* initialise some stuff */ fields_init (); if (!g_thread_supported()) g_thread_init (NULL); /* first set up the display */ /* create the main window */ app = gnome_app_new (APPID, APPNAME); g_signal_connect (G_OBJECT(app), "destroy", GTK_SIGNAL_FUNC(destroymain), NULL); keypress_signal = g_signal_connect (G_OBJECT(app), "key-press-event", GTK_SIGNAL_FUNC(keypress), NULL); g_signal_connect (G_OBJECT(app), "key-release-event", GTK_SIGNAL_FUNC(keyrelease), NULL); gtk_widget_set_events (app, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); gtk_window_set_resizable (GTK_WINDOW (app), TRUE); /* create and set the window icon */ icon_pixbuf = gdk_pixbuf_new_from_file (PIXMAPSDIR "/gtetrinet.png", NULL); if (icon_pixbuf) { gtk_window_set_icon (GTK_WINDOW (app), icon_pixbuf); gdk_pixbuf_unref (icon_pixbuf); } /* create the notebook */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook), GTK_POS_TOP); /* put it in the main window */ gnome_app_set_contents (GNOME_APP(app), notebook); /* make menus + toolbar */ make_menus (GNOME_APP(app)); /* create the pages in the notebook */ fieldswidget = fields_page_new (); gtk_widget_set_sensitive (fieldswidget, TRUE); gtk_widget_show (fieldswidget); pfields = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER(pfields), 0); gtk_container_add (GTK_CONTAINER(pfields), fieldswidget); gtk_widget_show (pfields); g_object_set_data (G_OBJECT(fieldswidget), "title", "Playing Fields"); // FIXME label = pixmapdata_label (fields_xpm, _("Playing Fields")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pfields, label); partywidget = partyline_page_new (); gtk_widget_show (partywidget); pparty = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER(pparty), 0); gtk_container_add (GTK_CONTAINER(pparty), partywidget); gtk_widget_show (pparty); g_object_set_data (G_OBJECT(partywidget), "title", "Partyline"); // FIXME label = pixmapdata_label (partyline_xpm, _("Partyline")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pparty, label); winlistwidget = winlist_page_new (); gtk_widget_show (winlistwidget); pwinlist = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER(pwinlist), 0); gtk_container_add (GTK_CONTAINER(pwinlist), winlistwidget); gtk_widget_show (pwinlist); g_object_set_data (G_OBJECT(winlistwidget), "title", "Winlist"); // FIXME label = pixmapdata_label (winlist_xpm, _("Winlist")); gtk_widget_show (label); gtk_notebook_append_page (GTK_NOTEBOOK(notebook), pwinlist, label); /* add signal to focus the text entry when switching to the partyline page*/ g_signal_connect_after(G_OBJECT (notebook), "switch-page", GTK_SIGNAL_FUNC (switch_focus), NULL); gtk_widget_show (notebook); g_object_set (G_OBJECT (notebook), "can-focus", FALSE, NULL); partyline_show_channel_list (list_enabled); gtk_widget_show (app); // gtk_widget_set_size_request (partywidget, 480, 360); // gtk_widget_set_size_request (winlistwidget, 480, 360); /* initialise some stuff */ commands_checkstate (); /* check command line params */ #ifdef DEBUG printf ("option_connect: %s\n" "option_nick: %s\n" "option_team: %s\n" "option_pass: %s\n" "option_spec: %i\n", option_connect, option_nick, option_team, option_pass, option_spec); #endif if (option_nick) GTET_O_STRCPY(nick, option_nick); if (option_team) GTET_O_STRCPY(team, option_team); if (option_pass) GTET_O_STRCPY(specpassword, option_pass); if (option_spec) spectating = TRUE; if (option_connect) { client_init (option_connect, nick); } /* Don't schedule if data is ready, glib should do this itself, * but welcome to anything that works... */ g_main_context_set_poll_func(NULL, gtetrinet_poll_func); /* gtk_main() */ gtk_main (); client_disconnect (); /* cleanup */ fields_cleanup (); sound_stopmidi (); return 0; }
main(int argc, char *argv[]) { int n; int rows, cols; int drawButtons; char *btn_font, *disp_font; /* GtkWidget *main_w; */ GtkWidget *vbox; GtkWidget *menu; GtkWidget *mdisp; GtkWidget *lcd; GtkWidget *btns; GdkFont *new_font; GtkStyle *default_style, *new_style; GdkBitmap *icon_bitmap; #ifdef USE_GNOME GnomeAppBar *appbar; #endif setlocale(LC_ALL, "C"); #ifdef USE_GNOME gnome_init("grpn", "1.0", argc, argv); gnome_app_new("grpn", "grpn"); #else /* initialize gtk */ gtk_init(&argc, &argv); #endif /* initial values */ drawButtons = 1; rows = 8; cols = 30; btn_font = disp_font = NULL; /* process command line args */ n = 1; while(n < argc){ if(0 == strcmp("-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -fn."); exit(0); } btn_font = disp_font = argv[n]; } else if(0 == strcmp("-btn-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -btn-fn."); exit(0); } btn_font = argv[n]; } else if(0 == strcmp("-disp-fn", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -disp-fn."); exit(0); } disp_font = argv[n]; } else if(0 == strcmp("-rows", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -rows."); exit(0); } if(1 != sscanf(argv[n], "%d", &rows)){ usage("Unable to read number or rows."); exit(0); } } else if(0 == strcmp("-cols", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -cols."); exit(0); } if(1 != sscanf(argv[n], "%d", &cols)){ usage("Unable to read number or cols."); exit(0); } } else if(0 == strcmp("-b", argv[n])){ drawButtons = 0; } else if(0 == strcmp("-bm", argv[n])){ n++; if(n >= argc){ usage("Missing required argument for -m."); exit(0); } if (0 == strcmp("dec", argv[n])){ setBaseMode(DECIMAL); } else if (0 == strcmp("eng", argv[n])){ setBaseMode(DECIMAL_ENG); } else if (0 == strcmp("bin", argv[n])){ setBaseMode(BINARY); } else if (0 == strcmp("oct", argv[n])){ setBaseMode(OCTAL); } else if (0 == strcmp("hex", argv[n])){ setBaseMode(HEXADECIMAL); } else { usage("Specify dec, eng, bin, oct or hex for -m."); exit(0); } } else { usage("Unknown Argument."); exit(0); } n++; } /* set up any constants we may use */ setup_constant(); /* initialize the undo system */ initUndoSystem(); /* setup the stack */ if(0 == setup_stack()){ fprintf(stderr, "Error: Could not initalize data structures.\n"); exit(0); } /* set the font if told */ if(btn_font != NULL){ default_style = gtk_widget_get_default_style(); if(NULL == (new_font = gdk_font_load(btn_font))){ fprintf(stderr, "Unable to load font %s.\n", btn_font); exit(0); } new_style = gtk_style_copy(default_style); new_style->font_desc = new_font; /* BDD - No longer in Gtk2.x */ /* gtk_widget_set_default_style(new_style); */ } #ifdef USE_GNOME main_w = gnome_app_new("grpn", "grpn"); setup_menu(main_w); appbar = GNOME_APPBAR(gnome_appbar_new(FALSE, FALSE, FALSE)); gnome_app_set_statusbar(GNOME_APP(main_w), GTK_WIDGET(appbar)); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gnome_app_set_contents(GNOME_APP(main_w), vbox); gtk_widget_show(vbox); #else /* the main window contains the work area and the menubar */ main_w = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_name(main_w, "grpn"); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(main_w), vbox); gtk_widget_show(vbox); /* set up the menu bar */ menu = setup_menu(vbox); #endif /* handle window manager close */ gtk_signal_connect(GTK_OBJECT(main_w), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(main_w), "destroy", GTK_SIGNAL_FUNC(destroy), NULL); /* create the varrious subsystems */ mdisp = setupModeDisplay(vbox); if(drawButtons) btns = setupButtons(vbox); lcd = setupLCD(vbox, rows, cols, disp_font); /* Create pixmap of depth 1 (bitmap) for icon */ gtk_widget_realize(main_w); icon_bitmap = gdk_bitmap_create_from_data(main_w->window, icon_bitmap_bits, icon_bitmap_width, icon_bitmap_height); gdk_window_set_icon(main_w->window, NULL, icon_bitmap, NULL); gtk_widget_show(main_w); gtk_main(); }
int main (int argc, char *argv []) { GtkWidget *label; GnomeClient *client; gnome_score_init("same-gnome"); bindtextdomain (PACKAGE, GNOMELOCALEDIR); textdomain (PACKAGE); gnome_init_with_popt_table ("same-gnome", VERSION, argc, argv, options, 0, NULL); gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-gsame.png"); client= gnome_master_client (); gtk_signal_connect (GTK_OBJECT (client), "save_yourself", GTK_SIGNAL_FUNC (save_state), argv[0]); gtk_signal_connect (GTK_OBJECT (client), "die", GTK_SIGNAL_FUNC (client_die), NULL); if (GNOME_CLIENT_RESTARTED (client)){ gnome_config_push_prefix (gnome_client_get_config_prefix (client)); restart (); restarted = 1; gnome_config_pop_prefix (); } srand (time (NULL)); app = gnome_app_new("same-gnome", _("Same Gnome")); gtk_window_set_policy(GTK_WINDOW(app), FALSE, FALSE, TRUE); gtk_signal_connect (GTK_OBJECT(app), "delete_event", (GtkSignalFunc)game_quit_callback, NULL); appbar = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER); gnome_app_set_statusbar(GNOME_APP (app), GTK_WIDGET(appbar)); gnome_appbar_set_status(GNOME_APPBAR (appbar), _("Welcome to Same Gnome!")); gnome_app_create_menus(GNOME_APP(app), mainmenu); gnome_app_install_menu_hints(GNOME_APP (app), mainmenu); vb = gtk_vbox_new (FALSE, 0); gnome_app_set_contents (GNOME_APP (app), vb); if (!fname) { fname = gnome_config_get_string ("/same-gnome/Preferences/Scenario=stones.png"); } create_same_board (fname); label = gtk_label_new (_("Score: ")); scorew = gtk_label_new (""); set_score (score); gtk_box_pack_start(GTK_BOX(appbar), label, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(appbar), scorew, FALSE, TRUE, 0); if (!restarted) new_game (); g_free (fname); gtk_widget_show (vb); gtk_widget_show (GTK_WIDGET(label)); gtk_widget_show (GTK_WIDGET(scorew)); gtk_widget_show (app); gtk_main (); return 0; }
GtkWidget *createMainWindow( void ) { GtkWidget *app;//!< Main container GtkWidget *buttonCalc, *buttonClose; GtkWidget *labelHeader; GtkWidget *label; GtkWidget *boxResistors, *boxConnType; GtkWidget *hbox, *vbox; // Create new Gnome application app = gnome_app_new("gnome1","Menus, menus, menus"); // Set window properties gtk_window_set_title(GTK_WINDOW(app), "Den mest fantastiska elektronikkalkylatorn"); gtk_window_set_position(GTK_WINDOW(app), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(app), 300, 200); gnome_app_create_menus( GNOME_APP(app), menubar); // Labels labelHeader = gtk_label_new("Räkna ut resistansen v1.0"); label = gtk_label_new("Typ av koppling:"); // Entry entryNr = gtk_spin_button_new_with_range(1,3,1); entryV = gtk_spin_button_new_with_range(56.34,10000,0.01); entryR1 = gtk_spin_button_new_with_range(1234.5 ,1000000000,0.1); entryR2 = gtk_spin_button_new_with_range(4321.0,1000000000,0.1); entryR3 = gtk_spin_button_new_with_range(5555.5,1000000000,0.1); // Buttons buttonCalc = gtk_button_new_with_label("Räkna ut"); buttonClose = gtk_button_new_with_label("Avsluta"); radioSerial = gtk_radio_button_new(NULL); radioParalell = gtk_radio_button_new_from_widget( GTK_RADIO_BUTTON( radioSerial )); // Set callback functions g_signal_connect( GTK_OBJECT (app), "destroy", GTK_SIGNAL_FUNC (closeApp), NULL ); g_signal_connect( GTK_OBJECT (buttonCalc), "clicked", GTK_SIGNAL_FUNC (buttonClicked), NULL ); g_signal_connect( GTK_OBJECT (buttonClose), "clicked", GTK_SIGNAL_FUNC (closeApp), NULL ); // Boxes boxResistors = gtk_vbox_new(FALSE, 5); boxConnType = gtk_vbox_new(TRUE, 5); hbox = gtk_hbox_new(TRUE, 5); vbox = gtk_vbox_new(FALSE, 10); // Packing boxes and adding labels gtk_box_pack_start(GTK_BOX(boxConnType), label, TRUE, FALSE, 5); addWidgetWithLabel( GTK_CONTAINER( boxConnType ), "Seriell", radioSerial ); addWidgetWithLabel( GTK_CONTAINER( boxConnType ), "Parallell", radioParalell ); addWidgetWithLabel( GTK_CONTAINER( boxConnType ), "Spänning (V):", entryV ); gtk_box_pack_start(GTK_BOX(boxConnType), buttonClose, TRUE, FALSE, 5); addWidgetWithLabel( GTK_CONTAINER(boxResistors), "Antal resistorer:", entryNr); addWidgetWithLabel( GTK_CONTAINER(boxResistors), "Resistor #1:", entryR1); addWidgetWithLabel( GTK_CONTAINER(boxResistors), "Resistor #2:", entryR2); addWidgetWithLabel( GTK_CONTAINER(boxResistors), "Resistor #3:", entryR3); gtk_box_pack_start(GTK_BOX(boxResistors), buttonCalc, TRUE, FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), boxConnType, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox), boxResistors, FALSE, FALSE, 5); // Add containers to gnome application gnome_app_set_contents( GNOME_APP(app), hbox); // Return Gnome app return app; }
GtkWidget* create_app (void) { GtkWidget *app; GtkWidget *dock1; GtkWidget *toolbar1; GtkWidget *tmp_toolbar_icon; GtkWidget *button_new; GtkWidget *button_open; GtkWidget *button_save; GtkWidget *button_save_as; GtkWidget *hexentry; GtkWidget *button_upload; GtkWidget *radiobutton_spline; GtkWidget *radiobutton_linear; GtkWidget *radiobutton_free; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *vbox2; GtkWidget *table1; GtkWidget *label1; GtkWidget *label2; GtkWidget *label3; GtkWidget *label4; GtkWidget *label5; GtkWidget *label6; GtkObject *minx_adj; GtkWidget *minx; GtkWidget *type; GList *type_items = NULL; GtkWidget *typeentry; GtkObject *maxx_adj; GtkWidget *maxx; GtkObject *miny_adj; GtkWidget *miny; GtkObject *maxy_adj; GtkWidget *maxy; GtkObject *count_adj; GtkWidget *count; GtkWidget *label10; GtkWidget *label11; GtkWidget *label12; GtkObject *scale_adj; GtkWidget *scale; GtkObject *base_adj; GtkWidget *base; GtkWidget *label13; GtkWidget *scrolledwindow1; GtkWidget *clist; GtkWidget *label8; GtkWidget *label9; GtkWidget *toolbar2; GtkWidget *list_open; GtkWidget *list_save; GtkWidget *list_add; GtkWidget *list_remove; GtkWidget *list_use; GtkWidget *curve; GtkWidget *appbar1; app = gnome_app_new ("Curvegen", _("PSXDEV Curve Generator")); gtk_object_set_data (GTK_OBJECT (app), "app", app); dock1 = GNOME_APP (app)->dock; gtk_widget_ref (dock1); gtk_object_set_data_full (GTK_OBJECT (app), "dock1", dock1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (dock1); gnome_app_create_menus (GNOME_APP (app), menubar1_uiinfo); gtk_widget_ref (menubar1_uiinfo[0].widget); gtk_object_set_data_full (GTK_OBJECT (app), "file1", menubar1_uiinfo[0].widget, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_ref (file1_menu_uiinfo[0].widget); gtk_object_set_data_full (GTK_OBJECT (app), "exit1", file1_menu_uiinfo[0].widget, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_ref (menubar1_uiinfo[1].widget); gtk_object_set_data_full (GTK_OBJECT (app), "help1", menubar1_uiinfo[1].widget, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_ref (help1_menu_uiinfo[0].widget); gtk_object_set_data_full (GTK_OBJECT (app), "about1", help1_menu_uiinfo[0].widget, (GtkDestroyNotify) gtk_widget_unref); toolbar1 = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); gtk_widget_ref (toolbar1); gtk_object_set_data_full (GTK_OBJECT (app), "toolbar1", toolbar1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (toolbar1); gnome_app_add_toolbar (GNOME_APP (app), GTK_TOOLBAR (toolbar1), "toolbar1", GNOME_DOCK_ITEM_BEH_EXCLUSIVE, GNOME_DOCK_TOP, 1, 0, 0); gtk_container_set_border_width (GTK_CONTAINER (toolbar1), 1); gtk_toolbar_set_space_size (GTK_TOOLBAR (toolbar1), 16); gtk_toolbar_set_space_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_SPACE_LINE); gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar1), GTK_RELIEF_NONE); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_NEW); button_new = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("New"), _("New File"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (button_new); gtk_object_set_data_full (GTK_OBJECT (app), "button_new", button_new, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_new); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_OPEN); button_open = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Open"), _("Open File"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (button_open); gtk_object_set_data_full (GTK_OBJECT (app), "button_open", button_open, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_open); gtk_widget_set_sensitive (button_open, FALSE); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_SAVE); button_save = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Save"), _("Save File"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (button_save); gtk_object_set_data_full (GTK_OBJECT (app), "button_save", button_save, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_save); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_SAVE_AS); button_save_as = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Save As"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (button_save_as); gtk_object_set_data_full (GTK_OBJECT (app), "button_save_as", button_save_as, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_save_as); hexentry = gtk_entry_new (); gtk_widget_ref (hexentry); gtk_object_set_data_full (GTK_OBJECT (app), "hexentry", hexentry, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hexentry); gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar1), hexentry, _("Address of curve in PlayStation memory..."), NULL); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_MAIL_FWD); button_upload = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Upload"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (button_upload); gtk_object_set_data_full (GTK_OBJECT (app), "button_upload", button_upload, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (button_upload); gtk_toolbar_append_space (GTK_TOOLBAR (toolbar1)); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_CONVERT); radiobutton_spline = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL, _("SPLINE"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (radiobutton_spline); gtk_object_set_data_full (GTK_OBJECT (app), "radiobutton_spline", radiobutton_spline, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (radiobutton_spline); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radiobutton_spline), FALSE); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_CONVERT); radiobutton_linear = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_RADIOBUTTON, radiobutton_spline, _("LINEAR"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (radiobutton_linear); gtk_object_set_data_full (GTK_OBJECT (app), "radiobutton_linear", radiobutton_linear, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (radiobutton_linear); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radiobutton_linear), FALSE); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_CONVERT); radiobutton_free = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_CHILD_RADIOBUTTON, radiobutton_spline, _("FREE"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (radiobutton_free); gtk_object_set_data_full (GTK_OBJECT (app), "radiobutton_free", radiobutton_free, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (radiobutton_free); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (radiobutton_free), FALSE); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_ref (vbox1); gtk_object_set_data_full (GTK_OBJECT (app), "vbox1", vbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (vbox1); gnome_app_set_contents (GNOME_APP (app), vbox1); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_ref (hbox1); gtk_object_set_data_full (GTK_OBJECT (app), "hbox1", hbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); vbox2 = gtk_vbox_new (FALSE, 0); gtk_widget_ref (vbox2); gtk_object_set_data_full (GTK_OBJECT (app), "vbox2", vbox2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (vbox2); gtk_box_pack_start (GTK_BOX (hbox1), vbox2, FALSE, TRUE, 0); table1 = gtk_table_new (10, 2, FALSE); gtk_widget_ref (table1); gtk_object_set_data_full (GTK_OBJECT (app), "table1", table1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (table1); gtk_box_pack_start (GTK_BOX (vbox2), table1, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (table1), 4); gtk_table_set_row_spacings (GTK_TABLE (table1), 1); gtk_table_set_col_spacings (GTK_TABLE (table1), 2); label1 = gtk_label_new (_("Min X")); gtk_widget_ref (label1); gtk_object_set_data_full (GTK_OBJECT (app), "label1", label1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label1); gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label1), 7.45058e-09, 0.5); label2 = gtk_label_new (_("Max X")); gtk_widget_ref (label2); gtk_object_set_data_full (GTK_OBJECT (app), "label2", label2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label2); gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label2), 7.45058e-09, 0.5); label3 = gtk_label_new (_("Min Y")); gtk_widget_ref (label3); gtk_object_set_data_full (GTK_OBJECT (app), "label3", label3, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label3); gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label3), 7.45058e-09, 0.5); label4 = gtk_label_new (_("Max Y")); gtk_widget_ref (label4); gtk_object_set_data_full (GTK_OBJECT (app), "label4", label4, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label4); gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 4, 5, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label4), 7.45058e-09, 0.5); label5 = gtk_label_new (_("Count")); gtk_widget_ref (label5); gtk_object_set_data_full (GTK_OBJECT (app), "label5", label5, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label5); gtk_table_attach (GTK_TABLE (table1), label5, 0, 1, 8, 9, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5); label6 = gtk_label_new (_("Type")); gtk_widget_ref (label6); gtk_object_set_data_full (GTK_OBJECT (app), "label6", label6, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label6); gtk_table_attach (GTK_TABLE (table1), label6, 0, 1, 9, 10, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5); minx_adj = gtk_adjustment_new (0, -1e+13, 1e+13, 1, 10, 10); minx = gtk_spin_button_new (GTK_ADJUSTMENT (minx_adj), 1, 4); gtk_widget_ref (minx); gtk_object_set_data_full (GTK_OBJECT (app), "minx", minx, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (minx); gtk_table_attach (GTK_TABLE (table1), minx, 1, 2, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (minx), TRUE); type = gtk_combo_new (); gtk_widget_ref (type); gtk_object_set_data_full (GTK_OBJECT (app), "type", type, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (type); gtk_table_attach (GTK_TABLE (table1), type, 1, 2, 9, 10, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_combo_set_value_in_list (GTK_COMBO (type), TRUE, FALSE); gtk_combo_set_use_arrows_always (GTK_COMBO (type), TRUE); type_items = g_list_append (type_items, _("u_char")); type_items = g_list_append (type_items, _("char")); type_items = g_list_append (type_items, _("u_short")); type_items = g_list_append (type_items, _("short")); type_items = g_list_append (type_items, _("u_long")); type_items = g_list_append (type_items, _("long")); type_items = g_list_append (type_items, _("float")); type_items = g_list_append (type_items, _("double")); type_items = g_list_append (type_items, _("fixed (4+12)")); gtk_combo_set_popdown_strings (GTK_COMBO (type), type_items); g_list_free (type_items); typeentry = GTK_COMBO (type)->entry; gtk_widget_ref (typeentry); gtk_object_set_data_full (GTK_OBJECT (app), "typeentry", typeentry, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (typeentry); gtk_entry_set_editable (GTK_ENTRY (typeentry), FALSE); gtk_entry_set_text (GTK_ENTRY (typeentry), _("u_char")); maxx_adj = gtk_adjustment_new (1, -1e+13, 1e+13, 1, 10, 10); maxx = gtk_spin_button_new (GTK_ADJUSTMENT (maxx_adj), 1, 4); gtk_widget_ref (maxx); gtk_object_set_data_full (GTK_OBJECT (app), "maxx", maxx, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (maxx); gtk_table_attach (GTK_TABLE (table1), maxx, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (maxx), TRUE); miny_adj = gtk_adjustment_new (0, -1e+13, 1e+13, 1, 10, 10); miny = gtk_spin_button_new (GTK_ADJUSTMENT (miny_adj), 1, 4); gtk_widget_ref (miny); gtk_object_set_data_full (GTK_OBJECT (app), "miny", miny, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (miny); gtk_table_attach (GTK_TABLE (table1), miny, 1, 2, 3, 4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (miny), TRUE); maxy_adj = gtk_adjustment_new (1, -1e+13, 1e+13, 1, 10, 10); maxy = gtk_spin_button_new (GTK_ADJUSTMENT (maxy_adj), 1, 4); gtk_widget_ref (maxy); gtk_object_set_data_full (GTK_OBJECT (app), "maxy", maxy, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (maxy); gtk_table_attach (GTK_TABLE (table1), maxy, 1, 2, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (maxy), TRUE); count_adj = gtk_adjustment_new (1, 1, 1e+22, 1, 10, 10); count = gtk_spin_button_new (GTK_ADJUSTMENT (count_adj), 1, 0); gtk_widget_ref (count); gtk_object_set_data_full (GTK_OBJECT (app), "count", count, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (count); gtk_table_attach (GTK_TABLE (table1), count, 1, 2, 8, 9, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); label10 = gtk_label_new (_("Curve Interval:")); gtk_widget_ref (label10); gtk_object_set_data_full (GTK_OBJECT (app), "label10", label10, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label10); gtk_table_attach (GTK_TABLE (table1), label10, 0, 2, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label10), 7.45058e-09, 0.5); label11 = gtk_label_new (_("Datatype:")); gtk_widget_ref (label11); gtk_object_set_data_full (GTK_OBJECT (app), "label11", label11, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label11); gtk_table_attach (GTK_TABLE (table1), label11, 0, 2, 5, 6, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label11), 7.45058e-09, 0.5); label12 = gtk_label_new (_("Scale")); gtk_widget_ref (label12); gtk_object_set_data_full (GTK_OBJECT (app), "label12", label12, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label12); gtk_table_attach (GTK_TABLE (table1), label12, 0, 1, 6, 7, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label12), 0, 0.5); scale_adj = gtk_adjustment_new (1, 1, 1e+22, 1, 10, 10); scale = gtk_spin_button_new (GTK_ADJUSTMENT (scale_adj), 1, 0); gtk_widget_ref (scale); gtk_object_set_data_full (GTK_OBJECT (app), "scale", scale, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scale); gtk_table_attach (GTK_TABLE (table1), scale, 1, 2, 6, 7, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); base_adj = gtk_adjustment_new (0, 0, 1e+22, 1, 10, 10); base = gtk_spin_button_new (GTK_ADJUSTMENT (base_adj), 1, 0); gtk_widget_ref (base); gtk_object_set_data_full (GTK_OBJECT (app), "base", base, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (base); gtk_table_attach (GTK_TABLE (table1), base, 1, 2, 7, 8, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); label13 = gtk_label_new (_("Base")); gtk_widget_ref (label13); gtk_object_set_data_full (GTK_OBJECT (app), "label13", label13, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label13); gtk_table_attach (GTK_TABLE (table1), label13, 0, 1, 7, 8, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (label13), 0, 0.5); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow1); gtk_object_set_data_full (GTK_OBJECT (app), "scrolledwindow1", scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow1); gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0); gtk_widget_set_sensitive (scrolledwindow1, FALSE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); clist = gtk_clist_new (2); gtk_widget_ref (clist); gtk_object_set_data_full (GTK_OBJECT (app), "clist", clist, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (clist); gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist); gtk_clist_set_column_width (GTK_CLIST (clist), 0, 28); gtk_clist_set_column_width (GTK_CLIST (clist), 1, 80); gtk_clist_column_titles_show (GTK_CLIST (clist)); label8 = gtk_label_new (_("Type")); gtk_widget_ref (label8); gtk_object_set_data_full (GTK_OBJECT (app), "label8", label8, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label8); gtk_clist_set_column_widget (GTK_CLIST (clist), 0, label8); label9 = gtk_label_new (_("Name")); gtk_widget_ref (label9); gtk_object_set_data_full (GTK_OBJECT (app), "label9", label9, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label9); gtk_clist_set_column_widget (GTK_CLIST (clist), 1, label9); toolbar2 = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); gtk_widget_ref (toolbar2); gtk_object_set_data_full (GTK_OBJECT (app), "toolbar2", toolbar2, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (toolbar2); gtk_box_pack_start (GTK_BOX (vbox2), toolbar2, FALSE, FALSE, 0); gtk_widget_set_sensitive (toolbar2, FALSE); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_OPEN); list_open = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Open"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (list_open); gtk_object_set_data_full (GTK_OBJECT (app), "list_open", list_open, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (list_open); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_SAVE); list_save = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Save"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (list_save); gtk_object_set_data_full (GTK_OBJECT (app), "list_save", list_save, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (list_save); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_ADD); list_add = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Add"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (list_add); gtk_object_set_data_full (GTK_OBJECT (app), "list_add", list_add, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (list_add); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_REMOVE); list_remove = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Remove"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (list_remove); gtk_object_set_data_full (GTK_OBJECT (app), "list_remove", list_remove, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (list_remove); tmp_toolbar_icon = gnome_stock_pixmap_widget (app, GNOME_STOCK_PIXMAP_EXEC); list_use = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Use"), NULL, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (list_use); gtk_object_set_data_full (GTK_OBJECT (app), "list_use", list_use, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (list_use); curve = gtk_curve_new (); gtk_widget_ref (curve); gtk_object_set_data_full (GTK_OBJECT (app), "curve", curve, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (curve); gtk_box_pack_start (GTK_BOX (hbox1), curve, TRUE, TRUE, 0); gtk_widget_set_usize (curve, 256, 256); gtk_curve_set_range (GTK_CURVE (curve), 0, 1, 0, 1); appbar1 = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER); gtk_widget_ref (appbar1); gtk_object_set_data_full (GTK_OBJECT (app), "appbar1", appbar1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (appbar1); gnome_app_set_statusbar (GNOME_APP (app), appbar1); gtk_signal_connect (GTK_OBJECT (app), "delete_event", GTK_SIGNAL_FUNC (on_app_delete_event), NULL); gtk_signal_connect (GTK_OBJECT (button_new), "clicked", GTK_SIGNAL_FUNC (on_button_new_clicked), NULL); gtk_signal_connect (GTK_OBJECT (button_open), "clicked", GTK_SIGNAL_FUNC (on_button_open_clicked), NULL); gtk_signal_connect (GTK_OBJECT (button_save), "clicked", GTK_SIGNAL_FUNC (on_button_save_clicked), NULL); gtk_signal_connect (GTK_OBJECT (button_save_as), "clicked", GTK_SIGNAL_FUNC (on_button_save_as_clicked), NULL); gtk_signal_connect (GTK_OBJECT (button_upload), "clicked", GTK_SIGNAL_FUNC (on_button_upload_clicked), NULL); gtk_signal_connect (GTK_OBJECT (radiobutton_spline), "clicked", GTK_SIGNAL_FUNC (on_radiobutton_spline_clicked), NULL); gtk_signal_connect (GTK_OBJECT (radiobutton_linear), "clicked", GTK_SIGNAL_FUNC (on_radiobutton_linear_clicked), NULL); gtk_signal_connect (GTK_OBJECT (radiobutton_free), "clicked", GTK_SIGNAL_FUNC (on_radiobutton_free_clicked), NULL); gtk_signal_connect (GTK_OBJECT (minx), "changed", GTK_SIGNAL_FUNC (on_minx_changed), NULL); gtk_signal_connect (GTK_OBJECT (maxx), "changed", GTK_SIGNAL_FUNC (on_maxx_changed), NULL); gtk_signal_connect (GTK_OBJECT (miny), "changed", GTK_SIGNAL_FUNC (on_miny_changed), NULL); gtk_signal_connect (GTK_OBJECT (maxy), "changed", GTK_SIGNAL_FUNC (on_maxy_changed), NULL); gtk_signal_connect (GTK_OBJECT (list_open), "clicked", GTK_SIGNAL_FUNC (on_list_open_clicked), NULL); gtk_signal_connect (GTK_OBJECT (list_save), "clicked", GTK_SIGNAL_FUNC (on_list_save_clicked), NULL); gtk_signal_connect (GTK_OBJECT (list_add), "clicked", GTK_SIGNAL_FUNC (on_list_add_clicked), NULL); gtk_signal_connect (GTK_OBJECT (list_remove), "clicked", GTK_SIGNAL_FUNC (on_list_remove_clicked), NULL); gtk_signal_connect (GTK_OBJECT (list_use), "clicked", GTK_SIGNAL_FUNC (on_list_use_clicked), NULL); return app; }
void create_toolbox () { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *vbox; GtkWidget *menubar; GtkAccelGroup *accel_group; #ifdef GNOME window = gnome_app_new ("Dia", _("Diagram Editor")); #else window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_ref (window); gtk_window_set_title (GTK_WINDOW (window), "Dia v" VERSION); gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox_window", "Dia"); #endif gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (toolbox_delete), NULL); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (toolbox_destroy), NULL); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1); #ifdef GNOME gnome_app_set_contents(GNOME_APP(window), main_vbox); #else gtk_container_add (GTK_CONTAINER (window), main_vbox); #endif gtk_widget_show (main_vbox); #ifdef GNOME gnome_toolbox_menus_create(window); #else menus_get_toolbox_menubar(&menubar, &accel_group); gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); #endif /* tooltips */ tool_tips = gtk_tooltips_new (); /* gtk_tooltips_set_colors (tool_tips, &colors[11], &main_vbox->style->fg[GTK_STATE_NORMAL]);*/ vbox = gtk_vbox_new (FALSE, 1); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 0); gtk_widget_show (vbox); create_tools (vbox); create_sheets (vbox); create_color_area (vbox); create_lineprops_area (vbox); gtk_widget_show (window); toolbox_shell = window; }
void transposition_dialog (void) { gint i; GtkWidget *mainbox, *thing, *box1, *box2, *frame, *hbox; const char *labels1[] = { _("Whole Song"), _("All Patterns"), _("Current Pattern"), _("Current Track"), NULL }; const char *labels2[] = { _("Current Instrument"), _("All Instruments"), NULL }; const char *labels3[] = { _("Half note up"), _("Half note down"), _("Octave up"), _("Octave down") }; const char *labels4[] = { _("Exchange 1 <-> 2"), _("Change 1 -> 2") }; if(transposition_window != NULL) { gdk_window_raise(transposition_window->window); return; } #ifdef USE_GNOME transposition_window = gnome_app_new("SoundTracker", _("Transposition Tools")); #else transposition_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(transposition_window), _("Transposition Tools")); #endif g_signal_connect(transposition_window, "delete_event", G_CALLBACK(transposition_close_requested), NULL); gtk_window_set_transient_for(GTK_WINDOW(transposition_window), GTK_WINDOW(mainwindow)); gtk_window_set_policy(GTK_WINDOW(transposition_window), FALSE, FALSE, FALSE); mainbox = gtk_vbox_new(FALSE, 2); gtk_container_border_width(GTK_CONTAINER(mainbox), 4); #ifdef USE_GNOME gnome_app_set_contents(GNOME_APP(transposition_window), mainbox); #else gtk_container_add(GTK_CONTAINER(transposition_window), mainbox); #endif gtk_widget_show(mainbox); box1 = gtk_hbox_new(FALSE, 4); gtk_widget_show(box1); gtk_box_pack_start(GTK_BOX(mainbox), box1, FALSE, TRUE, 0); thing = gtk_label_new(_("Scope of the operation:")); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0); add_empty_hbox(box1); make_radio_group_full(labels1, box1, transposition_scope_w, FALSE, TRUE, NULL, NULL); frame = gtk_frame_new(NULL); gtk_frame_set_label(GTK_FRAME(frame), _("Note Transposition")); gtk_box_pack_start(GTK_BOX(mainbox), frame, FALSE, TRUE, 0); gtk_widget_show(frame); box2 = gtk_vbox_new(FALSE, 2); gtk_widget_show(box2); gtk_container_add (GTK_CONTAINER(frame), box2); gtk_container_border_width(GTK_CONTAINER(box2), 4); box1 = gtk_hbox_new(FALSE, 4); gtk_widget_show(box1); gtk_box_pack_start(GTK_BOX(box2), box1, FALSE, TRUE, 0); add_empty_hbox(box1); make_radio_group_full(labels2, box1, transposition_instrument_mode_w, FALSE, TRUE, NULL, NULL); add_empty_hbox(box1); box1 = gtk_hbox_new(TRUE, 4); gtk_widget_show(box1); gtk_box_pack_start(GTK_BOX(box2), box1, FALSE, TRUE, 0); for(i = 0; i < 4; i++) { thing = gtk_button_new_with_label(labels3[i]); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(box1), thing, TRUE, TRUE, 0); g_signal_connect(thing, "clicked", G_CALLBACK(transposition_transpose_notes), GINT_TO_POINTER(i)); } frame = gtk_frame_new(NULL); gtk_frame_set_label(GTK_FRAME(frame), _("Instrument Changing")); gtk_box_pack_start(GTK_BOX(mainbox), frame, FALSE, TRUE, 0); gtk_widget_show(frame); box2 = gtk_vbox_new(FALSE, 2); gtk_widget_show(box2); gtk_container_add (GTK_CONTAINER(frame), box2); gtk_container_border_width(GTK_CONTAINER(box2), 4); box1 = gtk_hbox_new(FALSE, 4); gtk_widget_show(box1); gtk_box_pack_start(GTK_BOX(box2), box1, FALSE, TRUE, 0); add_empty_hbox(box1); gui_put_labelled_spin_button(box1, _("Instrument 1:"), 1, 128, &transposition_instrument_w[0], NULL, NULL); thing = gtk_button_new_with_label(_("Current instrument")); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0); g_signal_connect(thing, "clicked", G_CALLBACK(transposition_current_instrument_clicked), (gpointer)0); add_empty_hbox(box1); gui_put_labelled_spin_button(box1, _("Instrument 2:"), 1, 128, &transposition_instrument_w[1], NULL, NULL); thing = gtk_button_new_with_label(_("Current instrument")); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0); g_signal_connect(thing, "clicked", G_CALLBACK(transposition_current_instrument_clicked), (gpointer)1); add_empty_hbox(box1); box1 = gtk_hbox_new(TRUE, 4); gtk_widget_show(box1); gtk_box_pack_start(GTK_BOX(box2), box1, FALSE, TRUE, 0); for(i = 0; i < 2; i++) { thing = gtk_button_new_with_label(labels4[i]); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(box1), thing, TRUE, TRUE, 0); g_signal_connect(thing, "clicked", G_CALLBACK(transposition_change_instruments), GINT_TO_POINTER(i)); } /* The button area */ hbox = gtk_hbutton_box_new (); gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbox), 4); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); gtk_box_pack_start (GTK_BOX (mainbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); thing = gtk_button_new_from_stock (GTK_STOCK_CLOSE); GTK_WIDGET_SET_FLAGS(thing, GTK_CAN_DEFAULT); gtk_window_set_default(GTK_WINDOW(transposition_window), thing); g_signal_connect(thing, "clicked", G_CALLBACK(transposition_close_requested), NULL); gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, FALSE, 0); gtk_widget_show (thing); gtk_widget_show(transposition_window); }
void app_new(int argc, char *argv[], const char *geometry_string) { GtkWidget *vbox; GtkWidget *widget; GtkWidget *vpane; GtkWidget *separator; GtkLabel *filler; GtkHBox *labels; GtkVBox *status_vbox; GtkStatusbar *grip; app_window = gnome_app_new(GTT_APP_NAME, GTT_APP_TITLE " " VERSION); gtk_window_set_wmclass(GTK_WINDOW(app_window), GTT_APP_NAME, GTT_APP_PROPER_NAME); /* 485 x 272 seems to be a good size to default to */ gtk_window_set_default_size(GTK_WINDOW(app_window), 485, 272); gtk_window_set_resizable (GTK_WINDOW(app_window), TRUE); /* build menus */ menus_create(GNOME_APP(app_window)); /* build toolbar */ widget = build_toolbar(); gtk_widget_show(widget); gnome_app_set_toolbar(GNOME_APP(app_window), GTK_TOOLBAR(widget)); /* container holds status bar, main ctree widget */ vbox = gtk_vbox_new(FALSE, 0); /* build statusbar */ status_vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0)); gtk_widget_show(GTK_WIDGET(status_vbox)); labels = GTK_HBOX(gtk_hbox_new(FALSE, 0)); gtk_widget_show(GTK_WIDGET(labels)); status_bar = gtk_hbox_new(FALSE, 0); gtk_widget_show(status_bar); separator = gtk_hseparator_new(); gtk_widget_show(separator); gtk_box_pack_start(GTK_BOX(status_vbox), separator, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(status_vbox), GTK_WIDGET (labels), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(status_bar), GTK_WIDGET (status_vbox), TRUE, TRUE, 0); grip = GTK_STATUSBAR(gtk_statusbar_new()); gtk_statusbar_set_has_resize_grip(grip, TRUE); gtk_widget_show(GTK_WIDGET(grip)); gtk_box_pack_start(GTK_BOX(status_bar), GTK_WIDGET(grip), FALSE, FALSE, 0); /* put elapsed time into statusbar */ status_day_time = GTK_LABEL(gtk_label_new(_("00:00"))); gtk_widget_show(GTK_WIDGET(status_day_time)); gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(status_day_time), FALSE, TRUE, 0); /* put project name into statusbar */ status_project = GTK_LABEL(gtk_label_new( _("Timer is not running"))); gtk_widget_show(GTK_WIDGET(status_project)); gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(status_project), FALSE, TRUE, 10); filler = GTK_LABEL(gtk_label_new("")); gtk_widget_show(GTK_WIDGET(filler)); gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(filler), TRUE, TRUE, 1); /* put timer icon into statusbar */ status_timer = gtk_image_new_from_stock (GNOME_STOCK_TIMER, GTK_ICON_SIZE_MENU); gtk_widget_show(status_timer); gtk_box_pack_end(GTK_BOX(status_bar), GTK_WIDGET(status_timer), FALSE, FALSE, 1); /* create the main columned tree for showing projects */ projects_tree = gtt_projects_tree_new (); g_signal_connect (projects_tree, "columns-setup-done", G_CALLBACK (projects_tree_columns_setup_done), NULL); gtk_tree_view_set_reorderable (GTK_TREE_VIEW (projects_tree), TRUE); g_signal_connect (projects_tree, "row-activated", G_CALLBACK (projects_tree_row_activated), NULL); /* create the notes area */ global_na = notes_area_new(); vpane = notes_area_get_widget (global_na); /* Need to reparent, to get rid of glade parent-window hack. * But gtk_widget_reparent (vpane); causes a "Gtk-CRITICAL" * to occur. So we need a fancier move. */ gtk_widget_ref (vpane); gtk_container_remove(GTK_CONTAINER(vpane->parent), vpane); gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 0); gtk_widget_unref (vpane); gtk_box_pack_end(GTK_BOX(vbox), status_bar, FALSE, FALSE, 2); notes_area_add_projects_tree (global_na, projects_tree); /* we are done building it, make it visible */ gtk_widget_show(vbox); gnome_app_set_contents(GNOME_APP(app_window), vbox); gtt_status_icon_create(); if (!geometry_string) return; if (gtk_window_parse_geometry(GTK_WINDOW(app_window),geometry_string)) { geom_size_override=TRUE; } else { gnome_app_error(GNOME_APP(app_window), _("Couldn't understand geometry (position and size)\n" " specified on command line")); } }
/** * @fn GtkWidget* create_mainwin (void) * Crea la ventana principal */ GtkWidget* create_mainwin (void) { GtkWidget *app1; GtkWidget *dock1; GtkWidget *eventbox1; GtkWidget *viewport1; GtkWidget *vbox_main; GtkWidget *vbox_paned; GtkWidget *scrolledwindow; GtkWidget *paned; GtkWidget *text; GtkWidget *inputline; GtkWidget *sw; GtkWidget *ahbox; app1 = gnome_app_new ( PACKAGE, "Tenes Empanadas Graciela"); gtk_object_set_data (GTK_OBJECT (app1), "app1", app1); gtk_window_set_default_size (GTK_WINDOW (app1), 664, 640); gtk_window_set_policy (GTK_WINDOW (app1), TRUE, TRUE, FALSE); dock1 = GNOME_APP (app1)->dock; gtk_widget_ref (dock1); gtk_object_set_data_full (GTK_OBJECT (app1), "dock1", dock1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (dock1); gnome_app_create_menus (GNOME_APP (app1), menubar_uiinfo); gnome_app_create_toolbar(GNOME_APP(app1), toolbar_main); /* TODO: ask in GNOME if this is wanted */ /* gtk_menu_item_right_justify( GTK_MENU_ITEM(menubar_uiinfo[4].widget)); */ gtk_widget_realize (app1); gtk_signal_connect ( GTK_OBJECT(app1), "destroy", GTK_SIGNAL_FUNC( on_exit_activate ), NULL ); gtk_signal_connect ( GTK_OBJECT(app1), "delete_event", GTK_SIGNAL_FUNC( on_exit_activate ), NULL ); SensiData.connect_button = toolbar_main[0].widget; SensiData.start_button = toolbar_main[1].widget; /* 2 is a separator */ SensiData.enviarfichas_button = toolbar_main[3].widget; SensiData.reagrupe_button = toolbar_main[4].widget; SensiData.getcard_button = toolbar_main[5].widget; SensiData.endturn_button = toolbar_main[6].widget; /* 7 is a separator */ SensiData.status_button = toolbar_main[8].widget; eventbox1 = gtk_event_box_new (); gtk_widget_ref (eventbox1); gtk_object_set_data_full (GTK_OBJECT (app1), "eventbox1", eventbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (eventbox1); gnome_app_set_contents (GNOME_APP (app1), eventbox1); viewport1 = gtk_viewport_new (NULL, NULL); gtk_widget_show (viewport1); gtk_container_add (GTK_CONTAINER (eventbox1), viewport1); vbox_main = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox_main); gtk_container_add (GTK_CONTAINER (viewport1), vbox_main); /* status map */ if( mainstatus_create(&window_mainstatus) != TEG_STATUS_SUCCESS ) goto error; gtk_box_pack_start( GTK_BOX(vbox_main), window_mainstatus, FALSE,FALSE,0); /* paned */ paned = gtk_vpaned_new(); gtk_box_pack_start( GTK_BOX( vbox_main ), paned, TRUE, TRUE, 0 ); vbox_paned = gtk_vbox_new (FALSE, 0); gtk_paned_add1(GTK_PANED(paned), vbox_paned); gtk_widget_show (vbox_paned); /* map */ scrolledwindow = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_usize(scrolledwindow, 640, 394); if( canvas_create_map() != TEG_STATUS_SUCCESS ) goto error; gtk_container_add(GTK_CONTAINER(scrolledwindow), canvas_map); gtk_container_add(GTK_CONTAINER(vbox_paned),scrolledwindow); gtk_widget_show (canvas_map); gtk_widget_show (scrolledwindow); /* text */ ahbox = gtk_hbox_new(FALSE, 2); gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_box_pack_start(GTK_BOX(ahbox), sw, TRUE, TRUE, 0); gtk_widget_set_size_request(sw, 620, 60); text = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); gtk_container_add(GTK_CONTAINER(sw), text); gtk_widget_set_name(text, "chatline"); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); gtk_widget_realize(text); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); main_message_area = GTK_TEXT_VIEW(text); /* set_output_window_text(_("Tenes Empanadas Graciela")); */ gtk_widget_show(text); gtk_widget_show(sw); gtk_widget_show(ahbox); gtk_widget_show(paned); /* the chat line */ inputline = gtk_entry_new(); gtk_box_pack_start( GTK_BOX( vbox_main ), inputline, FALSE, FALSE, 0 ); gtk_widget_show(inputline); g_signal_connect(inputline, "activate", G_CALLBACK(inputline_return), NULL); chatline_init(); /* status bar */ statusbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER); gtk_widget_ref (statusbar); gtk_object_set_data_full (GTK_OBJECT (app1), "statusbar", statusbar, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (statusbar); gnome_app_set_statusbar (GNOME_APP (app1), statusbar); gtk_box_pack_start(GTK_BOX(statusbar), ministatus_build(), FALSE, TRUE, 0); gnome_appbar_set_status(GNOME_APPBAR(statusbar), _("Welcome to TEG!")); gnome_app_install_menu_hints( GNOME_APP(app1), menubar_uiinfo ); /* icono */ { GdkBitmap *mask; GdkPixmap *icono; #include "../teg_pix/teg_icono.xpm" gtk_widget_realize (app1); icono = gdk_pixmap_create_from_xpm_d( app1->window, &mask, &app1->style->bg[GTK_STATE_NORMAL],teg_icono_xpm ); gdk_window_set_icon (app1->window, NULL, icono , mask ); } gtk_widget_show(app1); return app1; error: g_error(_("Unable to create map!")); return NULL; }
/* initialize gnome and fir up the main window */ void ghack_init_main_window( int argc, char** argv) { int i; struct timeval tv; uid_t uid, euid; /* It seems that the authors of gnome_score_init() drop group * priveledges. We need group priveledges, so until we change the * way we save games to do things the gnome way(???), this stays * commented out. (after hours of frusteration...) * -Erik */ /* gnome_score_init("gnomehack"); */ gettimeofday(&tv, NULL); srand(tv.tv_usec); uid = getuid(); euid = geteuid(); if (uid != euid) setuid(uid); hide_privileges(TRUE); /* XXX gnome_init must print nethack options for --help, but does not */ gnome_init ("nethack", VERSION_STRING, argc, argv); hide_privileges(FALSE); parse_args (argc, argv); /* Initialize the i18n stuff (not that gnomehack supperts it yet...) */ #if 0 textdomain (PACKAGE); #endif gdk_imlib_init(); /* Main window */ mainWindow = gnome_app_new((char *) "nethack", (char *) N_("Nethack for Gnome")); gtk_widget_realize(mainWindow); if (restarted) { gtk_widget_set_uposition (mainWindow, os_x, os_y); gtk_widget_set_usize (mainWindow, os_w, os_h); } gtk_window_set_default_size( GTK_WINDOW(mainWindow), 800, 600); gtk_window_set_policy(GTK_WINDOW(mainWindow), FALSE, TRUE, TRUE); gnome_app_create_menus(GNOME_APP(mainWindow), mainmenu); gtk_signal_connect(GTK_OBJECT(mainWindow), "key_press_event", GTK_SIGNAL_FUNC(ghack_main_window_key_press), NULL); gtk_signal_connect(GTK_OBJECT(mainWindow), "delete_event", GTK_SIGNAL_FUNC(ghack_quit_game_cb), NULL); /* Put some stuff into our main window */ vBoxMain = gtk_vbox_new (FALSE, 0); hBoxFirstRow = gtk_hbox_new (FALSE, 0); /* pack Boxes into other boxes to produce the right structure */ gtk_box_pack_start (GTK_BOX (vBoxMain), hBoxFirstRow, FALSE, TRUE, 0); /* pack vBoxMain which contains all our widgets into the main window. */ gnome_app_set_contents(GNOME_APP(mainWindow), vBoxMain); /* DONT show the main window yet, due to a Gtk bug that causes it * to not refresh the window when adding widgets after the window * has already been shown */ if (uid != euid) setuid(euid); for(i = 0; i < SIZE(ghack_chain); i++) ghack_chain[i].handler = signal(ghack_chain[i].signum, ghack_sig_handler); }
static void create_app_helper (GtkWidget *widget, gpointer data) { GtkWidget *app; GtkWidget *vbox; GtkWidget *frame; GtkWidget *vbox2; GtkWidget *w; GtkWidget *popup; GnomeAppBar *bar; GnomeCanvasItem *item; app = gnome_app_new ("testGNOME", "GnomeAppHelper test"); gnome_app_create_menus (GNOME_APP (app), helper_main_menu); gnome_app_create_toolbar (GNOME_APP (app), helper_toolbar); bar = GNOME_APPBAR(gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER)); gnome_app_set_statusbar(GNOME_APP(app), GTK_WIDGET(bar)); gnome_app_install_appbar_menu_hints(GNOME_APPBAR(bar), helper_main_menu); vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); /* Shared popup menu */ popup = gnome_popup_menu_new (helper_shared_popup); frame = gtk_frame_new ("Shared popup menu"); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); gtk_container_set_border_width (GTK_CONTAINER (vbox2), GNOME_PAD_SMALL); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); w = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (vbox2), w, FALSE, FALSE, 0); gtk_widget_show (w); gnome_popup_menu_attach (popup, w, w); w = gtk_entry_new (); gtk_box_pack_start (GTK_BOX (vbox2), w, FALSE, FALSE, 0); gtk_widget_show (w); gnome_popup_menu_attach (popup, w, w); /* Popup menu explicitly popped */ popup = gnome_popup_menu_new (helper_explicit_popup); frame = gtk_frame_new ("Explicit popup menu"); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); w = gnome_canvas_new (); gtk_widget_set_size_request ((w), 200, 100); gnome_canvas_set_scroll_region (GNOME_CANVAS (w), 0.0, 0.0, 200.0, 100.0); gtk_container_add (GTK_CONTAINER (frame), w); gtk_widget_show (w); g_signal_connect (w, "destroy", G_CALLBACK (delete_event), popup); item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (w)), gnome_canvas_ellipse_get_type (), "x1", 5.0, "y1", 5.0, "x2", 95.0, "y2", 95.0, "fill_color", "white", "outline_color", "black", NULL); g_signal_connect (item, "event", G_CALLBACK (item_event), popup); item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (w)), gnome_canvas_ellipse_get_type (), "x1", 105.0, "y1", 0.0, "x2", 195.0, "y2", 95.0, "fill_color", "white", "outline_color", "black", NULL); g_signal_connect (item, "event", G_CALLBACK (item_event), popup); gnome_app_set_contents (GNOME_APP (app), vbox); gtk_widget_show (app); }
void cheat_sheet_dialog (void) { GtkWidget *mainbox, *scrolled_window, *text, *hbox, *thing; GdkFont *font; if(cheat_sheet_window != NULL) { gdk_window_raise(cheat_sheet_window->window); return; } #ifdef USE_GNOME cheat_sheet_window = gnome_app_new("SoundTracker", _("XM Effects Cheat Sheet")); #else cheat_sheet_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(cheat_sheet_window), _("XM Effects Cheat Sheet")); #endif g_signal_connect (GTK_OBJECT (cheat_sheet_window), "delete_event", GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL); mainbox = gtk_vbox_new(FALSE, 2); gtk_container_border_width(GTK_CONTAINER(mainbox), 4); #ifdef USE_GNOME gnome_app_set_contents(GNOME_APP(cheat_sheet_window), mainbox); #else gtk_container_add(GTK_CONTAINER(cheat_sheet_window), mainbox); #endif gtk_widget_show(mainbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_box_pack_start (GTK_BOX (mainbox), scrolled_window, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_widget_show (scrolled_window); /* Close button */ thing = gtk_hseparator_new(); gtk_widget_show(thing); gtk_box_pack_start(GTK_BOX(mainbox), thing, FALSE, TRUE, 0); hbox = gtk_hbutton_box_new (); gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbox), 4); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END); gtk_box_pack_start (GTK_BOX (mainbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); thing = gtk_button_new_from_stock (GTK_STOCK_CLOSE); GTK_WIDGET_SET_FLAGS(thing, GTK_CAN_DEFAULT); gtk_window_set_default(GTK_WINDOW(cheat_sheet_window), thing); g_signal_connect (GTK_OBJECT (thing), "clicked", GTK_SIGNAL_FUNC (cheat_sheet_close_requested), NULL); gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, FALSE, 0); gtk_widget_show (thing); text = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (text), FALSE); gtk_text_set_word_wrap (GTK_TEXT (text), FALSE); gtk_container_add (GTK_CONTAINER (scrolled_window), text); gtk_widget_grab_focus (text); gtk_widget_show (text); gtk_widget_set_usize(text, 42 * 12, 46 * 12); font = gdk_font_load ("-adobe-courier-medium-r-normal--*-120-*-*-*-*-*-*"); gtk_text_insert(GTK_TEXT(text), font, NULL, NULL, cheat_sheet_string, -1); /* The Text widget will reference count the font, so we * unreference it here */ gdk_font_unref (font); gtk_widget_show (cheat_sheet_window); }
GtkWidget* create_gifmain (void) { GtkWidget *toolbar; GtkWidget *tmp_toolbar_icon; GtkWidget *butConnect,*butAdd, *butConf, *butOffline; GtkWidget *appbar; char pathname[MAX_PATH_LENGTH]; gifmain = gnome_app_new ("gchat", "gchat"); gtk_window_set_position (GTK_WINDOW (gifmain), GTK_WIN_POS_CENTER); gtk_window_set_default_size (GTK_WINDOW (gifmain), 205, 400); strcpy(pathname,COMMON_PATH_PREFIX); strcat(pathname,"client/pixmaps/icon.png"); gtk_window_set_icon(GTK_WINDOW(gifmain), create_pixbuf(pathname)); gnome_app_create_menus (GNOME_APP (gifmain), menubar_uiinfo); gtk_widget_set_sensitive (conn_menu_uiinfo[1].widget, FALSE); gtk_widget_set_sensitive (mnuContacts_menu_uiinfo[0].widget, FALSE); gtk_widget_set_sensitive (mnuContacts_menu_uiinfo[1].widget, FALSE); gtk_widget_set_sensitive (mnuContacts_menu_uiinfo[3].widget, FALSE); toolbar = gtk_toolbar_new (); gtk_widget_show (toolbar); gnome_app_add_toolbar (GNOME_APP (gifmain), GTK_TOOLBAR (toolbar), "toolbar", BONOBO_DOCK_ITEM_BEH_EXCLUSIVE, BONOBO_DOCK_TOP, 1, 0, 0); gtk_container_set_border_width (GTK_CONTAINER (toolbar), 1); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH); tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-jump-to", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar))); butConnect = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("C_onn"), _("Connect to the server"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar)->children)->data))->label), TRUE); gtk_widget_show (butConnect); tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-add", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar))); butAdd = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("_Add"), _("Add new contacts"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar)->children)->data))->label), TRUE); gtk_widget_show (butAdd); gtk_widget_set_sensitive (butAdd, FALSE); tmp_toolbar_icon = gtk_image_new_from_stock ("gnome-stock-scores", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar))); butConf = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Con_f"), _("Make a conference"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar)->children)->data))->label), TRUE); gtk_widget_show (butConf); gtk_widget_set_sensitive (butConf, FALSE); tmp_toolbar_icon = gtk_image_new_from_stock ("gnome-stock-mail", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar))); butOffline = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_CHILD_BUTTON, NULL, _("Off_line"), _("View offline messages"), NULL, tmp_toolbar_icon, NULL, NULL); gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar)->children)->data))->label), TRUE); gtk_widget_show (butOffline); gtk_widget_set_sensitive (butOffline, FALSE); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow1); gnome_app_set_contents (GNOME_APP (gifmain), scrolledwindow1); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); appbar = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER); gtk_widget_show (appbar); gnome_app_set_statusbar (GNOME_APP (gifmain), appbar); gnome_app_install_menu_hints (GNOME_APP (gifmain), menubar_uiinfo); gtk_widget_show(gifmain); gtk_signal_connect (GTK_OBJECT (butConnect), "clicked", G_CALLBACK (on_Connect), NULL); gtk_signal_connect (GTK_OBJECT (butAdd), "clicked", G_CALLBACK (on_Add), NULL); gtk_signal_connect (GTK_OBJECT (butConf), "clicked", G_CALLBACK (on_butConf_clicked), NULL); gtk_signal_connect (GTK_OBJECT (butOffline), "clicked", G_CALLBACK (on_Offline), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (gifmain, gifmain, "gifmain"); GLADE_HOOKUP_OBJECT (gifmain, menubar_uiinfo[0].widget, "conn"); GLADE_HOOKUP_OBJECT (gifmain, conn_menu_uiinfo[0].widget, "mnuConnect"); GLADE_HOOKUP_OBJECT (gifmain, conn_menu_uiinfo[1].widget, "mnuDisconect"); GLADE_HOOKUP_OBJECT (gifmain, conn_menu_uiinfo[2].widget, "separator1"); GLADE_HOOKUP_OBJECT (gifmain, conn_menu_uiinfo[3].widget, "mnuQuit"); GLADE_HOOKUP_OBJECT (gifmain, menubar_uiinfo[1].widget, "mnuContacts"); GLADE_HOOKUP_OBJECT (gifmain, mnuContacts_menu_uiinfo[0].widget, "mnuAdd"); GLADE_HOOKUP_OBJECT (gifmain, mnuContacts_menu_uiinfo[1].widget, "mnuDelete"); GLADE_HOOKUP_OBJECT (gifmain, mnuContacts_menu_uiinfo[2].widget, "separator2"); GLADE_HOOKUP_OBJECT (gifmain, mnuContacts_menu_uiinfo[3].widget, "mnuOffline"); GLADE_HOOKUP_OBJECT (gifmain, menubar_uiinfo[2].widget, "mnuHelp"); GLADE_HOOKUP_OBJECT (gifmain, mnuHelp_menu_uiinfo[0].widget, "mnuAbout"); GLADE_HOOKUP_OBJECT (gifmain, toolbar, "toolbar"); GLADE_HOOKUP_OBJECT (gifmain, butConnect, "butConnect"); GLADE_HOOKUP_OBJECT (gifmain, butAdd, "butAdd"); GLADE_HOOKUP_OBJECT (gifmain, butConf, "butConf"); GLADE_HOOKUP_OBJECT (gifmain, butOffline, "butOffline"); GLADE_HOOKUP_OBJECT (gifmain, scrolledwindow1, "scrolledwindow1"); GLADE_HOOKUP_OBJECT (gifmain, appbar, "appbar"); return gifmain; }