Replace pidgin_set_urgent with gtk_window_set_urgency_hint

Tue, 13 Oct 2020 00:42:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 13 Oct 2020 00:42:59 -0500
changeset 40555
0bf5825aab0a
parent 40554
e910eacdf9d9
child 40556
3fb07a4b34dd

Replace pidgin_set_urgent with gtk_window_set_urgency_hint

Testing Done:
Compiled and grepped for usage of the winpidgin functions that were removed.

Reviewed at https://reviews.imfreedom.org/r/161/

ChangeLog.API file | annotate | diff | comparison | revisions
pidgin/gtkblist.c file | annotate | diff | comparison | revisions
pidgin/gtknotify.c file | annotate | diff | comparison | revisions
pidgin/gtkutils.c file | annotate | diff | comparison | revisions
pidgin/gtkutils.h file | annotate | diff | comparison | revisions
pidgin/pidginapplication.c file | annotate | diff | comparison | revisions
pidgin/plugins/notify.c file | annotate | diff | comparison | revisions
pidgin/win32/gtkwin32dep.c file | annotate | diff | comparison | revisions
pidgin/win32/gtkwin32dep.h file | annotate | diff | comparison | revisions
--- a/ChangeLog.API	Mon Oct 12 23:44:21 2020 -0500
+++ b/ChangeLog.API	Tue Oct 13 00:42:59 2020 -0500
@@ -650,6 +650,7 @@
 		* pidgin_protocol_option_menu_get_selected
 		* pidgin_set_custom_buddy_icon
 		* pidgin_set_sensitive_if_input
+		* pidgin_set_urgent, use gtk_window_set_urgency_hint instead.
 		* pidgin_setup_screenname_autocomplete_with_filter
 		* pidgin_sound_get_event_label
 		* pidgin_sound_get_event_option
--- a/pidgin/gtkblist.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/gtkblist.c	Tue Oct 13 00:42:59 2020 -0500
@@ -4458,7 +4458,8 @@
 	gtkblist->headline_callback = NULL;
 	gtkblist->headline_data = NULL;
 	gtkblist->headline_destroy = NULL;
-	pidgin_set_urgent(GTK_WINDOW(gtkblist->window), FALSE);
+
+	gtk_window_set_urgency_hint(GTK_WINDOW(gtkblist->window), FALSE);
 }
 
 static gboolean
@@ -4965,7 +4966,7 @@
 {
 	if(event->in) {
 		gtk_blist_focused = TRUE;
-		pidgin_set_urgent(GTK_WINDOW(gtkblist->window), FALSE);
+		gtk_window_set_urgency_hint(GTK_WINDOW(gtkblist->window), FALSE);
 	} else {
 		gtk_blist_focused = FALSE;
 	}
@@ -6722,10 +6723,10 @@
 
 
 static void
-set_urgent(void)
-{
-	if (gtkblist->window && !gtk_widget_has_focus(gtkblist->window))
-		pidgin_set_urgent(GTK_WINDOW(gtkblist->window), TRUE);
+set_urgent(void) {
+	if(gtkblist->window && !gtk_widget_has_focus(gtkblist->window)) {
+		gtk_window_set_urgency_hint(GTK_WINDOW(gtkblist->window), TRUE);
+	}
 }
 
 PidginBuddyList *
--- a/pidgin/gtknotify.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/gtknotify.c	Tue Oct 13 00:42:59 2020 -0500
@@ -640,7 +640,7 @@
 static int
 mail_window_focus_cb(GtkWidget *widget, GdkEventFocus *focus, gpointer null)
 {
-	pidgin_set_urgent(GTK_WINDOW(widget), FALSE);
+	gtk_window_set_urgency_hint(GTK_WINDOW(widget), FALSE);
 	return 0;
 }
 
@@ -834,8 +834,9 @@
 				reset_mail_dialog);
 		mail_dialog->in_use = FALSE;
 		g_free(label_text);
-	} else if (!gtk_widget_has_focus(mail_dialog->dialog))
-		pidgin_set_urgent(GTK_WINDOW(mail_dialog->dialog), TRUE);
+	} else if(!gtk_widget_has_focus(mail_dialog->dialog)) {
+		gtk_window_set_urgency_hint(GTK_WINDOW(mail_dialog->dialog), TRUE);
+	}
 
 	return data;
 }
--- a/pidgin/gtkutils.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/gtkutils.c	Tue Oct 13 00:42:59 2020 -0500
@@ -1772,15 +1772,6 @@
 	return NULL;
 }
 
-void pidgin_set_urgent(GtkWindow *window, gboolean urgent)
-{
-#if defined _WIN32
-	winpidgin_window_flash(window, urgent);
-#else
-	gtk_window_set_urgency_hint(window, urgent);
-#endif
-}
-
 static void *
 pidgin_utils_get_handle(void)
 {
--- a/pidgin/gtkutils.h	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/gtkutils.h	Tue Oct 13 00:42:59 2020 -0500
@@ -509,16 +509,6 @@
 			const gchar *key, GtkTreeIter *iter, gpointer data);
 
 /**
- * pidgin_set_urgent:
- * @window:  The window to draw attention to
- * @urgent:  Whether to set the urgent hint or not
- *
- * Sets or resets a window to 'urgent,' by setting the URGENT hint in X
- * or blinking in the win32 taskbar
- */
-void pidgin_set_urgent(GtkWindow *window, gboolean urgent);
-
-/**
  * pidgin_get_dim_grey_string:
  * @widget:  The widget to return dim grey for
  *
--- a/pidgin/pidginapplication.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/pidginapplication.c	Tue Oct 13 00:42:59 2020 -0500
@@ -199,10 +199,6 @@
 	 */
 	gdk_notify_startup_complete();
 
-#ifdef _WIN32
-	winpidgin_post_init();
-#endif
-
 	/* TODO: Use GtkApplicationWindow or add a window instead */
 	g_application_hold(application);
 }
--- a/pidgin/plugins/notify.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/plugins/notify.c	Tue Oct 13 00:42:59 2020 -0500
@@ -565,7 +565,7 @@
 	g_return_if_fail(purplewin != NULL);
 	g_return_if_fail(purplewin->window != NULL);
 
-	pidgin_set_urgent(GTK_WINDOW(purplewin->window), set);
+	gtk_window_set_urgency_hint(GTK_WINDOW(purplewin->window), set);
 }
 
 static void
--- a/pidgin/win32/gtkwin32dep.c	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/win32/gtkwin32dep.c	Tue Oct 13 00:42:59 2020 -0500
@@ -293,95 +293,6 @@
 	return win_hwnd;
 }
 
-static gboolean stop_flashing(GtkWidget *widget, GdkEventFocus *event, gpointer data) {
-	GtkWindow *window = data;
-	gpointer handler_id;
-
-	winpidgin_window_flash(window, FALSE);
-
-	if ((handler_id = g_object_get_data(G_OBJECT(window), "flash_stop_handler_id"))) {
-		g_signal_handler_disconnect(G_OBJECT(window), (gulong) GPOINTER_TO_UINT(handler_id));
-		g_object_steal_data(G_OBJECT(window), "flash_stop_handler_id");
-	}
-
-	return FALSE;
-}
-
-void
-winpidgin_window_flash(GtkWindow *window, gboolean flash) {
-	GdkWindow * gdkwin;
-	FLASHWINFO info;
-
-	g_return_if_fail(window != NULL);
-
-	gdkwin = gtk_widget_get_window(GTK_WIDGET(window));
-
-	g_return_if_fail(GDK_IS_WINDOW(gdkwin));
-	g_return_if_fail(gdk_window_get_window_type(gdkwin) != GDK_WINDOW_CHILD);
-
-	if (gdk_window_is_destroyed(gdkwin))
-		return;
-
-	memset(&info, 0, sizeof(FLASHWINFO));
-	info.cbSize = sizeof(FLASHWINFO);
-	info.hwnd = GDK_WINDOW_HWND(gdkwin);
-	if (flash) {
-		DWORD flashCount;
-		info.uCount = 3;
-		if (SystemParametersInfo(SPI_GETFOREGROUNDFLASHCOUNT, 0, &flashCount, 0))
-			info.uCount = flashCount;
-		info.dwFlags = FLASHW_ALL | FLASHW_TIMER;
-	} else
-		info.dwFlags = FLASHW_STOP;
-	FlashWindowEx(&info);
-	info.dwTimeout = 0;
-
-}
-
-void
-winpidgin_conv_blink(PurpleConversation *conv) {
-	PidginConvWindow *win;
-	GtkWindow *window;
-
-	if(conv == NULL) {
-		purple_debug_info("winpidgin", "No conversation found to blink.\n");
-		return;
-	}
-
-	win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
-	if(win == NULL) {
-		purple_debug_info("winpidgin", "No conversation windows found to blink.\n");
-		return;
-	}
-	window = GTK_WINDOW(win->window);
-
-	/* Don't flash if the window is in the foreground */
-	if (GetForegroundWindow() ==
-		GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(window))))
-	{
-		return;
-	}
-
-	winpidgin_window_flash(window, TRUE);
-	/* Stop flashing when window receives focus */
-	if (g_object_get_data(G_OBJECT(window), "flash_stop_handler_id") == NULL) {
-		gulong handler_id = g_signal_connect(G_OBJECT(window), "focus-in-event",
-						     G_CALLBACK(stop_flashing), window);
-		g_object_set_data(G_OBJECT(window), "flash_stop_handler_id", GUINT_TO_POINTER(handler_id));
-	}
-}
-
-static gboolean
-winpidgin_conv_im_blink(PurpleConversation *conv, PurpleMessage *pmsg)
-{
-	/* Don't flash for our own messages or system messages */
-	if (purple_message_get_flags(pmsg) & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM))
-		return FALSE;
-	if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/win32/blink_im"))
-		winpidgin_conv_blink(conv);
-	return FALSE;
-}
-
 void winpidgin_init(void) {
 	typedef void (__cdecl* LPFNSETLOGFILE)(const LPCSTR);
 	LPFNSETLOGFILE MySetLogFile;
@@ -417,17 +328,6 @@
 		purple_debug_misc("winpidgin", "winpidgin_init end\n");
 }
 
-void winpidgin_post_init(void) {
-
-	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/win32");
-	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/win32/blink_im", TRUE);
-
-	purple_signal_connect(pidgin_conversations_get_handle(),
-		"displaying-im-msg", &gtkwin32_handle, PURPLE_CALLBACK(winpidgin_conv_im_blink),
-		NULL);
-
-}
-
 /* Windows Cleanup */
 
 void winpidgin_cleanup(void) {
--- a/pidgin/win32/gtkwin32dep.h	Mon Oct 12 23:44:21 2020 -0500
+++ b/pidgin/win32/gtkwin32dep.h	Tue Oct 13 00:42:59 2020 -0500
@@ -44,13 +44,10 @@
 /* Misc */
 void winpidgin_shell_execute(const char *target, const char *verb, const char *clazz);
 void winpidgin_ensure_onscreen(GtkWidget *win);
-void winpidgin_conv_blink(PurpleConversation *conv);
-void winpidgin_window_flash(GtkWindow *window, gboolean flash);
 DWORD winpidgin_get_lastactive(void);
 
 /* init / cleanup */
 void winpidgin_init(void);
-void winpidgin_post_init(void);
 void winpidgin_cleanup(void);
 
 #endif /* _GTKWIN32DEP_H_ */

mercurial