Mercurial > pidgin
comparison gtk/gtkutils.c @ 15347:03edbb70210f
[gaim-migrate @ 18140]
Update gaim_gtk_set_urgent to work on WIN32.
I also changed the function signature to take a GtkWindow instead of a GdkWindow so that we can use gtk_window_set_urgency_hint (only available on GTK >= 2.8.0).
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 16 Jan 2007 22:20:26 +0000 |
parents | 85a2aafc9c4b |
children | 804e69c8ce23 |
comparison
equal
deleted
inserted
replaced
15346:467244cc4ff2 | 15347:03edbb70210f |
---|---|
2218 | 2218 |
2219 struct _icon_chooser { | 2219 struct _icon_chooser { |
2220 GtkWidget *icon_filesel; | 2220 GtkWidget *icon_filesel; |
2221 GtkWidget *icon_preview; | 2221 GtkWidget *icon_preview; |
2222 GtkWidget *icon_text; | 2222 GtkWidget *icon_text; |
2223 | 2223 |
2224 void (*callback)(const char*,gpointer); | 2224 void (*callback)(const char*,gpointer); |
2225 gpointer data; | 2225 gpointer data; |
2226 }; | 2226 }; |
2227 | 2227 |
2228 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | 2228 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
2676 #endif | 2676 #endif |
2677 } | 2677 } |
2678 | 2678 |
2679 #if !GTK_CHECK_VERSION(2,6,0) | 2679 #if !GTK_CHECK_VERSION(2,6,0) |
2680 static void | 2680 static void |
2681 _gdk_file_scale_size_prepared_cb (GdkPixbufLoader *loader, | 2681 _gdk_file_scale_size_prepared_cb (GdkPixbufLoader *loader, |
2682 int width, | 2682 int width, |
2683 int height, | 2683 int height, |
2684 gpointer data) | 2684 gpointer data) |
2685 { | 2685 { |
2686 struct { | 2686 struct { |
2689 gboolean preserve_aspect_ratio; | 2689 gboolean preserve_aspect_ratio; |
2690 } *info = data; | 2690 } *info = data; |
2691 | 2691 |
2692 g_return_if_fail (width > 0 && height > 0); | 2692 g_return_if_fail (width > 0 && height > 0); |
2693 | 2693 |
2694 if (info->preserve_aspect_ratio && | 2694 if (info->preserve_aspect_ratio && |
2695 (info->width > 0 || info->height > 0)) { | 2695 (info->width > 0 || info->height > 0)) { |
2696 if (info->width < 0) | 2696 if (info->width < 0) |
2697 { | 2697 { |
2698 width = width * (double)info->height/(double)height; | 2698 width = width * (double)info->height/(double)height; |
2699 height = info->height; | 2699 height = info->height; |
2839 path = NULL; | 2839 path = NULL; |
2840 } | 2840 } |
2841 | 2841 |
2842 if (filename) { | 2842 if (filename) { |
2843 char *newfile; | 2843 char *newfile; |
2844 | 2844 |
2845 newfile = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), | 2845 newfile = gaim_gtk_convert_buddy_icon(gaim_find_prpl(gaim_account_get_protocol_id(account)), |
2846 filename); | 2846 filename); |
2847 path = gaim_buddy_icons_get_full_path(newfile); | 2847 path = gaim_buddy_icons_get_full_path(newfile); |
2848 g_free(newfile); | 2848 g_free(newfile); |
2849 } | 2849 } |
2874 g_strfreev(split); | 2874 g_strfreev(split); |
2875 | 2875 |
2876 return ret; | 2876 return ret; |
2877 } | 2877 } |
2878 | 2878 |
2879 void gaim_gtk_set_urgent(GdkWindow *window, gboolean urgent) | 2879 void gaim_gtk_set_urgent(GtkWindow *window, gboolean urgent) |
2880 { | 2880 { |
2881 #ifdef _WIN32 | 2881 #if GTK_CHECK_VERSION(2,8,0) |
2882 #error Hey, Daniel! Make this work! | 2882 gtk_window_set_urgency_hint(window, urgent) |
2883 #elif defined _WIN32 | |
2884 gtkwgaim_window_flash(window, urgent); | |
2883 #else | 2885 #else |
2886 GdkWindow *gdkwin; | |
2884 XWMHints *hints; | 2887 XWMHints *hints; |
2885 | 2888 |
2886 g_return_if_fail(window != NULL); | 2889 g_return_if_fail(window != NULL); |
2887 | 2890 |
2888 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(window), | 2891 gdkwin = GTK_WIDGET(window)->window; |
2889 GDK_WINDOW_XWINDOW(window)); | 2892 |
2893 g_return_if_fail(gdkwin != NULL); | |
2894 | |
2895 hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), | |
2896 GDK_WINDOW_XWINDOW(gdkwin)); | |
2890 if(!hints) | 2897 if(!hints) |
2891 hints = XAllocWMHints(); | 2898 hints = XAllocWMHints(); |
2892 | 2899 |
2893 if (urgent) | 2900 if (urgent) |
2894 hints->flags |= XUrgencyHint; | 2901 hints->flags |= XUrgencyHint; |
2895 else | 2902 else |
2896 hints->flags &= ~XUrgencyHint; | 2903 hints->flags &= ~XUrgencyHint; |
2897 XSetWMHints(GDK_WINDOW_XDISPLAY(window), | 2904 XSetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), |
2898 GDK_WINDOW_XWINDOW(window), hints); | 2905 GDK_WINDOW_XWINDOW(gdkwin), hints); |
2899 XFree(hints); | 2906 XFree(hints); |
2900 #endif | 2907 #endif |
2901 } | 2908 } |
2902 | 2909 |
2903 GSList *minidialogs = NULL; | 2910 GSList *minidialogs = NULL; |
2908 static int handle; | 2915 static int handle; |
2909 | 2916 |
2910 return &handle; | 2917 return &handle; |
2911 } | 2918 } |
2912 | 2919 |
2913 static void connection_signed_off_cb(GaimConnection *gc) | 2920 static void connection_signed_off_cb(GaimConnection *gc) |
2914 { | 2921 { |
2915 GSList *list; | 2922 GSList *list; |
2916 for (list = minidialogs; list; list = list->next) { | 2923 for (list = minidialogs; list; list = list->next) { |
2917 if (g_object_get_data(G_OBJECT(list->data), "gc") == gc) { | 2924 if (g_object_get_data(G_OBJECT(list->data), "gc") == gc) { |
2918 gtk_widget_destroy(GTK_WIDGET(list->data)); | 2925 gtk_widget_destroy(GTK_WIDGET(list->data)); |
2953 minidialogs = g_slist_prepend(minidialogs, vbox); | 2960 minidialogs = g_slist_prepend(minidialogs, vbox); |
2954 g_signal_connect(G_OBJECT(vbox), "destroy", G_CALLBACK(alert_killed_cb), NULL); | 2961 g_signal_connect(G_OBJECT(vbox), "destroy", G_CALLBACK(alert_killed_cb), NULL); |
2955 | 2962 |
2956 if (first_call) { | 2963 if (first_call) { |
2957 first_call = FALSE; | 2964 first_call = FALSE; |
2958 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", | 2965 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
2959 gaim_gtk_utils_get_handle(), | 2966 gaim_gtk_utils_get_handle(), |
2960 GAIM_CALLBACK(connection_signed_off_cb), NULL); | 2967 GAIM_CALLBACK(connection_signed_off_cb), NULL); |
2961 } | 2968 } |
2962 | 2969 |
2963 hbox = gtk_hbox_new(FALSE, 0); | 2970 hbox = gtk_hbox_new(FALSE, 0); |
2964 gtk_container_add(GTK_CONTAINER(vbox), hbox); | 2971 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
2965 | 2972 |
2966 if (img != NULL) | 2973 if (img != NULL) |
2967 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | 2974 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
2968 | 2975 |
2969 primary_esc = g_markup_escape_text(primary, -1); | 2976 primary_esc = g_markup_escape_text(primary, -1); |
2970 | 2977 |
2971 if (secondary) | 2978 if (secondary) |
2972 secondary_esc = g_markup_escape_text(secondary, -1); | 2979 secondary_esc = g_markup_escape_text(secondary, -1); |
2973 g_snprintf(label_text, sizeof(label_text), | 2980 g_snprintf(label_text, sizeof(label_text), |
2978 gtk_widget_set_size_request(label, gaim_prefs_get_int("/gaim/gtk/blist/width")-25,-1); | 2985 gtk_widget_set_size_request(label, gaim_prefs_get_int("/gaim/gtk/blist/width")-25,-1); |
2979 gtk_label_set_markup(GTK_LABEL(label), label_text); | 2986 gtk_label_set_markup(GTK_LABEL(label), label_text); |
2980 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 2987 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
2981 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 2988 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2982 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | 2989 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
2983 | 2990 |
2984 hbox2 = gtk_hbox_new(FALSE, 6); | 2991 hbox2 = gtk_hbox_new(FALSE, 6); |
2985 gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); | 2992 gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); |
2986 | 2993 |
2987 va_start(args, user_data); | 2994 va_start(args, user_data); |
2988 while ((button_text = va_arg(args, char*))) { | 2995 while ((button_text = va_arg(args, char*))) { |
2989 callback = va_arg(args, GCallback); | 2996 callback = va_arg(args, GCallback); |
2990 button = gtk_button_new(); | 2997 button = gtk_button_new(); |
2991 | 2998 |
2992 if (callback) | 2999 if (callback) |
2993 g_signal_connect_swapped(G_OBJECT(button), "clicked", callback, user_data); | 3000 g_signal_connect_swapped(G_OBJECT(button), "clicked", callback, user_data); |
2994 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), vbox); | 3001 g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), vbox); |
2995 hbox = gtk_hbox_new(FALSE, 0); | 3002 hbox = gtk_hbox_new(FALSE, 0); |
2996 gtk_container_add(GTK_CONTAINER(button), hbox); | 3003 gtk_container_add(GTK_CONTAINER(button), hbox); |