inline void Lattice::create_neighbours(int x, int y)
{ check_boundary(x,y);
  Site& s = get_site(x,y);

  int x1 = x+1;
  int y1 = y;
  check_boundary(x1,y1);
  Site& nb1 = get_site(x1, y1);
  s.add_neighbour(nb1);

  x1 = x;
  y1 = y+1;
  check_boundary(x1,y1);
  Site& nb2 = get_site(x1, y1);
  s.add_neighbour(nb2);

  x1 = x-1;
  y1 = y;
  check_boundary(x1,y1);
  Site& nb3 = get_site(x1, y1);
  s.add_neighbour(nb3);

  x1 = x;
  y1 = y-1;
  check_boundary(x1,y1);
  Site& nb4 = get_site(x1, y1);
  s.add_neighbour(nb4);

}
void server_properties::refresh_server() {
    samp::api::ptr api_ptr = this->get_root()->get_item<samp::api>();
    api_ptr->send_rcon_command("hostname " + get_name());
    api_ptr->send_rcon_command("weburl " + get_site());
    api_ptr->set_game_mode_text(get_mode());
    api_ptr->send_rcon_command("mapname " + get_map());
}
Exemple #3
0
int main(int argc, char *argv[])
{
    char *me;
    char *output, *input;
    char *fs;
    int dims, i, has_cat;
    struct GModule *module;
    FILE *in_fd, *out_fd;
    Site *site;
    Site_head shead;
    struct TimeStamp ts;
    struct
    {
	struct Option *input, *output, *dims, *fs, *date;
    } parm;

    G_gisinit(me = argv[0]);

    module = G_define_module();
    G_add_keyword(_("sites"));
    module->description =
	"Convert an ASCII listing of site locations "
	"into a GRASS site list file.";

    parm.output = G_define_option();
    parm.output->key = "output";
    parm.output->type = TYPE_STRING;
    parm.output->required = YES;
    parm.output->description = "vector map to be created";
    parm.output->gisprompt = "any,vector,vector";

    parm.input = G_define_option();
    parm.input->key = "input";
    parm.input->type = TYPE_STRING;
    parm.input->required = NO;
    parm.input->description = "unix file containing sites";

    parm.dims = G_define_option();
    parm.dims->key = "d";
    parm.dims->type = TYPE_INTEGER;
    parm.dims->required = NO;
    parm.dims->description = "number of dimensions (default=2)";

    parm.fs = G_define_option();
    parm.fs->key = "fs";
    parm.fs->key_desc = "character|space|tab";
    parm.fs->type = TYPE_STRING;
    parm.fs->required = NO;
    parm.fs->description = "input field separator";
    parm.fs->answer = "space";

    parm.date = G_define_option();
    parm.date->key = "date";
    parm.date->key_desc = "timestamp";
    parm.date->required = NO;
    parm.date->type = TYPE_STRING;
    parm.date->description = "datetime or datetime1/datetime2";

    if (G_parser(argc, argv))
	exit(EXIT_FAILURE);

    if ((input = parm.input->answer)) {
	in_fd = fopen(input, "r");
	if (NULL == in_fd) {
	    fprintf(stderr, "%s - ", me);
	    perror(input);
	    exit(1);
	}
    }
    else
	in_fd = stdin;

    output = parm.output->answer;
    shead.name = G_store(parm.output->answer);
    shead.desc = G_store(G_recreate_command());
    shead.form = shead.labels = shead.stime = (char *)NULL;

    /* add here time parameter */
    if (parm.date->answer) {
	if (1 == G_scan_timestamp(&ts, parm.date->answer))
	    shead.time = &ts;
	else
	    G_fatal_error("Invalid timestamp");
    }
    else
	shead.time = (struct TimeStamp *)NULL;

    dims = 2;
    loop = 1;			/* added 11/99 MNeteler */

    if (parm.dims->answer != NULL)
	if ((i = sscanf(parm.dims->answer, "%d", &dims)) != 1)
	    G_fatal_error("error scanning number of dimensions");
    if (dims < 2)
	G_fatal_error("number of dimensions must be greater than 1");

    if (strlen(parm.fs->answer) < 1)
	G_fatal_error("field separator cannot be empty");
    else {
	fs = parm.fs->answer;
	if (strcmp(fs, "space") == 0)
	    fs = NULL;
	else if (strcmp(fs, "tab") == 0)
	    fs = NULL;
    }

    out_fd = G_fopen_sites_new(output);
    if (out_fd == NULL)
	G_fatal_error("can't create sites file [%s].", output);

    G_site_put_head(out_fd, &shead);

    while ((site = get_site(in_fd, dims, fs, &has_cat)))
	G_site_put(out_fd, site);

    G_sites_close(out_fd);
    exit(0);
}
Exemple #4
0
static void
awn_html_dialog_new(WebApplet *webapplet)
{
  /* create viewer */
  webapplet->mainwindow = awn_dialog_new_for_widget (GTK_WIDGET(webapplet->applet));
  webapplet->box = gtk_vbox_new (FALSE, 1);

  webapplet->viewer = html_web_view_new ();

  /* Load the .ini file for websites */
  GError *err = NULL;
  webapplet->sites_file = g_key_file_new();

  g_key_file_load_from_file(webapplet->sites_file,
                            APPLETSDIR"/webapplet/webapplet-websites.ini",
                            0, &err);

  if (err)
  {
    printf("Error loading websites: %s\n", err->message);
    g_error_free(err);
    g_key_file_free(webapplet->sites_file);
    webapplet->sites_file = NULL;
  }

  /* If first time using this, hide WebView, show location entry/website buttons */
  if (config_get_first_start(webapplet))
  {
    gtk_widget_set_no_show_all(webapplet->viewer, TRUE);

    gtk_box_pack_start(GTK_BOX(webapplet->box), first_start(webapplet),
                       FALSE, FALSE, 0);

    awn_applet_simple_set_tooltip_text(AWN_APPLET_SIMPLE(webapplet->applet),
                                       _("Web Applet"));
  }

  else
  {
    go_to_url(webapplet, (gchar*)config_get_uri(webapplet));

    if (webapplet->sites_file)
    {
      const gchar *name = config_get_site(webapplet);

      if (name && strcmp(name, "") != 0)
      {
        gint size = awn_applet_get_size(webapplet->applet);

        WebSite *site = get_site(webapplet, (gchar*)name);
        gchar *path = g_strdup_printf(APPLETSDIR"/webapplet/icons/%s", site->icon);
        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(path, size, size, NULL);
        awn_applet_simple_set_icon_pixbuf(AWN_APPLET_SIMPLE(site->webapplet->applet), pixbuf);

        if (site->width && site->height)
        {
          gtk_widget_set_size_request(GTK_WIDGET(site->webapplet->box),
                                      site->width, site->height);
        }
      }
    }
  }

  gtk_box_pack_start(GTK_BOX(webapplet->box), webapplet->viewer, TRUE, TRUE, 0);
  gtk_container_add(GTK_CONTAINER(webapplet->mainwindow), webapplet->box);
}
Exemple #5
0
static GtkWidget *
website_buttons(WebApplet *webapplet)
{
  GtkWidget *table = gtk_table_new(1, 3, TRUE);

  if (webapplet->sites_file)
  {
    GtkWidget *button;
    GdkPixbuf *pixbuf;
    WebSite *site;
    gchar **groups, *path = NULL;
    gint i, y;

    GKeyFile *file = webapplet->sites_file;

    table = gtk_table_new(1, 3, TRUE);

    groups = g_key_file_get_groups(file, NULL);

    for (i = 0; groups[i]; i++)
    {
      button = gtk_button_new_with_label(g_key_file_get_string(file,
                                         groups[i], "Name", NULL));

      if (g_key_file_has_key(file, groups[i], "Icon-22", NULL))
      {
        path = g_strdup_printf(APPLETSDIR"/webapplet/icons/%s",
                               g_key_file_get_string(file, groups[i], "Icon-22", NULL));
      }

      else if (g_key_file_has_key(file, groups[i], "Icon-svg", NULL))
      {
        path = g_strdup_printf(APPLETSDIR"/webapplet/icons/%s",
                               g_key_file_get_string(file, groups[i], "Icon-svg", NULL));
      }

      else if (g_key_file_has_key(file, groups[i], "Icon-48", NULL))
      {
        path = g_strdup_printf(APPLETSDIR"/webapplet/icons/%s",
                               g_key_file_get_string(file, groups[i], "Icon-48", NULL));
      }

      else if (g_key_file_has_key(file, groups[i], "Icon", NULL))
      {
        path = g_strdup_printf(APPLETSDIR"/webapplet/icons/%s",
                               g_key_file_get_string(file, groups[i], "Icon", NULL));
      }

      if (path)
      {
        pixbuf = gdk_pixbuf_new_from_file_at_size(path, 22, 22, NULL);
        gtk_button_set_image(GTK_BUTTON(button),
                             gtk_image_new_from_pixbuf(pixbuf));

        g_free(path);
      }

      y = (gint)((gdouble)i / 4.0);

      gtk_table_attach(GTK_TABLE(table), button,
                       i % 4, (i % 4) + 1,
                       y, y + 1, GTK_FILL|GTK_EXPAND, 0, 3, 3);

      site = get_site(webapplet, groups[i]);

      g_signal_connect(G_OBJECT(button), "clicked",
                       G_CALLBACK(site_clicked), (gpointer)site);
    }
  }

  return table;
}