Logo Search packages:      
Sourcecode: teg version File versions  Download package

TEG_STATUS mainstatus_create ( GtkWidget **  window  ) 

! Creates the widget for the Main Status

Definition at line 447 of file status.c.

{
      int i;
      int failed=1;

      if( mainstatus_canvas )
            goto error;

      mainstatus_canvas = gnome_canvas_new();
      if( ! mainstatus_canvas )
            goto error;

      /* load colors for started_item, and player_colors */
      colors_load_images();

      gtk_widget_set_usize ( mainstatus_canvas, MAINSTATUS_X, MAINSTATUS_Y + 1 );
      gnome_canvas_set_scroll_region (GNOME_CANVAS (mainstatus_canvas), 0, 0, MAINSTATUS_X, MAINSTATUS_Y);

      /* background */
      if( gui_theme.toolbar_custom && gui_theme.toolbar_name )
      {
            GdkPixbuf *im;
            char *filename = theme_load_file( gui_theme.toolbar_name );
            im = gdk_pixbuf_new_from_file(filename, NULL);

            if( im ) {
                  gnome_canvas_item_new(
                        gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
                        gnome_canvas_pixbuf_get_type (),
                        "pixbuf", im,
                        "x", 0.0,
                        "y", 0.0,
                        /* "width", (double) gdk_pixbuf_get_width(im), */
                        /* "height", (double) gdk_pixbuf_get_height(im), */
                        "width", (double) MAINSTATUS_X,
                        "height", (double) MAINSTATUS_Y,
                        "anchor", GTK_ANCHOR_NW,
                        NULL);

                  failed = 0;

                  gdk_pixbuf_unref( im );
            }
      }

      /* load default background */
      if( failed ) {
            gnome_canvas_item_new(
                  gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
                  gnome_canvas_rect_get_type (),
                  "x1", 0.0,
                  "y1", 0.0,
                  "x2", (double) MAINSTATUS_X,
                  "y2", (double) MAINSTATUS_Y,
                  "fill_color","light green",
                  "outline_color","black",
                  NULL);
      }

      /* round started by */
      gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",_("Round started by:"),
            "x", (double) ROUND_OFFSET,
            "y", (double) 3,
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_10_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NE,
            NULL);

      color_started_item = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_pixbuf_get_type (),
            "pixbuf", g_color_circles[TEG_MAX_PLAYERS],
            "x", (double) ROUND_OFFSET + 4,
            "y", (double) 4,
            "width", (double) gdk_pixbuf_get_width(g_color_circles[TEG_MAX_PLAYERS]),
            "height", (double) gdk_pixbuf_get_height(g_color_circles[TEG_MAX_PLAYERS]),
            "anchor",GTK_ANCHOR_NW,
            NULL);
      gnome_canvas_item_hide( color_started_item );

      /* round number */
      gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",_("Round number:"),
            "x", (double) ROUND_OFFSET,
            "y", (double) MAINSTATUS_Y/2 + 1,
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_10_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NE,
            NULL);

      round_number_item = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",_("?"),
            "x", (double) ROUND_OFFSET + 4,
            "y", (double) MAINSTATUS_Y/2 + 2,
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_12_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NW,
            NULL);

      /* players turn */
      gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",_("Players turn:"),
            "x", (double) PLAYERS_COLORS_OFFSET - 4,
            "y", (double) 3,
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_10_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NE,
            NULL);

      /* create canvas for the circles & and load the circles */
      for(i=0;i<TEG_MAX_PLAYERS;i++)
      {
            players_color[i] = gnome_canvas_item_new(
                  gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
                  gnome_canvas_pixbuf_get_type (),
                  "pixbuf", g_color_circles[TEG_MAX_PLAYERS],
                  "x", 0.0,
                  "y", 0.0,
                  "width", (double) gdk_pixbuf_get_width(g_color_circles[TEG_MAX_PLAYERS]),
                  "height", (double) gdk_pixbuf_get_height(g_color_circles[TEG_MAX_PLAYERS]),
                  "anchor", GTK_ANCHOR_NW,
                  NULL);
            gnome_canvas_item_hide( players_color[i] );
      }

      players_color_over = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_pixbuf_get_type (),
            "pixbuf", g_color_circle_over,
            "x", 0.0,
            "y", 0.0,
            "width", (double) gdk_pixbuf_get_width(g_color_circle_over),
            "height", (double) gdk_pixbuf_get_height(g_color_circle_over),
            "anchor", GTK_ANCHOR_NW,
            NULL);
      gnome_canvas_item_hide( players_color_over );


      mainstatus_update();

      *window = mainstatus_canvas;
      gtk_widget_show( mainstatus_canvas );
      return TEG_STATUS_SUCCESS;

error:
      return TEG_STATUS_ERROR;
}


Generated by  Doxygen 1.6.0   Back to index