summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-10-25 01:11:15 -0400
committerSøren Sandmann <sandmann@redhat.com>2008-10-25 01:11:15 -0400
commit2468310301525f5e7d5f13725654bd8bbd0efa8d (patch)
treee9f5232b8c00900f6b25d1b7a6adb101c13f4625
parent7b6f2ae288b1f61242c14898070b2d1254000307 (diff)
parent1d037a7f99db074a85fd99529dba5797e7d0d0bd (diff)
Fix conflicts
-rw-r--r--Makefile.am32
-rw-r--r--TODO2
-rw-r--r--icons/16x16/siv.pngbin0 -> 929 bytes
-rw-r--r--icons/22x22/siv.pngbin0 -> 1212 bytes
-rw-r--r--icons/24x24/siv.pngbin0 -> 1247 bytes
-rw-r--r--icons/32x32/siv.pngbin0 -> 2472 bytes
-rw-r--r--icons/48x48/siv.pngbin0 -> 4597 bytes
-rw-r--r--icons/64x64/siv.pngbin0 -> 7081 bytes
-rw-r--r--icons/96x96/siv.pngbin0 -> 13571 bytes
-rw-r--r--siv.c21
-rw-r--r--siv.h1
-rw-r--r--window.c58
12 files changed, 94 insertions, 20 deletions
diff --git a/Makefile.am b/Makefile.am
index 0d62197..b2253ea 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@
bin_PROGRAMS = siv
-siv_CFLAGS = $(DEPENDENCIES_CFLAGS) -DDATADIR=\"$(pkgdatadir)\"
+AM_CFLAGS = $(DEPENDENCIES_CFLAGS) -DDATADIR=\"$(pkgdatadir)\"
siv_LDADD = $(DEPENDENCIES_LIBS)
siv_SOURCES = \
@@ -32,3 +32,33 @@ dist_pkgdata_DATA = siv.glade
desktopdir = $(datadir)/applications
desktop_DATA = siv.desktop
+
+pixmaps16dir = $(datadir)/icons/hicolor/16x16/apps/
+pixmaps22dir = $(datadir)/icons/hicolor/22x22/apps/
+pixmaps24dir = $(datadir)/icons/hicolor/24x16/apps/
+pixmaps32dir = $(datadir)/icons/hicolor/32x32/apps/
+pixmaps48dir = $(datadir)/icons/hicolor/48x48/apps/
+pixmaps64dir = $(datadir)/icons/hicolor/64x64/apps/
+pixmaps96dir = $(datadir)/icons/hicolor/96x96/apps/
+
+dist_pixmaps16_DATA = icons/16x16/siv.png
+dist_pixmaps22_DATA = icons/22x22/siv.png
+dist_pixmaps24_DATA = icons/24x24/siv.png
+dist_pixmaps32_DATA = icons/32x32/siv.png
+dist_pixmaps48_DATA = icons/48x48/siv.png
+dist_pixmaps64_DATA = icons/64x64/siv.png
+dist_pixmaps96_DATA = icons/96x96/siv.png
+
+# Stolen from rhythmbox
+gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+
+install-data-hook: update-icon-cache
+uninstall-hook: update-icon-cache
+update-icon-cache:
+ @-if test -z "$(DESTDIR)"; then \
+ echo "Updating Gtk icon cache."; \
+ $(gtk_update_icon_cache); \
+ else \
+ echo "*** Icon cache not updated. After (un)install, run this:"; \
+ echo "*** $(gtk_update_icon_cache)"; \
+ fi
diff --git a/TODO b/TODO
index 321383f..b700021 100644
--- a/TODO
+++ b/TODO
@@ -32,6 +32,8 @@
Done:
+- Icon
+
- If more than one instance of the application is
open, then things go haywrite.
diff --git a/icons/16x16/siv.png b/icons/16x16/siv.png
new file mode 100644
index 0000000..a78d1e1
--- /dev/null
+++ b/icons/16x16/siv.png
Binary files differ
diff --git a/icons/22x22/siv.png b/icons/22x22/siv.png
new file mode 100644
index 0000000..f71386d
--- /dev/null
+++ b/icons/22x22/siv.png
Binary files differ
diff --git a/icons/24x24/siv.png b/icons/24x24/siv.png
new file mode 100644
index 0000000..45950db
--- /dev/null
+++ b/icons/24x24/siv.png
Binary files differ
diff --git a/icons/32x32/siv.png b/icons/32x32/siv.png
new file mode 100644
index 0000000..099f76d
--- /dev/null
+++ b/icons/32x32/siv.png
Binary files differ
diff --git a/icons/48x48/siv.png b/icons/48x48/siv.png
new file mode 100644
index 0000000..f16bfcd
--- /dev/null
+++ b/icons/48x48/siv.png
Binary files differ
diff --git a/icons/64x64/siv.png b/icons/64x64/siv.png
new file mode 100644
index 0000000..15332da
--- /dev/null
+++ b/icons/64x64/siv.png
Binary files differ
diff --git a/icons/96x96/siv.png b/icons/96x96/siv.png
new file mode 100644
index 0000000..2e0cece
--- /dev/null
+++ b/icons/96x96/siv.png
Binary files differ
diff --git a/siv.c b/siv.c
index 7820ca3..e992732 100644
--- a/siv.c
+++ b/siv.c
@@ -10,7 +10,9 @@
struct App
{
- int n_windows;
+ int n_windows;
+
+ GtkWidget * chooser;
};
void
@@ -93,6 +95,23 @@ app_unregister_window (App *app, SivWindow *window)
gtk_main_quit ();
}
+GtkWidget *
+app_get_open_chooser (App *app)
+{
+ if (!app->chooser)
+ {
+ app->chooser =
+ gtk_file_chooser_dialog_new ("Open",
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+ }
+
+ return app->chooser;
+}
+
static gchar *
encode (const char *filename)
{
diff --git a/siv.h b/siv.h
index 6c5905a..0ec92c6 100644
--- a/siv.h
+++ b/siv.h
@@ -53,6 +53,7 @@ void app_set_meta_data (App *data,
int zoom_level,
int vadj,
int hadj);
+GtkWidget *app_get_open_chooser (App *app);
/* Doesn't really belong in the app namespace */
void app_show_warning (GtkWidget *parent_window,
diff --git a/window.c b/window.c
index 43e15d0..3cea43d 100644
--- a/window.c
+++ b/window.c
@@ -356,6 +356,7 @@ rebuild (SivWindow *window)
{
int w, h;
GtkAdjustment *vadj, *hadj;
+ GdkPixbuf *scaled;
compute_size (window, &w, &h);
@@ -382,11 +383,33 @@ rebuild (SivWindow *window)
gtk_widget_set_size_request (get_widget (window, "drawing_area"), w, h);
+ /* The documentation for gtk_window_set_icon() says you shouldn't scale
+ * the icon before passing it, but gdk_window_set_icon_list() ends up
+ * issuing g_warnings if the icon is too big.
+ */
+ if (gdk_pixbuf_get_width (window->original) >= 32 ||
+ gdk_pixbuf_get_height (window->original) >= 32)
+ {
+ scaled = gdk_pixbuf_scale_simple (window->original, 32, 32, GDK_INTERP_BILINEAR);
+ }
+ else
+ {
+ scaled = g_object_ref (window->original);
+ }
+
+ gtk_window_set_icon (get_widget (window, "main_window"), scaled);
+
+ g_object_unref (scaled);
+
gtk_widget_show (get_widget (window, "scrolled_window"));
window->width = w;
window->height = h;
}
+ else
+ {
+ gtk_window_set_icon_name (get_widget (window, "main_window"), "siv");
+ }
set_title (window);
set_sensitivity (window);
@@ -729,9 +752,8 @@ set_busy (GtkWidget *widget,
}
static void
-add_image_filters (GtkWidget *dialog)
+add_image_filters (GtkFileChooser *chooser)
{
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
GtkFileFilter *filter;
filter = gtk_file_filter_new ();
@@ -750,30 +772,25 @@ on_open (GtkWidget *widget, gpointer data)
{
SivWindow *window = data;
gchar *filename = NULL;
- GtkWidget *dialog;
+ GtkFileChooser *chooser;
set_busy (get_widget (window, "main_window"), TRUE);
- dialog = gtk_file_chooser_dialog_new ("Open",
- get_widget (window, "main_window"),
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- add_image_filters (dialog);
+ chooser = GTK_FILE_CHOOSER (app_get_open_chooser (window->app));
+ gtk_window_set_transient_for (GTK_WINDOW (chooser),
+ get_widget (window, "main_window"));
+ gtk_window_set_modal (GTK_WINDOW (chooser), TRUE);
- gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ add_image_filters (chooser);
set_busy (get_widget (window, "main_window"), FALSE);
retry:
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_ACCEPT)
{
GError *err = NULL;
SivWindow *target;
gboolean success;
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
if (window->original)
target = window_new (window->app);
@@ -796,11 +813,11 @@ retry:
filename = tmp;
}
- set_busy (dialog, TRUE);
+ set_busy (GTK_WIDGET (chooser), TRUE);
success = window_load_file (target, filename, &err);
- set_busy (dialog, FALSE);
+ set_busy (GTK_WIDGET (chooser), FALSE);
if (success)
{
@@ -824,7 +841,7 @@ retry:
goto retry;
}
- gtk_widget_destroy (dialog);
+ gtk_widget_hide (GTK_WIDGET (chooser));
}
static void
@@ -836,6 +853,7 @@ on_about (GtkWidget *widget, gpointer data)
gtk_show_about_dialog (get_widget (window, "main_window"),
"program-name", APPLICATION_NAME,
"copyright", "Copyright 2008, S"OSLASH"ren Sandmann",
+ "logo-icon-name", "siv",
"version", PACKAGE_VERSION,
NULL);
}
@@ -929,8 +947,12 @@ set_defaults (SivWindow *window)
if (height > monitor.height)
height = monitor.height - 32;
+
+ if (GTK_WIDGET_REALIZED (get_widget (window, "main_window")))
+ gtk_window_resize (get_widget (window, "main_window"), width, height);
+ else
+ gtk_window_set_default_size (get_widget (window, "main_window"), width, height);
- gtk_window_set_default_size (get_widget (window, "main_window"), width, height);
gtk_window_move (get_widget (window, "main_window"),
(monitor.width - width) / 2,
(monitor.height - height) / 2);