From d17a46454b3ff886b0a9834d1ee63056e1d007ba Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Wed, 23 Dec 2009 20:31:11 +0100 Subject: Show file name and image resolution in the status bar. --- window_main.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'window_main.c') 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); -- cgit v1.2.3