Introduced zathurarc

This commit is contained in:
Moritz Lipp 2010-06-14 21:52:19 +02:00
parent 0a20bb6218
commit 5b95da172f
2 changed files with 39 additions and 4 deletions

View file

@ -14,6 +14,7 @@ static const char FORMAT_DESCRIPTION[] = "<i>%s</i>";
/* directories and files */ /* directories and files */
static const char ZATHURA_DIR[] = ".zathura"; static const char ZATHURA_DIR[] = ".zathura";
static const char BOOKMARK_FILE[] = "bookmarks"; static const char BOOKMARK_FILE[] = "bookmarks";
static const char ZATHURA_RC[] = "zathurarc";
/* bookmarks */ /* bookmarks */
static const char BM_PAGE_ENTRY[] = "page"; static const char BM_PAGE_ENTRY[] = "page";

View file

@ -300,6 +300,7 @@ void notify(int, char*);
gboolean open_file(char*, char*); gboolean open_file(char*, char*);
void open_uri(char*); void open_uri(char*);
void update_status(); void update_status();
void read_configuration();
void recalcRectangle(int, PopplerRectangle*); void recalcRectangle(int, PopplerRectangle*);
void setCompletionRowColor(GtkBox*, int, int); void setCompletionRowColor(GtkBox*, int, int);
void set_page(int); void set_page(int);
@ -1124,6 +1125,38 @@ update_status()
g_free(zoom_level); g_free(zoom_level);
} }
void
read_configuration()
{
char* zathurarc = g_strdup_printf("%s/%s/%s", g_get_home_dir(), ZATHURA_DIR, ZATHURA_RC);
if(!zathurarc)
return;
if(g_file_test(zathurarc, G_FILE_TEST_IS_REGULAR))
{
char* content = NULL;
if(g_file_get_contents(zathurarc, &content, NULL, NULL))
{
gchar **lines = g_strsplit(content, "\n", -1);
int n = g_strv_length(lines) - 1;
int i;
for(i = 0; i < n; i++)
{
gchar **tokens = g_strsplit(lines[i], " ", -1);
int length = g_strv_length(tokens);
if(!strcmp(tokens[0], "set"))
cmd_set(length - 1, tokens + 1);
}
}
}
g_free(zathurarc);
}
void void
recalcRectangle(int page_id, PopplerRectangle* rectangle) recalcRectangle(int page_id, PopplerRectangle* rectangle)
{ {
@ -2731,14 +2764,14 @@ cmd_set(int argc, char** argv)
return FALSE; return FALSE;
/* assembly the arguments back to one string */ /* assembly the arguments back to one string */
int i; int j;
GString *s = g_string_new(""); GString *s = g_string_new("");
for(i = 1; i < argc; i++) for(j = 1; j < argc; j++)
{ {
if(i != 0) if(j != 1)
s = g_string_append_c(s, ' '); s = g_string_append_c(s, ' ');
s = g_string_append(s, argv[i]); s = g_string_append(s, argv[j]);
} }
char **x = (char**) settings[i].variable; char **x = (char**) settings[i].variable;
@ -3701,6 +3734,7 @@ int main(int argc, char* argv[])
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
init_zathura(); init_zathura();
read_configuration();
init_colors(); init_colors();
init_directories(); init_directories();