コード例 #1
0
ファイル: menu.c プロジェクト: dmilith/ekg2-bsd
void userlist_button_cb(GtkWidget *button, char *cmd) {
	int i, num_sel, using_allnicks = FALSE;
	char **nicks, *allnicks;
	char *nick = NULL;
	session *sess;

	sess = current_sess;

	if (strstr(cmd, "%a"))
		using_allnicks = TRUE;

	if (sess->type == SESS_DIALOG) {
		/* fake a selection */
		nicks = malloc(sizeof(char *) * 2);
		nicks[0] = g_strdup(sess->channel);
		nicks[1] = NULL;
		num_sel = 1;
	} else {
		/* find number of selected rows */
		nicks = userlist_selection_list(sess->gui->user_tree, &num_sel);
		if (num_sel < 1) {
			nick_command_parse(sess, cmd, "", "");
			return;
		}
	}

	/* create "allnicks" string */
	allnicks = malloc(((NICKLEN + 1) * num_sel) + 1);
	*allnicks = 0;

	i = 0;
	while (nicks[i]) {
		if (i > 0)
			strcat(allnicks, " ");
		strcat(allnicks, nicks[i]);

		if (!nick)
			nick = nicks[0];

		/* if not using "%a", execute the command once for each nickname */
		if (!using_allnicks)
			nick_command_parse(sess, cmd, nicks[i], "");

		i++;
	}

	if (using_allnicks) {
		if (!nick)
			nick = "";
		nick_command_parse(sess, cmd, nick, allnicks);
	}

	while (num_sel) {
		num_sel--;
		g_free(nicks[num_sel]);
	}

	free(nicks);
	free(allnicks);
}
コード例 #2
0
ファイル: menu.c プロジェクト: dmilith/ekg2-bsd
static void popup_menu_cb(GtkWidget *item, char *cmd) {
	char *nick;

	/* the userdata is set in menu_quick_item() */
	nick = g_object_get_data(G_OBJECT(item), "u");
#if 0
	if (!nick) {		/* userlist popup menu */
		/* treat it just like a userlist button */
		userlist_button_cb(NULL, cmd);
		return;
	}

	if (!current_sess)	/* for url grabber window */
		nick_command_parse(sess_list->data, cmd, nick, nick);
	else
		nick_command_parse(current_sess, cmd, nick, nick);
#endif
}
コード例 #3
0
ファイル: userlistgui.cpp プロジェクト: sehe/hexchat
static gint
userlist_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
{
	if (!event)
		return FALSE;

	if (!(event->state & STATE_CTRL) &&
		event->type == GDK_2BUTTON_PRESS && prefs.hex_gui_ulist_doubleclick[0])
	{
		auto nicks = userlist_selection_list (widget);
		if (!nicks.empty())
		{
			nick_command_parse (current_sess, prefs.hex_gui_ulist_doubleclick, nicks[0],
									  nicks[0]);
		}
		return TRUE;
	}

	if (event->button == 3)
	{
		/* do we have a multi-selection? */
		auto nicks = userlist_selection_list (widget);
		if (!nicks.empty())
		{
			menu_nickmenu (current_sess, event, nicks[0], nicks.size());
			return TRUE;
		}

		auto sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
		GtkTreePath *path;
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
			 event->x, event->y, &path, 0, 0, 0))
		{
			GtkTreePathPtr path_ptr(path);
			gtk_tree_selection_unselect_all (sel);
			gtk_tree_selection_select_path (sel, path);
			nicks = userlist_selection_list (widget);
			if (!nicks.empty())
			{
				menu_nickmenu (current_sess, event, nicks[0], nicks.size());
			}
		} else
		{
			gtk_tree_selection_unselect_all (sel);
		}

		return TRUE;
	}

	return FALSE;
}
コード例 #4
0
ファイル: userlistgui.c プロジェクト: AlexTheRose/hexchat
static gint
userlist_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
{
	char **nicks;
	int i;
	GtkTreeSelection *sel;
	GtkTreePath *path;

	if (!event)
		return FALSE;

	if (!(event->state & STATE_CTRL) &&
		event->type == GDK_2BUTTON_PRESS && prefs.hex_gui_ulist_doubleclick[0])
	{
		nicks = userlist_selection_list (widget, &i);
		if (nicks)
		{
			nick_command_parse (current_sess, prefs.hex_gui_ulist_doubleclick, nicks[0],
									  nicks[0]);
			while (i)
			{
				i--;
				g_free (nicks[i]);
			}
			free (nicks);
		}
		return TRUE;
	}

	if (event->button == 3)
	{
		/* do we have a multi-selection? */
		nicks = userlist_selection_list (widget, &i);
		if (nicks && i > 1)
		{
			menu_nickmenu (current_sess, event, nicks[0], i);
			while (i)
			{
				i--;
				g_free (nicks[i]);
			}
			free (nicks);
			return TRUE;
		}
		if (nicks)
		{
			g_free (nicks[0]);
			free (nicks);
		}

		sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
			 event->x, event->y, &path, 0, 0, 0))
		{
			gtk_tree_selection_unselect_all (sel);
			gtk_tree_selection_select_path (sel, path);
			gtk_tree_path_free (path);
			nicks = userlist_selection_list (widget, &i);
			if (nicks)
			{
				menu_nickmenu (current_sess, event, nicks[0], i);
				while (i)
				{
					i--;
					g_free (nicks[i]);
				}
				free (nicks);
			}
		} else
		{
			gtk_tree_selection_unselect_all (sel);
		}

		return TRUE;
	}

	return FALSE;
}