+2003-12-14 Hans Breuer <hans@breuer.org>
+
+ * gtk/gtkprivate.h gtk/gtkmain.c : handle GTK_DATADIR
+ similar as the other filesystem placement 'constants' (dynamic
+ resolving on win32)
+
+ * gtk/gtkfilechooserwidget.c : handle file system to win32
+ renaming here as will
+ * gtk/gtkfilesystemwin32.c : implement render_icon
+
+ * gtk/gtk.def gdk/gdk.def : updated externals
+
+ * gdk/win32/gdkdisplay-win32.c : make it compile without
+ <multimon.h> - i.e. even older sdk
+
+ * gdk/win32/gdkevents-win32.c : match resize_timer_proc
+ with TIMERPROC prototype
+
+ * gdk/win32/gdkwindow-win32.c : older msvc does not know
+ BITMAPV5HEADER (from win xp) either
+
+ * gtk/gtkimmodule.c : make it compile even if GTK_LOCALEDIR is
+ not defined
+
+ * tests/testfilechooser.c : recent GLib crashes on
+ g_print ("%s", NULL) so avoid this
+
2003-12-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkselection-win32.c: Calls to OpenClipboard() must be
+2003-12-14 Hans Breuer <hans@breuer.org>
+
+ * gtk/gtkprivate.h gtk/gtkmain.c : handle GTK_DATADIR
+ similar as the other filesystem placement 'constants' (dynamic
+ resolving on win32)
+
+ * gtk/gtkfilechooserwidget.c : handle file system to win32
+ renaming here as will
+ * gtk/gtkfilesystemwin32.c : implement render_icon
+
+ * gtk/gtk.def gdk/gdk.def : updated externals
+
+ * gdk/win32/gdkdisplay-win32.c : make it compile without
+ <multimon.h> - i.e. even older sdk
+
+ * gdk/win32/gdkevents-win32.c : match resize_timer_proc
+ with TIMERPROC prototype
+
+ * gdk/win32/gdkwindow-win32.c : older msvc does not know
+ BITMAPV5HEADER (from win xp) either
+
+ * gtk/gtkimmodule.c : make it compile even if GTK_LOCALEDIR is
+ not defined
+
+ * tests/testfilechooser.c : recent GLib crashes on
+ g_print ("%s", NULL) so avoid this
+
2003-12-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkselection-win32.c: Calls to OpenClipboard() must be
+2003-12-14 Hans Breuer <hans@breuer.org>
+
+ * gtk/gtkprivate.h gtk/gtkmain.c : handle GTK_DATADIR
+ similar as the other filesystem placement 'constants' (dynamic
+ resolving on win32)
+
+ * gtk/gtkfilechooserwidget.c : handle file system to win32
+ renaming here as will
+ * gtk/gtkfilesystemwin32.c : implement render_icon
+
+ * gtk/gtk.def gdk/gdk.def : updated externals
+
+ * gdk/win32/gdkdisplay-win32.c : make it compile without
+ <multimon.h> - i.e. even older sdk
+
+ * gdk/win32/gdkevents-win32.c : match resize_timer_proc
+ with TIMERPROC prototype
+
+ * gdk/win32/gdkwindow-win32.c : older msvc does not know
+ BITMAPV5HEADER (from win xp) either
+
+ * gtk/gtkimmodule.c : make it compile even if GTK_LOCALEDIR is
+ not defined
+
+ * tests/testfilechooser.c : recent GLib crashes on
+ g_print ("%s", NULL) so avoid this
+
2003-12-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkselection-win32.c: Calls to OpenClipboard() must be
+2003-12-14 Hans Breuer <hans@breuer.org>
+
+ * gtk/gtkprivate.h gtk/gtkmain.c : handle GTK_DATADIR
+ similar as the other filesystem placement 'constants' (dynamic
+ resolving on win32)
+
+ * gtk/gtkfilechooserwidget.c : handle file system to win32
+ renaming here as will
+ * gtk/gtkfilesystemwin32.c : implement render_icon
+
+ * gtk/gtk.def gdk/gdk.def : updated externals
+
+ * gdk/win32/gdkdisplay-win32.c : make it compile without
+ <multimon.h> - i.e. even older sdk
+
+ * gdk/win32/gdkevents-win32.c : match resize_timer_proc
+ with TIMERPROC prototype
+
+ * gdk/win32/gdkwindow-win32.c : older msvc does not know
+ BITMAPV5HEADER (from win xp) either
+
+ * gtk/gtkimmodule.c : make it compile even if GTK_LOCALEDIR is
+ not defined
+
+ * tests/testfilechooser.c : recent GLib crashes on
+ g_print ("%s", NULL) so avoid this
+
2003-12-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkselection-win32.c: Calls to OpenClipboard() must be
+2003-12-14 Hans Breuer <hans@breuer.org>
+
+ * gtk/gtkprivate.h gtk/gtkmain.c : handle GTK_DATADIR
+ similar as the other filesystem placement 'constants' (dynamic
+ resolving on win32)
+
+ * gtk/gtkfilechooserwidget.c : handle file system to win32
+ renaming here as will
+ * gtk/gtkfilesystemwin32.c : implement render_icon
+
+ * gtk/gtk.def gdk/gdk.def : updated externals
+
+ * gdk/win32/gdkdisplay-win32.c : make it compile without
+ <multimon.h> - i.e. even older sdk
+
+ * gdk/win32/gdkevents-win32.c : match resize_timer_proc
+ with TIMERPROC prototype
+
+ * gdk/win32/gdkwindow-win32.c : older msvc does not know
+ BITMAPV5HEADER (from win xp) either
+
+ * gtk/gtkimmodule.c : make it compile even if GTK_LOCALEDIR is
+ not defined
+
+ * tests/testfilechooser.c : recent GLib crashes on
+ g_print ("%s", NULL) so avoid this
+
2003-12-14 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkselection-win32.c: Calls to OpenClipboard() must be
gdk_window_reparent
gdk_window_resize
gdk_window_scroll
+ gdk_window_set_accept_focus
gdk_window_set_back_pixmap
gdk_window_set_background
gdk_window_set_child_shapes
#include "gdk.h"
#include "gdkprivate-win32.h"
-#if defined(_MSC_VER) && (WINVER < 0x500)
+#define HAVE_MONITOR_INFO
+
+#if defined(_MSC_VER) && (WINVER < 0x500) && (WINVER > 0x0400)
#include <multimon.h>
+#elif (WINVER <= 0x0400)
+#undef HAVE_MONITOR_INFO
#endif
+#ifdef HAVE_MONITOR_INFO
typedef BOOL (WINAPI *t_EnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
typedef BOOL (WINAPI *t_GetMonitorInfoA)(HMONITOR, LPMONITORINFO);
static t_EnumDisplayMonitors p_EnumDisplayMonitors = NULL;
static t_GetMonitorInfoA p_GetMonitorInfoA = NULL;
+#endif
void
_gdk_windowing_set_default_display (GdkDisplay *display)
g_assert (_gdk_display == display);
}
+#ifdef HVAE_MONITOR_INFO
static BOOL CALLBACK
count_monitor (HMONITOR hmonitor,
HDC hdc,
return TRUE;
}
+#endif /* HAVE_MONITOR_INFO */
GdkDisplay *
gdk_display_open (const gchar *display_name)
_gdk_display = g_object_new (GDK_TYPE_DISPLAY, NULL);
_gdk_screen = g_object_new (GDK_TYPE_SCREEN, NULL);
+#ifdef HAVE_MONITOR_INFO
user32 = GetModuleHandle ("user32.dll");
g_assert (user32 != NULL);
#endif
}
else
+#endif /* HAVE_MONITOR_INFO */
{
RECT rect;
static gboolean in_ime_composition = FALSE;
static gboolean resizing = FALSE;
-static UINT_PTR resize_timer;
+static UINT resize_timer;
static int debug_indent = 0;
static VOID CALLBACK
resize_timer_proc (HWND hwnd,
UINT msg,
- UINT_PTR id,
+ UINT id,
DWORD time)
{
if (resizing)
#include "gdkprivate-win32.h"
#include "gdkinput-win32.h"
-#ifdef __MINGW32__
+#if defined __MINGW32__ || (WINVER < 0x0500)
typedef struct {
DWORD bV5Size;
LONG bV5Width;
gtk_combo_disable_activate
gtk_combo_get_type
gtk_combo_new
+ gtk_combo_box_entry_new_with_model
+ gtk_combo_box_new_with_model
gtk_combo_set_case_sensitive
gtk_combo_set_item_string
gtk_combo_set_popdown_strings
gtk_file_info_free
gtk_file_info_get_display_key
gtk_file_info_get_display_name
- gtk_file_info_get_icon_type
+; gtk_file_info_get_icon_type
gtk_file_info_get_is_folder
gtk_file_info_get_is_hidden
gtk_file_info_get_mime_type
gtk_file_info_get_size
gtk_file_info_get_type
gtk_file_info_new
- gtk_file_info_render_icon
+; gtk_file_info_render_icon
gtk_file_info_set_display_name
- gtk_file_info_set_icon_type
+; gtk_file_info_set_icon_type
gtk_file_info_set_is_folder
gtk_file_info_set_is_hidden
gtk_file_info_set_mime_type
gtk_file_system_path_to_filename
gtk_file_system_path_to_uri
gtk_file_system_remove_bookmark
- gtk_file_system_unix_get_type
- gtk_file_system_unix_new
gtk_file_system_uri_to_path
+ gtk_file_system_win32_get_type
+ gtk_file_system_win32_new
gtk_fixed_get_has_window
gtk_fixed_get_type
gtk_fixed_move
gtk_toolbar_set_tooltips
gtk_toolbar_space_style_get_type
gtk_toolbar_style_get_type
- gtk_toolbar_unhighlight_drop_location
gtk_toolbar_unset_icon_size
gtk_toolbar_unset_style
gtk_tooltips_data_get
#include "gtkfilechooserutils.h"
#ifdef G_OS_UNIX
#include "gtkfilesystemunix.h"
-#endif
-#ifdef G_OS_WIN32
+#else if defined G_OS_WIN32
#include "gtkfilesystemwin32.h"
#endif
#include "gtktypebuiltins.h"
gtk_widget_push_composite_child ();
if (!priv->file_system)
- priv->file_system = gtk_file_system_unix_new ();
+ {
+#if defined G_OS_UNIX
+ priv->file_system = gtk_file_system_unix_new ();
+#else if defined G_OS_WIN32
+ priv->file_system = gtk_file_system_win32_new ();
+#endif
+ }
priv->impl = _gtk_file_chooser_default_new (priv->file_system);
gtk_box_pack_start (GTK_BOX (object), priv->impl, TRUE, TRUE, 0);
#include "gtkfilesystemwin32.h"
#include "gtkintl.h"
#include "gtkstock.h"
+#include "gtkiconfactory.h"
#include <errno.h>
#include <stdio.h>
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <shellapi.h> /* ExtractAssociatedIcon */
#include <direct.h>
#include <io.h>
#define mkdir(p,m) _mkdir(p)
+#include <gdk/win32/gdkwin32.h> /* gdk_win32_hdc_get */
#else
#error "The implementation is win32 only yet."
#endif /* G_OS_WIN32 */
const gchar *uri);
static GtkFilePath * gtk_file_system_win32_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
+static GdkPixbuf *gtk_file_system_win32_render_icon (GtkFileSystem *file_system,
+ const GtkFilePath *path,
+ GtkWidget *widget,
+ gint pixel_size,
+ GError **error);
+
static gboolean gtk_file_system_win32_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
iface->path_to_filename = gtk_file_system_win32_path_to_filename;
iface->uri_to_path = gtk_file_system_win32_uri_to_path;
iface->filename_to_path = gtk_file_system_win32_filename_to_path;
+ iface->render_icon = gtk_file_system_win32_render_icon;
iface->add_bookmark = gtk_file_system_win32_add_bookmark;
iface->remove_bookmark = gtk_file_system_win32_remove_bookmark;
iface->list_bookmarks = gtk_file_system_win32_list_bookmarks;
gtk_file_info_set_display_name (info, filename);
}
+#if 0 /* it's dead in GtkFileSystemUnix.c, too */
if (GTK_FILE_INFO_ICON & types)
{
switch (dt)
g_assert_not_reached ();
}
}
+#endif
g_free (filename);
return info;
}
{
gchar *contents = NULL;
gsize len = 0;
- GList *entry;
+ GSList *entry;
FILE *f;
if (g_file_test (filename, G_FILE_TEST_EXISTS))
return ok;
}
+static GdkPixbuf*
+extract_icon (const char* filename)
+{
+ GdkPixbuf *pixbuf = NULL;
+ WORD iicon;
+ HICON hicon;
+
+ if (!filename || !filename[0])
+ return NULL;
+
+ hicon = ExtractAssociatedIcon (GetModuleHandle (NULL), filename, &iicon);
+ if (hicon > (HICON)1)
+ {
+ ICONINFO ii;
+
+ if (GetIconInfo (hicon, &ii))
+ {
+ SIZE size;
+ GdkPixmap *pixmap;
+ GdkGC *gc;
+ HDC hdc;
+
+ if (!GetBitmapDimensionEx (ii.hbmColor, &size))
+ g_warning ("GetBitmapDimensionEx failed.");
+
+ if (size.cx < 1) size.cx = 32;
+ if (size.cy < 1) size.cy = 32;
+
+ pixmap = gdk_pixmap_new (NULL, size.cx, size.cy,
+ gdk_screen_get_system_visual (gdk_screen_get_default ())->depth);
+ gc = gdk_gc_new (pixmap);
+ hdc = gdk_win32_hdc_get (GDK_DRAWABLE (pixmap), gc, 0);
+
+ if (!DrawIcon (hdc, 0, 0, hicon))
+ g_warning ("DrawIcon failed");
+
+ gdk_win32_hdc_release (GDK_DRAWABLE (pixmap), gc, 0);
+
+ pixbuf = gdk_pixbuf_get_from_drawable (
+ NULL, pixmap,
+ gdk_screen_get_system_colormap (gdk_screen_get_default ()),
+ 0, 0, 0, 0, size.cx, size.cy);
+ g_object_unref (pixmap);
+ g_object_unref (gc);
+ }
+ else
+ g_print ("GetIconInfo failed: %s\n", g_win32_error_message (GetLastError ()));
+
+ if (!DestroyIcon (hicon))
+ g_warning ("DestroyIcon failed");
+ }
+ else
+ g_print ("ExtractAssociatedIcon failed: %s\n", g_win32_error_message (GetLastError ()));
+
+ return pixbuf;
+}
+
+static GtkIconSet *
+win32_pseudo_mime_lookup (const char* name)
+{
+ static GHashTable *mime_hash = NULL;
+ GtkIconSet *is = NULL;
+ char *p = strrchr(name, '.');
+ char *extension = p ? g_ascii_strdown (p, -1) : g_strdup ("");
+
+ if (!mime_hash)
+ mime_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* do we already have it ? */
+ is = g_hash_table_lookup (mime_hash, extension);
+ if (is)
+ {
+ g_free (extension);
+ return is;
+ }
+ /* create icon and set */
+ {
+ GdkPixbuf *pixbuf = extract_icon (name);
+ if (pixbuf)
+ {
+ GtkIconSource* source = gtk_icon_source_new ();
+
+ is = gtk_icon_set_new_from_pixbuf (pixbuf);
+ gtk_icon_source_set_pixbuf (source, pixbuf);
+ gtk_icon_set_add_source (is, source);
+
+ gtk_icon_source_free (source);
+ }
+
+ g_hash_table_insert (mime_hash, extension, is);
+ return is;
+ }
+}
+
+static GdkPixbuf *
+gtk_file_system_win32_render_icon (GtkFileSystem *file_system,
+ const GtkFilePath *path,
+ GtkWidget *widget,
+ gint pixel_size,
+ GError **error)
+{
+ GtkIconSet *icon_set = NULL;
+ const char* filename = gtk_file_path_get_string (path);
+
+ /* handle drives with stock icons */
+ if (filename_is_root (filename))
+ {
+ gchar *filename2 = g_strconcat(filename, "\\", NULL);
+ DWORD dt = GetDriveType (filename2);
+
+ switch (dt)
+ {
+ case DRIVE_REMOVABLE :
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_FLOPPY);
+ break;
+ case DRIVE_CDROM :
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_CDROM);
+ break;
+ case DRIVE_FIXED : /* need a hard disk icon */
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_CDROM);
+ break;
+ default :
+ break;
+ }
+ g_free (filename2);
+ }
+ else if (g_file_test (filename, G_FILE_TEST_IS_DIR))
+ {
+ if (0 == strcmp (g_get_home_dir(), filename))
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_HOME);
+ else
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_OPEN);
+ }
+ else if (g_file_test (filename, G_FILE_TEST_IS_EXECUTABLE))
+ {
+ /* don't lookup all executable icons */
+ icon_set = gtk_style_lookup_icon_set (widget->style, GTK_STOCK_EXECUTE);
+ }
+ else if (g_file_test (filename, G_FILE_TEST_EXISTS))
+ {
+ icon_set = win32_pseudo_mime_lookup (filename);
+ }
+
+ if (!icon_set)
+ {
+ g_set_error (error,
+ GTK_FILE_SYSTEM_ERROR,
+ GTK_FILE_SYSTEM_ERROR_FAILED,
+ _("This file system does not support icons for everything"));
+ return NULL;
+ }
+
+ // FIXME : I'd like to get from pixel_size (=20) back to
+ // icon size, which is an index, but there appears to be no way ?
+ return gtk_icon_set_render_icon (icon_set,
+ widget->style,
+ gtk_widget_get_direction (widget),
+ GTK_STATE_NORMAL,
+ GTK_ICON_SIZE_BUTTON,
+ widget, NULL);
+}
+
static GSList *_bookmarks = NULL;
static gboolean
GError **error)
{
GtkFileInfo *info;
+#if 0 /* it's dead in GtkFileSystemUnix.c, too */
GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
+#endif
WIN32_FILE_ATTRIBUTE_DATA wfad;
if (!GetFileAttributesEx (filename, GetFileExInfoStandard, &wfad))
gtk_file_info_set_is_folder (info, !!(wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
}
+#if 0 /* it's dead in GtkFileSystemUnix.c, too */
if (types & GTK_FILE_INFO_ICON)
{
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
gtk_file_info_set_icon_type (info, icon_type);
}
+#endif
- if ((types & GTK_FILE_INFO_MIME_TYPE) ||
- ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR))
+ if ((types & GTK_FILE_INFO_MIME_TYPE)
+#if 0 /* it's dead in GtkFileSystemUnix.c, too */
+ || ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR)
+#endif
+ )
{
#if 0
const char *mime_type = xdg_mime_get_mime_type_for_file (filename);
SIMPLE_ID,
N_("Default"),
GETTEXT_PACKAGE,
+#ifdef GTK_LOCALEDIR
GTK_LOCALEDIR,
+#else
+ "",
+#endif
""
};
G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
+const gchar *
+_gtk_get_datadir (void)
+{
+ static char *gtk_datadir = NULL;
+ if (gtk_datadir == NULL)
+ gtk_datadir = g_win32_get_package_installation_subdirectory
+ (GETTEXT_PACKAGE, dll_name, "share");
+
+ return gtk_datadir;
+}
+
const gchar *
_gtk_get_libdir (void)
{
#ifdef G_OS_WIN32
+const gchar *_gtk_get_datadir ();
const gchar *_gtk_get_libdir ();
const gchar *_gtk_get_sysconfdir ();
const gchar *_gtk_get_localedir ();
const gchar *_gtk_get_data_prefix ();
+#undef GTK_DATADIR
+#define GTK_DATADIR _gtk_get_datadir ()
#undef GTK_LIBDIR
#define GTK_LIBDIR _gtk_get_libdir ()
#undef GTK_LOCALEDIR
gchar *uri;
uri = gtk_file_chooser_get_current_folder_uri (chooser);
- g_print ("Current folder changed :\n %s\n", uri);
+ g_print ("Current folder changed :\n %s\n", uri ? uri : "(null)");
g_free (uri);
}