Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
	}
Ejemplo n.º 3
0
int
main (int argc, char **argv)
{
	char *charset;

	gnome_init ("test-charset-picker", "1.0", argc, argv);

	charset = e_charset_picker_dialog ("test-charset-picker",
					   "Pick a charset, any charset",
					   NULL, NULL);
	if (charset)
		printf ("You picked: %s\n", charset);

	return 0;
}
int main(int argc,char *argv[])
{
    GtkObject *mdi;

    gnome_init("simplemdi","1.0",argc,argv);
    mdi = gnome_mdi_new("simplemdi","Simple MDI");
    gtk_signal_connect(mdi,"destroy",
            GTK_SIGNAL_FUNC(eventDestroy),NULL);

    addChild(mdi,"First");
    addChild(mdi,"Second");
    addChild(mdi,"Third");
    addChild(mdi,"Last");

    gnome_mdi_set_mode(GNOME_MDI(mdi),GNOME_MDI_NOTEBOOK);
    //gnome_mdi_open_toplevel(GNOME_MDI(mdi));

    gtk_main();
    exit(0);
}
Ejemplo n.º 5
0
int
main (int argc, char *argv[])
{
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);

  gnome_init ("psxcdmaker", VERSION, argc, argv);

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  app = create_app1 ();
  gtk_widget_show (app);

	init();

  gtk_main ();
  return 0;
}
Ejemplo n.º 6
0
/*****************************************************************************
 * GtkMain: Gtk+ thread
 *****************************************************************************
 * this part of the interface is in a separate thread so that we can call
 * gtk_main() from within it without annoying the rest of the program.
 *****************************************************************************/
static void GtkMain( vlc_object_t *p_this )
{
    /* gtk_init needs to know the command line. We don't care, so we
     * give it an empty one */
    static char  *p_args[] = { "", NULL };
#if defined(MODULE_NAME_IS_gtk_main) || defined(MODULE_NAME_IS_gtk2_main)
    static char **pp_args  = p_args;
#endif
    static int    i_args   = 1;

    /* FIXME: deprecated ? */
#if defined(MODULE_NAME_IS_gtk2_main) || defined(MODULE_NAME_IS_gnome2_main)
    gdk_threads_init();
#endif

#if defined(MODULE_NAME_IS_gnome_main)
    gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args );
#elif defined(MODULE_NAME_IS_gnome2_main)
    gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
                        i_args, p_args,
                        GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
                        NULL );
#else
    gtk_set_locale();
    gtk_init( &i_args, &pp_args );
#endif

    gdk_threads_enter();

    vlc_thread_ready( p_this );

    /* If we don't add this simple timeout, gtk_main remains stuck if
     * we try to close the window without having sent any gtk event. */
    gtk_timeout_add( INTF_IDLE_SLEEP / 1000, foo, p_this );

    /* Enter Gtk mode */
    gtk_main();

    gdk_threads_leave();
}
Ejemplo n.º 7
0
int
main (int argc, char *argv[])
{

  gnome_init ("slim", VERSION, argc, argv);

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  mainwin = create_mainwin ();
  gtk_widget_show (mainwin);

  sbStatus = lookup_widget(mainwin, "sbStatus");
  tbRotor = lookup_widget(mainwin, "tbRotor");
  tbProgrun = lookup_widget(mainwin, "tbProgrun");
  btnProgreset = lookup_widget(mainwin, "btnProgreset");

  gtk_main ();
  return 0;
}
int
main (int argc, char *argv[])
{
  GtkWidget *rs232;

#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);
#endif

  gnome_init ("rs232", VERSION, argc, argv);

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  rs232 = create_rs232 ();
  gtk_widget_show (rs232);

  gtk_main ();
  return 0;
}
Ejemplo n.º 9
0
int
main (int argc, char **argv)
{
  GnomePrinter *printer;
  GList *list, *tmp;

  gnome_init ("TestPrint", VERSION, argc, argv);

  list = gnome_font_family_list ();
  for (tmp = list; tmp; tmp = tmp->next)
    g_print ("%s\n", (char *)tmp->data);
  gnome_font_family_list_free (list);

  printer = gnome_printer_dialog_new_modal ();

  if (printer)
    {
      print_test_page (printer);
      g_object_unref (printer);
    }

  return 0;
}
Ejemplo n.º 10
0
Archivo: gat.c Proyecto: piki/gat
/** 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;
}
Ejemplo n.º 11
0
int
main (int argc, char **argv)
{
    GladeXML *xml;
    GtkWidget *window;
    /*
#if defined (HAVE_SETENV)
    setenv ("GTK_RC_FILES", DATADIR "/themes/Crux/gtk/gtkrc", 0);
    setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 0);
#elif defined (HAVE_PUTENV)
    putenv ("GTK_RC_FILES=" DATADIR "/themes/Crux/gtk/gtkrc");
    putenv ("GNOME_DISABLE_CRASH_DIALOG=1");
#else
# warning "Need either setenv or putenv, test program is probably broken"
#endif
    */
    gnome_init ("foo", "0", argc, argv);
    glade_gnome_init ();

    if (access ("./test.glade", R_OK) == 0)
	xml = glade_xml_new ("./test.glade", "window1", NULL);
    else if (access ("../test.glade", R_OK) == 0)
	xml = glade_xml_new ("../test.glade", "window1", NULL);
    else
    {
	g_error ("can't load test.glade");
	exit (1);
    }

    window = glade_xml_get_widget (xml, "window1");
    glade_xml_signal_autoconnect (xml);
    gtk_object_destroy (GTK_OBJECT (xml));
    gtk_widget_show_all (window);

    gtk_main ();
}
Ejemplo n.º 12
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 *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;
}
Ejemplo n.º 14
0
void c_gnome_init_tool_kit (char *app_id, const char *app_version) {
	gnome_init(app_id, app_version, eif_argc, &eif_argv);
	gtk_signal_set_funcs(callback_entry_func, NULL); 
}
Ejemplo n.º 15
0
int  main(int argc, char *argv[])
{
	gnome_init(VERSION, VERSION, argc, argv);

	/* Set up to draw from card class */
	GtkWidget *vbox, *vbox1, *vbox2, *vbox3;
	GtkWidget *tbar;
	GtkWidget *setbutton, *nosetbutton;
	GdkColor white, black, blue;
	/* Done setting up */

	window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window), "Set Game");
	gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE);
	gtk_container_border_width(GTK_CONTAINER(window), 0);

	vbox= gtk_vbox_new(FALSE, 0);
	vbox1 = gtk_vbox_new(FALSE, 0);
	vbox2 = gtk_vbox_new(FALSE, 0);
	vbox3 = gtk_vbox_new(FALSE, 0);

	drawing_area = gtk_drawing_area_new();
  gtk_widget_set_events(drawing_area,
    GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK);
  gtk_widget_set_events(window, GDK_KEY_PRESS_MASK);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
    GTK_SIGNAL_FUNC(expose_event), 0);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "button_press_event",
    GTK_SIGNAL_FUNC(button_event), 0);
	GnomeUIInfo toolbar[ ] = {
GNOMEUIINFO_ITEM_STOCK ("New Game", "Start new Game", newgame, GNOME_STOCK_PIXMAP_NEW),
GNOMEUIINFO_ITEM_STOCK ("High Scores", "Shows High scores", gtk_main_quit, GNOME_STOCK_PIXMAP_SCORES),
GNOMEUIINFO_ITEM_STOCK ("End Game", "Ends Current Game", gtk_main_quit, GNOME_STOCK_PIXMAP_STOP),
GNOMEUIINFO_ITEM_STOCK ("Exit", "Exit the application", gtk_main_quit, GNOME_STOCK_PIXMAP_EXIT),
GNOMEUIINFO_END
};
	tbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
	gnome_app_fill_toolbar(GTK_TOOLBAR(tbar), toolbar, gtk_accel_group_new());
	gtk_box_pack_start(GTK_BOX(vbox1), tbar, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), vbox3, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox2), drawing_area, TRUE, TRUE, 5);
	gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), SPACE_INTER+CARD_WS*4, SPACE_INTER+CARD_HS*3);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Player"), TRUE, TRUE, 1);
	playerscore = gtk_label_new("0");
	gtk_box_pack_start(GTK_BOX(vbox3), playerscore, TRUE, TRUE, 1);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Computer"), TRUE, TRUE, 1);
	computerscore = gtk_label_new("0");
	gtk_box_pack_start(GTK_BOX(vbox3), computerscore, TRUE, TRUE, 1);
	gtk_box_pack_start(GTK_BOX(vbox3), gtk_label_new("Cards Remaining"), TRUE, TRUE, 1);
	cards_remain = gtk_label_new("81");
	gtk_box_pack_start(GTK_BOX(vbox3), cards_remain, TRUE, TRUE, 1);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	gtk_widget_show_all(window);

	gtk_idle_add( myidle, NULL);


/************************ Start Deck Setup *************************/
unsigned char *pixmap_data[] = {
    bean_e_bits,
    bean_s_bits,
    bean_f_bits,
    blob_e_bits,
    blob_s_bits,
    blob_f_bits,
    diamond_e_bits,
    diamond_s_bits,
    diamond_f_bits
  };
  int i, j;
  GdkWindow *wn = window->window;
  GdkColor col[4];
  GdkColormap *cmap = gdk_window_get_colormap(wn);
  GdkGC *gc;
  GtkStyle *style = gtk_widget_get_style(window);
  col[0].red = 54000; col[0].green = col[0].blue = 0;
  col[1].green = 40000; col[1].red = col[1].blue = 0;
  col[2].red = col[2].blue = 32000; col[2].green = 0;
  gdk_color_white(cmap, &white);
  gdk_color_black(cmap, &black);
  blue.red = blue.green = 0; blue.blue = 48000;
  gdk_color_alloc(cmap, &blue);
  for (i=0; i<3; i++)
    gdk_color_alloc(cmap, &col[i]);
  for (i=0; i<9; i++)
    for (j=0; j<3; j++)
      card_pixmap[i*3+j] = gdk_pixmap_create_from_data(wn, (gchar*) pixmap_data[i],
        SHAPE_W, SHAPE_H, -1, &col[j], &white);
  /* free colors? !! */

  gc = gdk_gc_new(wn);

  /*** cards in normal state ***/
  card_bkg = gdk_pixmap_new(wn, CARD_WIDTH, CARD_HEIGHT, -1);
  /* clear the card */
  gdk_gc_set_foreground(gc, &style->bg[GTK_STATE_NORMAL]);
  gdk_draw_rectangle(card_bkg, gc, 1, 0, 0, CARD_WIDTH, CARD_HEIGHT);
  /* draw corner arcs */
  gdk_gc_set_foreground(gc, &white);
  gdk_draw_arc(card_bkg, gc, 1, 0,                 0,
    2*ARC_SIZE, 2*ARC_SIZE, 90*64,  90*64);
  gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE, 0,
    2*ARC_SIZE, 2*ARC_SIZE, 0,      90*64);
  gdk_draw_arc(card_bkg, gc, 1, 0,                 CARD_HEIGHT-2*ARC_SIZE,
    2*ARC_SIZE, 2*ARC_SIZE, 180*64, 90*64);
  gdk_draw_arc(card_bkg, gc, 1, CARD_WIDTH-2*ARC_SIZE,
    CARD_HEIGHT-2*ARC_SIZE, 2*ARC_SIZE, 2*ARC_SIZE, 270*64, 90*64);
  /* draw the rest */
  gdk_draw_rectangle(card_bkg, gc, 1, ARC_SIZE, 0, CARD_WIDTH-2*ARC_SIZE, CARD_HEIGHT);
  gdk_draw_rectangle(card_bkg, gc, 1, 0, ARC_SIZE, CARD_WIDTH, CARD_HEIGHT-2*ARC_SIZE);
	  gdk_gc_destroy(gc);

/************************ End Deck Setup *************************/



  /* done setting up for once 
	  to draw
	  wn = drawing_area->window;
	  gc-gdk_gc_new(wn);
	  card1.draw();
	  .............draw();
	  gdk_gc_destroy();
	  
	  
	  Card(int colr, int shp, int num, int shdng);
  */
 

		mytable.Draw();
	gtk_main();
	return 0;
}	
Ejemplo n.º 16
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);
}
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{
	gboolean root_override=FALSE, open_in_new_window = FALSE;
	GList *filenames = NULL, *projectfiles=NULL;
	gint linenumber = -1;

	Tbfwin *firstbfwin;
#ifndef NOSPLASH
	GtkWidget *splash_window;
#endif /* #ifndef NOSPLASH */

#ifdef ENABLE_NLS
	setlocale(LC_ALL,"");
	bindtextdomain(PACKAGE,LOCALEDIR);
	DEBUG_MSG("set bindtextdomain for %s to %s\n",PACKAGE,LOCALEDIR);
	bind_textdomain_codeset(PACKAGE, "UTF-8");
	textdomain(PACKAGE);
#endif
#ifdef HAVE_ATLEAST_GNOMEUI_2_6
	gnome_init(PACKAGE, VERSION, argc, argv);
#else
	gtk_init(&argc, &argv);
#endif /* HAVE_ATLEAST_GNOMEUI_2_6
 */
	main_v = g_new0(Tmain, 1);
	main_v->session = g_new0(Tsessionvars,1);
	DEBUG_MSG("main, main_v is at %p\n", main_v);

	rcfile_check_directory();
	rcfile_parse_main();

	parse_commandline(argc, argv, &root_override, &filenames, &projectfiles, &open_in_new_window, &linenumber);
#ifdef WITH_MSG_QUEUE
	if (((filenames || projectfiles) && (main_v->props.view_bars & MODE_REUSE_WINDOW)) || open_in_new_window) {
		msg_queue_start(filenames, projectfiles, linenumber, open_in_new_window);
	}
#endif /* WITH_MSG_QUEUE */
#ifndef NOSPLASH
	/* start splash screen somewhere here */
	splash_window = start_splash_screen();
	splash_screen_set_label(_("parsing highlighting file..."));
#endif /* #ifndef NOSPLASH */

	{
		gchar *filename = g_strconcat(g_get_home_dir(), "/.winefish/dir_history", NULL);
		main_v->recent_directories = get_stringlist(filename, NULL);
		g_free(filename);
	}
	rcfile_parse_global_session();
	rcfile_parse_highlighting();
#ifndef NOSPLASH
	splash_screen_set_label(_("compiling highlighting patterns..."));
#endif /* #ifndef NOSPLASH */
	hl_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("initialize some other things..."));
#endif /* #ifndef NOSPLASH */
	filebrowserconfig_init();
	filebrowser_filters_rebuild();
	autoclosing_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing autotext and words file..."));
#endif /* #ifndef NOSPLASH */
	autotext_init();
	completion_init();
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing custom menu file..."));
#endif /* #ifndef NOSPLASH */
	rcfile_parse_custom_menu(FALSE,FALSE);

#ifdef SNOOPER2
#ifndef NOSPLASH
	splash_screen_set_label(_("parsing keymap and initializing function list..."));
#endif /* #ifndef NOSPLASH */
	funclist_init();
	keymap_init();
#endif /* SNOOPER2 */
	
	main_v->tooltips = gtk_tooltips_new();
	/* initialize the completion window */
	/* main_v->completion.window = NULL; */
	fref_init();
	bmark_init();
#ifdef WITH_MSG_QUEUE
	if (!filenames && !projectfiles && (main_v->props.view_bars & MODE_REUSE_WINDOW)) {
		msg_queue_start(NULL, NULL, -1, open_in_new_window);
	}
#endif /* WITH_MSG_QUEUE */
#ifndef NOSPLASH
	splash_screen_set_label(_("creating main gui..."));
#endif /* #ifndef NOSPLASH */

	/* create the first window */
	firstbfwin = g_new0(Tbfwin,1);
	firstbfwin->session = main_v->session;
	firstbfwin->bookmarkstore = main_v->bookmarkstore;
	main_v->bfwinlist = g_list_append(NULL, firstbfwin);
	gui_create_main(firstbfwin, filenames, linenumber);
	bmark_reload(firstbfwin);
#ifndef NOSPLASH
	splash_screen_set_label(_("showing main gui..."));
#endif /* #ifndef NOSPLASH */

	/* set GTK settings, must be AFTER the menu is created */
	{
		gchar *shortcutfilename;
		GtkSettings* gtksettings = gtk_settings_get_default();
		g_object_set(G_OBJECT(gtksettings), "gtk-can-change-accels", TRUE, NULL); 
		shortcutfilename = g_strconcat(g_get_home_dir(), "/.winefish/menudump_2", NULL);
		gtk_accel_map_load(shortcutfilename);
		g_free(shortcutfilename);
	}

	gui_show_main(firstbfwin);
	/*
	if (main_v->props.view_html_toolbar && main_v->globses.quickbar_items == NULL) {
		info_dialog(firstbfwin->main_window, _("Winefish tip:"), _("This message is shown since you DONOT have any items in the QuickBar.\n\nIf you right-click a button in the Standard toolbars you can add buttons to the Quickbar."));
	}
	*/
	if (projectfiles) {
		GList *tmplist = g_list_first(projectfiles);
		while (tmplist) {
			project_open_from_file(firstbfwin, tmplist->data, linenumber);
			tmplist = g_list_next(tmplist);
		}
	}

#ifndef NOSPLASH
	DEBUG_MSG("destroy splash\n");
	flush_queue();
	{
		static struct timespec const req = { 0, 10000000};
		nanosleep(&req, NULL);
	}
	gtk_widget_destroy(splash_window);
#endif /* #ifndef NOSPLASH */

	/* snooper must be installed after the main gui has shown;
	otherwise the program may be aborted */
#ifndef SNOOPER2
	snooper_install();
#endif /* SNOOPER2 */

	DEBUG_MSG("main, before gtk_main()\n");
	gtk_main();
	DEBUG_MSG("main, after gtk_main()\n");
#ifdef WITH_MSG_QUEUE	
	/* do the cleanup */
	msg_queue_cleanup();
#endif /* WITH_MSG_QUEUE */
	DEBUG_MSG("Winefish: exiting cleanly\n");
	return 0;
}
Ejemplo n.º 18
0
nsresult
nsIconChannel::InitWithGnome(nsIMozIconURI *aIconURI)
{
  nsresult rv;
  
  if (!gnome_program_get()) {
    // Get the brandShortName from the string bundle to pass to GNOME
    // as the application name.  This may be used for things such as
    // the title of grouped windows in the panel.
    nsCOMPtr<nsIStringBundleService> bundleService = 
      do_GetService(NS_STRINGBUNDLE_CONTRACTID);

    NS_ASSERTION(bundleService, "String bundle service must be present!");

    nsCOMPtr<nsIStringBundle> bundle;
    bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                                getter_AddRefs(bundle));
    nsXPIDLString appName;

    if (bundle) {
      bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                getter_Copies(appName));
    } else {
      NS_WARNING("brand.properties not present, using default application name");
      appName.AssignLiteral("Gecko");
    }

    char* empty[] = { "" };
    gnome_init(NS_ConvertUTF16toUTF8(appName).get(), "1.0", 1, empty);
  }

  nsCAutoString iconSizeString;
  aIconURI->GetIconSize(iconSizeString);

  PRUint32 iconSize;

  if (iconSizeString.IsEmpty()) {
    rv = aIconURI->GetImageSize(&iconSize);
    NS_ASSERTION(NS_SUCCEEDED(rv), "GetImageSize failed");
  } else {
    int size;
    
    GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
    gtk_icon_size_lookup(icon_size, &size, NULL);
    iconSize = size;
  }

  nsCAutoString type;
  aIconURI->GetContentType(type);

  GnomeVFSFileInfo fileInfo = {0};
  fileInfo.refcount = 1; // In case some GnomeVFS function addrefs and releases it

  nsCAutoString spec;
  nsCOMPtr<nsIURI> fileURI;
  rv = aIconURI->GetIconFile(getter_AddRefs(fileURI));
  if (fileURI) {
    fileURI->GetAsciiSpec(spec);
    // Only ask gnome-vfs for a GnomeVFSFileInfo for file: uris, to avoid a
    // network request
    PRBool isFile;
    if (NS_SUCCEEDED(fileURI->SchemeIs("file", &isFile)) && isFile) {
      gnome_vfs_get_file_info(spec.get(), &fileInfo, GNOME_VFS_FILE_INFO_DEFAULT);
    }
    else {
      // We have to get a leaf name from our uri...
      nsCOMPtr<nsIURL> url(do_QueryInterface(fileURI));
      if (url) {
        nsCAutoString name;
        // The filename we get is UTF-8-compatible, which matches gnome expectations.
        // See also: http://lists.gnome.org/archives/gnome-vfs-list/2004-March/msg00049.html
        // "Whenever we can detect the charset used for the URI type we try to
        //  convert it to/from utf8 automatically inside gnome-vfs."
        // I'll interpret that as "otherwise, this field is random junk".
        url->GetFileName(name);
        fileInfo.name = g_strdup(name.get());
      }
      // If this is no nsIURL, nothing we can do really.

      if (!type.IsEmpty()) {
        fileInfo.valid_fields = GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE;
        fileInfo.mime_type = g_strdup(type.get());
      }
    }
  }


  if (type.IsEmpty()) {
    nsCOMPtr<nsIMIMEService> ms(do_GetService("@mozilla.org/mime;1"));
    if (ms) {
      nsCAutoString fileExt;
      aIconURI->GetFileExtension(fileExt);
      ms->GetTypeFromExtension(fileExt, type);
    }
  }

  // Get the icon theme
  if (!gIconTheme) {
    gIconTheme = gnome_icon_theme_new();
    if (!gIconTheme) {
      gnome_vfs_file_info_clear(&fileInfo);
      return NS_ERROR_NOT_AVAILABLE;
    }
  }

  char* name = gnome_icon_lookup(gIconTheme, NULL, spec.get(), NULL, &fileInfo,
                                 type.get(), GNOME_ICON_LOOKUP_FLAGS_NONE,
                                 NULL);
  gnome_vfs_file_info_clear(&fileInfo);
  if (!name) {
    return NS_ERROR_NOT_AVAILABLE;
  }
 
  char* file = gnome_icon_theme_lookup_icon(gIconTheme, name, iconSize,
                                            NULL, NULL);
  g_free(name);
  if (!file)
    return NS_ERROR_NOT_AVAILABLE;

  // Create a GdkPixbuf buffer and scale it
  GError *err = nsnull;
  GdkPixbuf* buf = gdk_pixbuf_new_from_file(file, &err);
  g_free(file);
  if (!buf) {
    if (err)
      g_error_free(err);
    return NS_ERROR_UNEXPECTED;
  }

  GdkPixbuf* scaled = buf;
  if (gdk_pixbuf_get_width(buf)  != iconSize &&
      gdk_pixbuf_get_height(buf) != iconSize) {
    // scale...
    scaled = gdk_pixbuf_scale_simple(buf, iconSize, iconSize,
                                     GDK_INTERP_BILINEAR);
    gdk_pixbuf_unref(buf);
    if (!scaled)
      return NS_ERROR_OUT_OF_MEMORY;
  }

  // XXX Respect icon state
  
  rv = moz_gdk_pixbuf_to_channel(scaled, aIconURI,
                                 getter_AddRefs(mRealChannel));
  gdk_pixbuf_unref(scaled);
  return rv;
}