summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@dhcp-100-2-40.bos.redhat.com>2009-04-15 16:07:35 -0400
committerSøren Sandmann Pedersen <ssp@dhcp-100-2-40.bos.redhat.com>2009-04-15 16:07:35 -0400
commit7a8846fd1e1370f1e46587ec429eb3b469af3556 (patch)
tree070b5073a49be46f5af5155912400ee3e0cf9d38
parent0e6d7edcb3853d51e71461c8665790a2916a0ceb (diff)
Allow the toolbar to be hidden
-rw-r--r--TODO5
-rw-r--r--siv.c10
-rw-r--r--siv.glade18
-rw-r--r--siv.h4
-rw-r--r--window.c17
5 files changed, 48 insertions, 6 deletions
diff --git a/TODO b/TODO
index c4d08d3..a7d28ee 100644
--- a/TODO
+++ b/TODO
@@ -28,6 +28,11 @@
- Remember the directory in the open file dialog
+- Pass through unknown properties in the metadata. (To be forwards
+ compatible). This is not hugely important. I don't really care all
+ that much about NFS mounted home directories where people run
+ different versions of siv.
+
Done:
- Handle startup notification across dbus
diff --git a/siv.c b/siv.c
index 745efbb..40b63ff 100644
--- a/siv.c
+++ b/siv.c
@@ -216,7 +216,10 @@ load_meta_data (void)
if (!get_int (keyfile, group, "hadj", &(data->hadj)))
data->hadj = 0;
-
+
+ if (!get_int (keyfile, group, "show_toolbar", &(data->show_toolbar)))
+ data->show_toolbar = TRUE;
+
g_hash_table_insert (result, g_strdup (group), data);
}
@@ -269,6 +272,7 @@ foreach (gpointer key, gpointer value, gpointer user_data)
g_key_file_set_integer (key_file, filename, "zoom_level", meta->zoom_level);
g_key_file_set_integer (key_file, filename, "hadj", meta->hadj);
g_key_file_set_integer (key_file, filename, "vadj", meta->vadj);
+ g_key_file_set_integer (key_file, filename, "show_toolbar", meta->show_toolbar);
}
void
@@ -282,7 +286,8 @@ app_set_meta_data (App *app,
BackgroundType background,
int zoom_level,
int vadj,
- int hadj)
+ int hadj,
+ int show_toolbar)
{
GKeyFile *keyfile = g_key_file_new ();
char *encoded = encode (filename);
@@ -307,6 +312,7 @@ app_set_meta_data (App *app,
data->zoom_level = zoom_level;
data->hadj = hadj;
data->vadj = vadj;
+ data->show_toolbar = show_toolbar;
g_hash_table_foreach (table, foreach, keyfile);
diff --git a/siv.glade b/siv.glade
index 4f887ee..e93c378 100644
--- a/siv.glade
+++ b/siv.glade
@@ -77,6 +77,22 @@
<widget class="GtkMenu" id="view1_menu">
<child>
+ <widget class="GtkCheckMenuItem" id="menu_toolbar">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Toolbar</property>
+ <property name="use_underline">True</property>
+ <property name="active">False</property>
+ <signal name="activate" handler="on_toolbar2_activate" last_modification_time="Wed, 15 Apr 2009 19:23:02 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkSeparatorMenuItem" id="separator3">
+ <property name="visible">True</property>
+ </widget>
+ </child>
+
+ <child>
<widget class="GtkRadioMenuItem" id="menu_white">
<property name="visible">True</property>
<property name="label" translatable="yes">_White Background</property>
@@ -190,7 +206,7 @@
</child>
<child>
- <widget class="GtkToolbar" id="toolbar1">
+ <widget class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="tooltips">True</property>
diff --git a/siv.h b/siv.h
index c3d9d5a..9d9f80d 100644
--- a/siv.h
+++ b/siv.h
@@ -32,6 +32,7 @@ struct MetaData
int zoom_level;
int vadj;
int hadj;
+ gboolean show_toolbar;
};
/* App */
@@ -52,7 +53,8 @@ void app_set_meta_data (App *data,
BackgroundType background,
int zoom_level,
int vadj,
- int hadj);
+ int hadj,
+ gboolean show_toolbar);
GtkWidget *app_get_open_chooser (App *app);
/* Doesn't really belong in the app namespace */
diff --git a/window.c b/window.c
index 52d868f..b6316c8 100644
--- a/window.c
+++ b/window.c
@@ -307,7 +307,7 @@ save_meta_data (SivWindow *window)
const char *filename;
BackgroundType bg;
gboolean smooth;
-
+ gboolean show_toolbar;
if (window->filename)
filename = window->filename;
@@ -335,6 +335,7 @@ save_meta_data (SivWindow *window)
}
smooth = gtk_check_menu_item_get_active (get_widget (window, "menu_smooth_image"));
+ show_toolbar = gtk_check_menu_item_get_active (get_widget (window, "menu_toolbar"));
app_set_meta_data (window->app,
filename,
@@ -342,7 +343,8 @@ save_meta_data (SivWindow *window)
smooth, bg,
window->zoom_level,
get_vadj (window)->value,
- get_hadj (window)->value);
+ get_hadj (window)->value,
+ show_toolbar);
}
static void
@@ -440,6 +442,11 @@ rebuild (SivWindow *window)
set_title (window);
set_sensitivity (window);
+ if (gtk_check_menu_item_get_active (get_widget (window, "menu_toolbar")))
+ gtk_widget_show (get_widget (window, "toolbar"));
+ else
+ gtk_widget_hide (get_widget (window, "toolbar"));
+
gtk_widget_queue_draw (get_widget (window, "drawing_area"));
}
@@ -919,6 +926,7 @@ connect_signals (SivWindow *window)
{ "menu_white", "activate", G_CALLBACK (on_various) },
{ "menu_no", "activate", G_CALLBACK (on_various) },
{ "menu_checkerboard", "activate", G_CALLBACK (on_various) },
+ { "menu_toolbar", "activate", G_CALLBACK (on_various) },
{ "drawing_area", "expose_event", G_CALLBACK (on_expose) },
{ "drawing_area", "scroll_event", G_CALLBACK (on_scroll) },
{ "drawing_area", "size_allocate", G_CALLBACK (on_size_allocate) },
@@ -991,6 +999,8 @@ set_defaults (SivWindow *window)
gtk_check_menu_item_set_active (get_widget (window, "menu_smooth_image"), TRUE);
gtk_check_menu_item_set_active (get_widget (window, "menu_no"), TRUE);
+ gtk_check_menu_item_set_active (get_widget (window, "menu_toolbar"), TRUE);
+
}
static void
@@ -1028,6 +1038,9 @@ apply_meta_data (SivWindow *window, const char *filename)
gtk_check_menu_item_set_active (get_widget (window, "menu_smooth_image"),
data.smooth_image);
+
+ gtk_check_menu_item_set_active (get_widget (window, "menu_toolbar"),
+ data.show_toolbar);
window->zoom_level = data.zoom_level;