summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-04-27 23:04:41 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-04-27 23:04:41 -0400
commitce6695cbd2620b9bfe3594ddec4d017f3399548c (patch)
treea12c1e795df24c61e4aa4e646e6a9741babfc787
parent4e7afd8977a2fd658857fbc2efa4a252e952ec82 (diff)
About box; encode file names
-rw-r--r--TODO8
-rw-r--r--configure.ac2
-rw-r--r--siv.c34
-rw-r--r--siv.glade1
-rw-r--r--siv.h2
-rw-r--r--window.c16
6 files changed, 49 insertions, 14 deletions
diff --git a/TODO b/TODO
index c57e16d..9c8828e 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,5 @@
-- About box
-
- Remember position of empty window
-- Make sure filenames are escaped if they contains [ or ]
-
- Set mimetypes in open dialog
- Dragging
@@ -15,6 +11,10 @@
Done:
+- Make sure filenames are escaped if they contains [ or ]
+
+- About box
+
- Build system
- Meta data
diff --git a/configure.ac b/configure.ac
index 94f657c..6cd3d11 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
-AC_INIT(siv,[0.5], [], siv)
+AC_INIT(siv,[0.7], [], siv)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
diff --git a/siv.c b/siv.c
index a523743..e40b1a0 100644
--- a/siv.c
+++ b/siv.c
@@ -53,11 +53,33 @@ app_unregister_window (App *app, Window *window)
gtk_main_quit ();
}
+static gchar *
+encode (const char *filename)
+{
+ GString *result = g_string_new (NULL);
+ int i;
+
+ for (i = 0; filename[i] != '\0'; ++i)
+ {
+ char c = filename[i];
+
+ if (!g_ascii_isprint (c) || c == '@' || c == '[' || c == ']')
+ g_string_append_printf (result, "@%x", c);
+ else
+ g_string_append_c (result, c);
+ }
+
+ return g_string_free (result, FALSE);
+}
+
MetaData *
-app_get_meta_data (App *app,
- const char *file)
+app_get_meta_data (App *app,
+ const char *file)
{
- MetaData *data = g_hash_table_lookup (app->meta_data, file);
+ char *encoded = encode (file);
+ MetaData *data = g_hash_table_lookup (app->meta_data, encoded);
+
+ g_free (encoded);
return data;
}
@@ -101,7 +123,8 @@ app_set_meta_data (App *app,
int hadj)
{
GKeyFile *keyfile = g_key_file_new ();
- MetaData *data = g_hash_table_lookup (app->meta_data, filename);
+ char *encoded = encode (filename);
+ MetaData *data = g_hash_table_lookup (app->meta_data, encoded);
char *key_filename = make_filename();
char *output;
@@ -109,7 +132,7 @@ app_set_meta_data (App *app,
{
data = g_new0 (MetaData, 1);
- g_hash_table_insert (app->meta_data, g_strdup (filename), data);
+ g_hash_table_insert (app->meta_data, g_strdup (encoded), data);
}
data->window_x = window_x;
@@ -133,6 +156,7 @@ app_set_meta_data (App *app,
g_key_file_free (keyfile);
g_free (key_filename);
+ g_free (encoded);
}
diff --git a/siv.glade b/siv.glade
index e0b7258..4f887ee 100644
--- a/siv.glade
+++ b/siv.glade
@@ -193,7 +193,6 @@
<widget class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
- <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property>
<property name="tooltips">True</property>
<property name="show_arrow">True</property>
diff --git a/siv.h b/siv.h
index bf38811..b7efe67 100644
--- a/siv.h
+++ b/siv.h
@@ -1,11 +1,11 @@
#ifndef SIV_H
#define SIV_H
+#include <config.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#define APPLICATION_NAME "Simple Image Viewer"
-#define PACKAGE_VERSION "0.0.1"
#define GLADE_FILE DATADIR"/siv.glade"
typedef struct Window Window;
diff --git a/window.c b/window.c
index d0764a6..7401042 100644
--- a/window.c
+++ b/window.c
@@ -543,6 +543,19 @@ retry:
}
static void
+on_about (GtkWidget *widget, gpointer data)
+{
+#define OSLASH "\303\270"
+ Window *window = data;
+
+ gtk_show_about_dialog (get_widget (window, "main_window"),
+ "program-name", APPLICATION_NAME,
+ "copyright", "Copyright 2008, S"OSLASH"ren Sandmann",
+ "version", PACKAGE_VERSION,
+ NULL);
+}
+
+static void
connect_signals (Window *window)
{
int i;
@@ -575,6 +588,7 @@ connect_signals (Window *window)
{ "drawing_area", "scroll_event", G_CALLBACK (on_scroll) },
{ "drawing_area", "size_allocate", G_CALLBACK (on_size_allocate) },
{ "menu_open", "activate", G_CALLBACK (on_open) },
+ { "menu_about", "activate", G_CALLBACK (on_about) },
};
for (i = 0; i < G_N_ELEMENTS (connections); ++i)
@@ -730,8 +744,6 @@ window_load_file (Window *window, const char *filename, GError **err)
{
GtkCheckMenuItem *item;
- g_print ("moving to %d %d\n", data->window_x, data->window_y);
-
gtk_window_move (get_widget (window, "main_window"),
data->window_x, data->window_y);