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;

}
Exemplo n.º 2
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();
}
Exemplo n.º 3
0
	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;
	}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
/* 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);
}
Exemplo n.º 6
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;
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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);
}
Exemplo n.º 9
0
/**
 * @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;
}
Exemplo n.º 10
0
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;
}