⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notify.c

📁 Linux下的多协议即时通讯程序源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
		entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id));		id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "focus-in-event",		                      G_CALLBACK(unnotify_cb), conv);		imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id));	}	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_click")) {		/* TODO similarly should really find a way to allow for		 * clicking in other places of the window */		id = g_signal_connect(G_OBJECT(gtkconv->entry), "button-press-event",		                      G_CALLBACK(unnotify_cb), conv);		entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id));		id = g_signal_connect(G_OBJECT(gtkconv->imhtml), "button-press-event",		                      G_CALLBACK(unnotify_cb), conv);		imhtml_ids = g_slist_append(imhtml_ids, GUINT_TO_POINTER(id));	}	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_type")) {		id = g_signal_connect(G_OBJECT(gtkconv->entry), "key-press-event",		                      G_CALLBACK(unnotify_cb), conv);		entry_ids = g_slist_append(entry_ids, GUINT_TO_POINTER(id));	}	purple_conversation_set_data(conv, "notify-imhtml-signals", imhtml_ids);	purple_conversation_set_data(conv, "notify-entry-signals", entry_ids);	return 0;}static voiddetach_signals(PurpleConversation *conv){	PidginConversation *gtkconv = NULL;	PidginWindow *gtkwin = NULL;	GSList *ids = NULL, *l;	gtkconv = PIDGIN_CONVERSATION(conv);	if (!gtkconv)		return;	gtkwin  = gtkconv->win;	ids = purple_conversation_get_data(conv, "notify-imhtml-signals");	for (l = ids; l != NULL; l = l->next)		g_signal_handler_disconnect(gtkconv->imhtml, GPOINTER_TO_INT(l->data));	g_slist_free(ids);	ids = purple_conversation_get_data(conv, "notify-entry-signals");	for (l = ids; l != NULL; l = l->next)		g_signal_handler_disconnect(gtkconv->entry, GPOINTER_TO_INT(l->data));	g_slist_free(ids);	purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0));	purple_conversation_set_data(conv, "notify-imhtml-signals", NULL);	purple_conversation_set_data(conv, "notify-entry-signals", NULL);}static voidconv_created(PurpleConversation *conv){	purple_conversation_set_data(conv, "notify-message-count",	                           GINT_TO_POINTER(0));	/* always attach the signals, notify() will take care of conversation	 * type checking */	attach_signals(conv);}static voidconv_switched(PurpleConversation *conv){#if 0	PidginWindow *purplewin = purple_conversation_get_window(new_conv);#endif	/*	 * If the conversation was switched, then make sure we re-notify	 * because Purple will have overwritten our custom window title.	 */	notify(conv, FALSE);#if 0	printf("conv_switched - %p - %p\n", old_conv, new_conv);	printf("count - %d\n", count_messages(purplewin));	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/notify_switch"))		unnotify(new_conv, FALSE);	else {		/* if we don't have notification on the window then we don't want to		 * re-notify it */		if (count_messages(purplewin))			notify_win(purplewin);	}#endif}static voiddeleting_conv(PurpleConversation *conv){	PidginWindow *purplewin = NULL;	detach_signals(conv);	purplewin = PIDGIN_CONVERSATION(conv)->win;	handle_urgent(purplewin, FALSE);	purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(0));	return;#if 0	/* i think this line crashes */	if (count_messages(purplewin))		notify_win(purplewin);#endif}#if 0static voidconversation_dragging(PurpleConversation *active_conv,                        PidginWindow *old_purplewin,                        PidginWindow *new_purplewin){	if (old_purplewin != new_purplewin) {		if (old_purplewin == NULL) {			/*			purple_conversation_autoset_title(active_conv);			handle_urgent(new_purplewin, FALSE);				*/			if (count_messages(new_purplewin))				notify_win(new_purplewin);		} else {			printf("if else count = %d\n", count_messages(new_purplewin));			printf("if else count = %d\n", count_messages(old_purplewin));			/*			PurpleConversation *old_active_conv = NULL;			old_active_conv = purple_conv_window_get_active_conversation(new_purplewin);			purple_conversation_autoset_title(old_active_conv);			handle_urgent(old_purplewin, FALSE);			if (count_messages(old_purplewin))				notify_win(old_purplewin);			purple_conversation_autoset_title(active_conv);			handle_urgent(new_purplewin, FALSE);			if (count_messages(new_purplewin))				notify_win(new_purplewin);				*/		}	} else {		printf("else count = %d\n", count_messages(new_purplewin));		printf("else count = %d\n", count_messages(old_purplewin));		/*		purple_conversation_autoset_title(active_conv);		handle_urgent(old_purplewin, FALSE);		if (count_messages(old_purplewin))			notify_win(old_purplewin);			*/	}}#endifstatic voidhandle_string(PidginWindow *purplewin){	GtkWindow *window = NULL;	gchar newtitle[256];	g_return_if_fail(purplewin != NULL);	window = GTK_WINDOW(purplewin->window);	g_return_if_fail(window != NULL);	g_snprintf(newtitle, sizeof(newtitle), "%s%s",	           purple_prefs_get_string("/plugins/gtk/X11/notify/title_string"),	           gtk_window_get_title(window));	gtk_window_set_title(window, newtitle);}static voidhandle_count_title(PidginWindow *purplewin){	GtkWindow *window;	char newtitle[256];	g_return_if_fail(purplewin != NULL);	window = GTK_WINDOW(purplewin->window);	g_return_if_fail(window != NULL);	g_snprintf(newtitle, sizeof(newtitle), "[%d] %s",	           count_messages(purplewin), gtk_window_get_title(window));	gtk_window_set_title(window, newtitle);}static voidhandle_count_xprop(PidginWindow *purplewin){#ifndef _WIN32	guint count;	GtkWidget *window;	GdkWindow *gdkwin;	window = purplewin->window;	g_return_if_fail(window != NULL);	if (_PurpleUnseenCount == GDK_NONE) {		_PurpleUnseenCount = gdk_atom_intern("_PIDGIN_UNSEEN_COUNT", FALSE);	}	if (_Cardinal == GDK_NONE) {		_Cardinal = gdk_atom_intern("CARDINAL", FALSE);	}	count = count_messages(purplewin);	gdkwin = window->window;	gdk_property_change(gdkwin, _PurpleUnseenCount, _Cardinal, 32,	                    GDK_PROP_MODE_REPLACE, (guchar *) &count, 1);#endif}static voidhandle_urgent(PidginWindow *win, gboolean set){#ifndef _WIN32	pidgin_set_urgent(GTK_WINDOW(win->window), set);#endif}static voidhandle_raise(PidginWindow *purplewin){	pidgin_conv_window_raise(purplewin);}static voidtype_toggle_cb(GtkWidget *widget, gpointer data){	gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));	gchar pref[256];	g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s",	           (char *)data);	purple_prefs_set_bool(pref, on);}static voidmethod_toggle_cb(GtkWidget *widget, gpointer data){	gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));	gchar pref[256];	g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s",	           (char *)data);	purple_prefs_set_bool(pref, on);	if (!strcmp(data, "method_string")) {		GtkWidget *entry = g_object_get_data(G_OBJECT(widget), "title-entry");		gtk_widget_set_sensitive(entry, on);		purple_prefs_set_string("/plugins/gtk/X11/notify/title_string",		                      gtk_entry_get_text(GTK_ENTRY(entry)));	}	apply_method();}static voidnotify_toggle_cb(GtkWidget *widget, gpointer data){	gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));	gchar pref[256];	g_snprintf(pref, sizeof(pref), "/plugins/gtk/X11/notify/%s",	           (char *)data);	purple_prefs_set_bool(pref, on);	apply_notify();}static gbooleanoptions_entry_cb(GtkWidget *widget, GdkEventFocus *evt, gpointer data){	if (data == NULL)		return FALSE;	if (!strcmp(data, "method_string")) {		purple_prefs_set_string("/plugins/gtk/X11/notify/title_string",		                      gtk_entry_get_text(GTK_ENTRY(widget)));	}	apply_method();	return FALSE;}static voidapply_method(){	GList *convs;	PidginWindow *purplewin = NULL;	for (convs = purple_get_conversations(); convs != NULL;	     convs = convs->next) {		PurpleConversation *conv = (PurpleConversation *)convs->data;		/* remove notifications */		unnotify(conv, FALSE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -