summaryrefslogtreecommitdiff
path: root/window_main.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-12-23 20:31:11 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2009-12-23 20:31:11 +0100
commitd17a46454b3ff886b0a9834d1ee63056e1d007ba (patch)
tree522d15cd35e6ced82f64c87af1423afe97a3c659 /window_main.c
parentd7c8c0381462d6f565d0c9eedfd02f61696a2fad (diff)
Show file name and image resolution in the status bar.
Diffstat (limited to 'window_main.c')
-rw-r--r--window_main.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/window_main.c b/window_main.c
index d7a8bf2..0ab12ce 100644
--- a/window_main.c
+++ b/window_main.c
@@ -12,6 +12,7 @@
#include "wallpapers.h"
#include "thumbnails.h"
+struct wallpaper_t *cur_wall = NULL;
GdkPixbuf *orig_pixbuf = NULL;
gint last_width = 0,
last_height = 0,
@@ -25,6 +26,8 @@ GtkIconView *thumbview;
GThread *add_thread = NULL,
*thumb_thread = NULL;
+guint image_context;
+
void on_foldtree_selection_changed(GtkTreeSelection *treeselection, gpointer user_data);
inline static void foldtree_create_model(GtkTreeView *foldtree) {
@@ -117,6 +120,9 @@ static void load_pixbuf(const gchar *filepath) {
GdkPixbuf *pb;
GError *error = NULL;
GdkWindow *window;
+ sqlite_uint64 wallid;
+ struct wallpaper_t *wall;
+ gchar *msg, *base;
if(orig_pixbuf)
g_object_unref(orig_pixbuf);
@@ -127,6 +133,31 @@ static void load_pixbuf(const gchar *filepath) {
return;
}
+ if(cur_wall) {
+ g_free(cur_wall->filepath);
+ g_free(cur_wall);
+ cur_wall = NULL;
+ }
+
+ wallid = db_get_wallpaper(filepath);
+ if(wallid) {
+ wall = g_malloc(sizeof(struct wallpaper_t));
+ if(db_get_wallpaper_data(wallid, wall)) {
+ cur_wall = wall;
+ } else {
+ g_free(wall->filepath);
+ g_free(wall);
+ }
+ }
+
+ if(cur_wall) {
+ base = g_path_get_basename(cur_wall->filepath);
+ msg = g_strdup_printf("%s: %dx%d", base, cur_wall->width, cur_wall->height);
+ gtk_statusbar_push(statusbar, image_context, msg);
+ g_free(base);
+ g_free(msg);
+ }
+
resize_pixbuf();
}
@@ -225,8 +256,7 @@ void on_add_dir_action_activate(GtkAction *action, gpointer user_data) {
g_warning("%s", error->message);
g_free(error);
}
- } else
- printf("no directory selected\n");
+ }
gtk_widget_destroy(dialog);
}
@@ -273,6 +303,7 @@ int gui_main(int argc, char **argv) {
g_signal_connect(window_hpane, "notify::position", G_CALLBACK(on_window_hpane_resized), window_hpane);
statusbar = GTK_STATUSBAR(gtk_builder_get_object(builder, "statusbar"));
+ image_context = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "Image display");
gtk_builder_connect_signals(builder, NULL);