Esempio n. 1
0
static void set_conv_window_trans(PidginWindow *oldwin, PidginWindow *newwin) {
	GtkWidget *win = newwin->window;

	/* check prefs to see if we want trans */
	if (purple_prefs_get_bool(OPT_WINTRANS_IM_ENABLED)) {
		set_wintrans(win, purple_prefs_get_int(OPT_WINTRANS_IM_ALPHA),
			TRUE, purple_prefs_get_bool(OPT_WINTRANS_IM_ONTOP));

		if (purple_prefs_get_bool(OPT_WINTRANS_IM_SLIDER)) {
			add_slider(win);
		}
	}

	/* If we're moving from one window to another,
	 * add the focus listeners to the new window if not already there */
	if (oldwin != NULL && oldwin != newwin) {
		if (pidgin_conv_window_get_gtkconv_count(newwin) == 0) {
			g_signal_connect(G_OBJECT(win), "focus_in_event",
				G_CALLBACK(focus_conv_win_cb), win);
			g_signal_connect(G_OBJECT(win), "focus_out_event",
				G_CALLBACK(focus_conv_win_cb), win);
		}

		/* If we've moved the last conversation, cleanup the window */
		if (pidgin_conv_window_get_gtkconv_count(oldwin) == 1)
			cleanup_conv_window(oldwin);
	}
}
Esempio n. 2
0
static void
conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) {
	PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
	PidginWindow *win = pidgin_conv_get_window(pconv);

	if (type == PURPLE_CONV_UPDATE_UNSEEN && !pidgin_conv_is_hidden(pconv)
			&& pconv->unseen_state == PIDGIN_UNSEEN_NONE
			&& pidgin_conv_window_get_gtkconv_count(win) == 1) {
		GtkWidget *window = win->window;
		gboolean has_focus;

		g_object_get(G_OBJECT(window), "has-toplevel-focus", &has_focus, NULL);

		if (!has_focus || !purple_prefs_get_bool(OPT_WINTRANS_IM_ONFOCUS))
			set_conv_window_trans(NULL, win);

		if (g_signal_handler_find(G_OBJECT(window), G_SIGNAL_MATCH_FUNC,
				0, 0, NULL, G_CALLBACK(focus_conv_win_cb), NULL) == 0) {
			g_signal_connect(G_OBJECT(window), "focus_in_event",
				G_CALLBACK(focus_conv_win_cb), window);
			g_signal_connect(G_OBJECT(window), "focus_out_event",
				G_CALLBACK(focus_conv_win_cb), window);
		}
	}
}
Esempio n. 3
0
static void
conversation_delete_cb(PurpleConversation *conv) {
	PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
	/* If it is the last conversation in the window, cleanup */
	if (win != NULL && pidgin_conv_window_get_gtkconv_count(win) == 1)
		cleanup_conv_window(win);
}
Esempio n. 4
0
/**
 * A callback for when a conversation is opened
 *
 * This will simply remove the instructions tab when a conversation is opened
 * in a notebook that is displaying it.
 *
 * @param[in] conv       The new conversation
**/
static void conversation_created_cb(PurpleConversation *conv)
{
	PidginConversation *gtkconv; /*< The new Pidgin conversation */
	PidginBuddyList *gtkblist; /*< The Buddy List associated with conv */
	PidginWindow *gtkconvwin; /*< The conversation window that owns conv */

	if (conv == NULL)
		return;

	gtkconv = PIDGIN_CONVERSATION(conv);
	gtkconvwin = pidgin_conv_get_window(gtkconv);
	gtkblist = pwm_convs_get_blist(gtkconvwin);

	/* Sanity check: This callback should only continue for merged windows.
	 */
	if (gtkblist == NULL)
		return;

	/* If there is a tab in addition to the instructions tab, remove it. */
	if (pidgin_conv_window_get_gtkconv_count(gtkconvwin) > 1) {
		pwm_hide_dummy_conversation(gtkblist);
		pwm_set_conv_menus_visible(gtkblist, TRUE);

		/* Process queued focus events, and focus the conversation entry
		 * field. */
		while (gtk_events_pending())
			gtk_main_iteration();
		gtk_widget_grab_focus(gtkconv->entry);
	}
}
Esempio n. 5
0
/**
 * A callback for when a conversation is being closed
 *
 * This is only used to display help, hide conversation menu items, and reset
 * the window title when the last conversation in the Buddy List window is
 * being closed.
 *
 * @param[in] conv       The conversation on its way out the door
**/
static void deleting_conversation_cb(PurpleConversation *conv)
{
	PidginBuddyList *gtkblist; /*< The Buddy List associated with conv */
	PidginWindow *gtkconvwin; /*< The conversation window that owns conv */

	if (conv == NULL)
		return;

	gtkconvwin = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));
	gtkblist = pwm_convs_get_blist(gtkconvwin);

	/* Sanity check: This callback should only continue for merged windows.
	 */
	if (gtkblist == NULL)
		return;

	/* If the last conv is being deleted, reset help, icons, title, and
	 * menu. */
	if (pidgin_conv_window_get_gtkconv_count(gtkconvwin) <= 1) {
		pwm_show_dummy_conversation(gtkblist);
		gtk_window_set_icon_list(GTK_WINDOW(gtkblist->window), NULL);
		gtk_window_set_title(GTK_WINDOW(gtkblist->window),
				     pwm_fetch(gtkblist, "title"));
		pwm_set_conv_menus_visible(gtkblist, FALSE);
	}
}
Esempio n. 6
0
static void
conv_placement_by_number(PidginConversation *conv)
{
	PidginWindow *win = NULL;
	GList *wins = NULL;

	if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate"))
		win = pidgin_conv_window_last_with_type(purple_conversation_get_type(conv->active_conv));
	else if ((wins = pidgin_conv_windows_get_list()) != NULL)
		win = g_list_last(wins)->data;

	if (win == NULL) {
		win = pidgin_conv_window_new();

		pidgin_conv_window_add_gtkconv(win, conv);
		pidgin_conv_window_show(win);
	} else {
		int max_count = purple_prefs_get_int("/plugins/gtk/extplacement/placement_number");
		int count = pidgin_conv_window_get_gtkconv_count(win);

		if (count < max_count)
			pidgin_conv_window_add_gtkconv(win, conv);
		else {
			GList *l = NULL;

			for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) {
				win = l->data;

				if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
					purple_conversation_get_type(pidgin_conv_window_get_active_conversation(win)) != purple_conversation_get_type(conv->active_conv))
					continue;

				count = pidgin_conv_window_get_gtkconv_count(win);
				if (count < max_count) {
					pidgin_conv_window_add_gtkconv(win, conv);
					return;
				}
			}
			win = pidgin_conv_window_new();

			pidgin_conv_window_add_gtkconv(win, conv);
			pidgin_conv_window_show(win);
		}
	}
}
Esempio n. 7
0
static void
new_conversation_cb(PurpleConversation *conv) {
	PidginWindow *win = pidgin_conv_get_window(PIDGIN_CONVERSATION(conv));

	/* If it is the first conversation in the window,
	 * add the sliders, and set transparency */
	if (!pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv)) && pidgin_conv_window_get_gtkconv_count(win) == 1) {
		GtkWidget *window = win->window;

		set_conv_window_trans(NULL, win);

		g_signal_connect(G_OBJECT(window), "focus_in_event",
			G_CALLBACK(focus_conv_win_cb), window);
		g_signal_connect(G_OBJECT(window), "focus_out_event",
			G_CALLBACK(focus_conv_win_cb), window);
	}
}
Esempio n. 8
0
static void
stroke_new_win(GtkWidget *widget, void *data)
{
	PidginWindow *new_win, *old_win;
	PurpleConversation *conv;

	conv    = (PurpleConversation *)data;
	old_win = PIDGIN_CONVERSATION(conv)->win;

	if (pidgin_conv_window_get_gtkconv_count(old_win) <= 1)
		return;

	new_win = pidgin_conv_window_new();

	pidgin_conv_window_remove_gtkconv(old_win, PIDGIN_CONVERSATION(conv));
	pidgin_conv_window_add_gtkconv(new_win, PIDGIN_CONVERSATION(conv));

	pidgin_conv_window_show(new_win);
}
Esempio n. 9
0
static PurpleCmdRet
irssi_window_cmd(PurpleConversation *conv, const gchar *sub_cmd,
				 gchar **error)
{
	PidginConversation *gtkconv;
	PidginWindow *win;
	gint cur;

	gtkconv = PIDGIN_CONVERSATION(conv);
	win = gtkconv->win;
	cur = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook));

	/* if the sub_cmd is a number, or starts with one, assume the user wants
	 * to switch to a specific numbered tab */
	if(g_ascii_isdigit(*sub_cmd)) {
		gint tab = atoi(sub_cmd) - 1; /* index starts at zero */

		if(tab < 0) {
			*error = g_strdup(_("Invalid window specified."));

			return PURPLE_CMD_RET_FAILED;
		}

		if(tab < pidgin_conv_window_get_gtkconv_count(win))
			gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), tab);

		return PURPLE_CMD_RET_OK;
	}

	if(!g_ascii_strcasecmp(sub_cmd, "close")) {
		g_timeout_add(50, (GSourceFunc)irssi_window_close_cb, conv);

		return PURPLE_CMD_RET_OK;
	} else if(!g_ascii_strcasecmp(sub_cmd, "next") ||
			  !g_ascii_strcasecmp(sub_cmd, "right"))
	{
		if(!pidgin_conv_window_get_gtkconv_at_index(win, cur + 1)) {
			/* wrap around... */
			gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0);
		} else {
			/* move normally */
			gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook),
										  cur + 1);
		}

		return PURPLE_CMD_RET_OK;
	} else if(!g_ascii_strcasecmp(sub_cmd, "previous") ||
			  !g_ascii_strcasecmp(sub_cmd, "prev") ||
			  !g_ascii_strcasecmp(sub_cmd, "left"))
	{
		if(!pidgin_conv_window_get_gtkconv_at_index(win, cur - 1)) {
			/* wrap around... */
			gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1);
		} else {
			gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook),
										  cur - 1);
		}

		return PURPLE_CMD_RET_OK;
	} else {
		*error = g_strdup(_("Invalid argument!"));

		return PURPLE_CMD_RET_FAILED;
	}

	*error = g_strdup(_("Unknown Error!"));
	return PURPLE_CMD_RET_FAILED;
}