Example #1
0
void
load_fileinfo(ChmFile *book)
{
  GList *pairs, *list;
  gchar *path;

  path = g_strdup_printf("%s/%s", book->dir, CHMSEE_BOOKINFO_FILE);

  g_debug("bookinfo path = %s", path);

  pairs = parse_config_file("bookinfo", path);

  for (list = pairs; list; list = list->next) {
    Item *item;

    item = list->data;

    if (strstr(item->id, "hhc")) {
      book->hhc = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "hhk")) {
      book->hhk = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "home")) {
      book->home = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "title")) {
      book->title = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "encoding")) {
      book->encoding = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "variable_font")) {
      book->variable_font = g_strdup(item->value);
      continue;
    }

    if (strstr(item->id, "fixed_font")) {
      book->fixed_font = g_strdup(item->value);
      continue;
    }
  }

  free_config_list(pairs);
}
Example #2
0
void
chmsee_load_config(ChmSee *self)
{
	g_debug("enter chmsee_load_config");
	GList *pairs, *list;
	gchar *path;

	path = g_build_filename(selfp->home, "config", NULL);

	g_debug("config path = %s", path);

	pairs = parse_config_file("config", path);

	for (list = pairs; list; list = list->next) {
		Item *item;

		item = list->data;

		/* Get user prefered language */
		if (strstr(item->id, "LANG")) {
			selfp->lang = atoi(item->value);
			continue;
		}

		/* Get last directory */
		if (strstr(item->id, "LAST_DIR")) {
			selfp->last_dir = g_strdup(item->value);
			continue;
		}

		/* Get window position */
		if (strstr(item->id, "POS_X")) {
			selfp->pos_x = atoi(item->value);
			continue;
		}
		if (strstr(item->id, "POS_Y")) {
			selfp->pos_y = atoi(item->value);
			continue;
		}
		if (strstr(item->id, "WIDTH")) {
			selfp->width = atoi(item->value);
			continue;
		}
		if (strstr(item->id, "HEIGHT")) {
			selfp->height = atoi(item->value);
			continue;
		}
		if(strstr(item->id, "HPANED_POSTION")) {
			chmsee_set_hpaned_position(self, atoi(item->value));
			continue;
		}
                if(strstr(item->id, "FULLSCREEN")) {
                  if(strcmp(item->value, "true") == 0) {
                    chmsee_set_fullscreen(self, TRUE);
                  } else if(strcmp(item->value, "false") == 0) {
                    chmsee_set_fullscreen(self, FALSE);
                  } else {
                    g_warning("%s:%d:unknown value of FULLSCREEN %s", __FILE__, __LINE__, item->value);
                  }
                }
	}

	free_config_list(pairs);
	g_free(path);
}