Exemplo n.º 1
0
void menu_nickmenu(window_t *sess, GdkEventButton * event, char *nick, int num_sel) {
	char buf[512];
	GtkWidget *menu = gtk_menu_new();
	userlist_t *user;

	if (str_copy)
		free(str_copy);
	str_copy = xstrdup(nick);

	submenu_list = NULL;	/* first time through, might not be 0 */		/* [XXX, how does this work? memleak? */
	/* more than 1 nick selected? */
	if (num_sel > 1) {
		snprintf(buf, sizeof(buf), "%d nicks selected.", num_sel);
		menu_quick_item(0, buf, menu, 0, 0, 0);
		menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0);
	} else {
		user = userlist_find(sess->session, nick);

		/* XXX,
		 *	jesli nadal nie ma uzytkownika, to szukaj go w konferencjach */

		if (user) {
			GtkWidget *submenu = menu_quick_sub(nick, menu, NULL, XCMENU_DOLIST, -1);

			char *fmt = "<tt><b>%-11s</b></tt> %s";			/* XXX, gettext? (let the translators tweak this if need be) */
			char *real;

		/* UID */
			real = g_markup_escape_text(user->uid, -1);
			snprintf(buf, sizeof(buf), fmt, "UID:", real);
			g_free(real);
			menu_quick_item(0, buf, submenu, XCMENU_MARKUP, 0, 0);

		/* <separator> ? */

		/* XXX, get more data using USERLIST_PRIVHANDLE (?) */
		/* the same like above */

			menu_quick_endsub();
			menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0);
		}
	}
#if 0
	if (num_sel > 1)
		menu_create(menu, popup_list, NULL, FALSE);
	else
		menu_create(menu, popup_list, str_copy, FALSE);

	if (num_sel == 0)	/* xtext click */
		menu_add_plugin_items(menu, "\x5$NICK", str_copy);
	else			/* userlist treeview click */
		menu_add_plugin_items(menu, "\x5$NICK", NULL);
#endif
	menu_popup(menu, event, NULL);
}
Exemplo n.º 2
0
static void
tray_menu_cb(GtkWidget *widget, guint button, guint time, gpointer userdata)
{
	GtkWidget *menu;
	GtkWidget *submenu;

	menu = gtk_menu_new ();
	/*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/

	if (tray_get_window_status() == WS_HIDDEN)
		tray_make_item (menu, _("_Restore"), tray_menu_restore_cb, NULL);
	else
		tray_make_item (menu, _("_Hide"), tray_menu_restore_cb, NULL);
	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);

	submenu = mg_submenu (menu, _("_Blink on"));
	blink_item (&prefs.input_tray_chans, submenu, _("Channel Message"));
	blink_item (&prefs.input_tray_priv, submenu, _("Private Message"));
	blink_item (&prefs.input_tray_hilight, submenu, _("Highlighted Message"));
	/*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/

	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
	mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL);

	menu_add_plugin_items (menu, "\x5$TRAY", NULL);

	g_object_ref (menu);
	g_object_ref_sink (menu);
	g_object_unref (menu);
	g_signal_connect (G_OBJECT (menu), "selection-done",
							G_CALLBACK (tray_menu_destroy), NULL);

	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu,
						 userdata, button, time);
}
Exemplo n.º 3
0
void
menu_chanmenu (struct session *sess, GdkEventButton * event, char *chan)
{
	GtkWidget *menu;
	int is_joined = FALSE;

	if (find_channel (sess->server, chan))
		is_joined = TRUE;

	if (str_copy)
		free (str_copy);
	str_copy = strdup (chan);

	menu = gtk_menu_new ();

	menu_quick_item (0, chan, menu, XCMENU_SHADED, str_copy, 0);
	menu_quick_item (0, 0, menu, XCMENU_SHADED, str_copy, 0);

	if (!is_joined)
		menu_quick_item_with_callback (menu_chan_join, _("Join Channel"), menu,
												 str_copy);
	else
	{
		menu_quick_item_with_callback (menu_chan_part, _("Part Channel"), menu,
												 str_copy);
		menu_quick_item_with_callback (menu_chan_cycle, _("Cycle Channel"), menu,
												 str_copy);
	}

	menu_add_plugin_items (menu, "\x5$CHAN", str_copy);
	menu_popup (menu, event, NULL);
}
Exemplo n.º 4
0
void menu_urlmenu(GdkEventButton * event, char *url) {
	GtkWidget *menu;
	char *tmp, *chop;

	if (str_copy)
		free(str_copy);
	str_copy = strdup(url);

	menu = gtk_menu_new();
	/* more than 51 chars? Chop it */
	if (g_utf8_strlen(str_copy, -1) >= 52) {
		tmp = strdup(str_copy);
		chop = g_utf8_offset_to_pointer(tmp, 48);
		chop[0] = chop[1] = chop[2] = '.';
		chop[3] = 0;
		menu_quick_item(0, tmp, menu, XCMENU_SHADED, 0, 0);
		free(tmp);
	} else {
		menu_quick_item(0, str_copy, menu, XCMENU_SHADED, 0, 0);
	}
	menu_quick_item(0, 0, menu, XCMENU_SHADED, 0, 0);

	/* Two hardcoded entries */
	if (strncmp(str_copy, "irc://", 6) == 0 || strncmp(str_copy, "ircs://", 7) == 0)
		menu_quick_item_with_callback(open_url_cb, _("Connect"), menu, str_copy);
	else
		menu_quick_item_with_callback(open_url_cb, _("Open Link in Browser"), menu,
					      str_copy);
	menu_quick_item_with_callback(copy_to_clipboard_cb, _("Copy Selected Link"), menu,
				      str_copy);
	/* custom ones from urlhandlers.conf */
	menu_create(menu, urlhandler_list, str_copy, TRUE);
	menu_add_plugin_items(menu, "\x4$URL", str_copy);
	menu_popup(menu, event, NULL);
}
Exemplo n.º 5
0
static void
tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata)
{
	GtkWidget *menu;
	GtkWidget *submenu;
	GtkWidget *item;
	int away_status;

	/* ph may have an invalid context now */
	xchat_set_context (ph, xchat_find_context (ph, NULL, NULL));

	menu = gtk_menu_new ();
	/*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/

	if (tray_get_window_status () == WS_HIDDEN)
		tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL);
	else
		tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL);
	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);

#ifndef WIN32 /* somehow this is broken on win32 */
	submenu = mg_submenu (menu, _("_Blink on"));
	blink_item (&prefs.input_tray_chans, submenu, _("Channel Message"));
	blink_item (&prefs.input_tray_priv, submenu, _("Private Message"));
	blink_item (&prefs.input_tray_hilight, submenu, _("Highlighted Message"));
	/*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/

	submenu = mg_submenu (menu, _("_Change status"));
	away_status = tray_find_away_status ();
	item = tray_make_item (submenu, _("_Away"), tray_foreach_server, "away");
	if (away_status == 1)
		gtk_widget_set_sensitive (item, FALSE);
	item = tray_make_item (submenu, _("_Back"), tray_foreach_server, "back");
	if (away_status == 2)
		gtk_widget_set_sensitive (item, FALSE);

	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
#endif

	mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL);

	menu_add_plugin_items (menu, "\x5$TRAY", NULL);

	g_object_ref (menu);
	g_object_ref_sink (menu);
	g_object_unref (menu);
	g_signal_connect (G_OBJECT (menu), "selection-done",
							G_CALLBACK (tray_menu_destroy), NULL);

	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, gtk_status_icon_position_menu,
						 userdata, button, time);
}
Exemplo n.º 6
0
static void
tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata)
{
	static GtkWidget *menu;
	GtkWidget *submenu;
	GtkWidget *item;
	int away_status;

	/* ph may have an invalid context now */
	hexchat_set_context (ph, hexchat_find_context (ph, NULL, NULL));

	/* close any old menu */
	if (G_IS_OBJECT (menu))
	{
		tray_menu_destroy (menu, NULL);
	}

	menu = gtk_menu_new ();
	/*gtk_menu_set_screen (GTK_MENU (menu), gtk_widget_get_screen (widget));*/

	if (tray_get_window_status () == WS_HIDDEN)
		tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL);
	else
		tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL);
	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);

#ifndef WIN32 /* submenus are buggy on win32 */
	submenu = mg_submenu (menu, _("_Blink on"));
	blink_item (&prefs.hex_input_tray_chans, submenu, _("Channel Message"));
	blink_item (&prefs.hex_input_tray_priv, submenu, _("Private Message"));
	blink_item (&prefs.hex_input_tray_hilight, submenu, _("Highlighted Message"));
	/*blink_item (BIT_FILEOFFER, submenu, _("File Offer"));*/

	submenu = mg_submenu (menu, _("_Change status"));
#else /* so show away/back in main tray menu */
	submenu = menu;
#endif

	away_status = tray_find_away_status ();
	item = tray_make_item (submenu, _("_Away"), tray_foreach_server, "away");
	if (away_status == 1)
		gtk_widget_set_sensitive (item, FALSE);
	item = tray_make_item (submenu, _("_Back"), tray_foreach_server, "back");
	if (away_status == 2)
		gtk_widget_set_sensitive (item, FALSE);

	menu_add_plugin_items (menu, "\x5$TRAY", NULL);
#ifdef WIN32
	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
	mg_create_icon_item (_("_Preferences"), GTK_STOCK_PREFERENCES, menu, tray_menu_settings, NULL);
#endif
	tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
	mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL);

	g_object_ref (menu);
	g_object_ref_sink (menu);
	g_object_unref (menu);
	g_signal_connect (G_OBJECT (menu), "selection-done",
							G_CALLBACK (tray_menu_destroy), NULL);
#ifdef WIN32
	g_signal_connect (G_OBJECT (menu), "leave-notify-event",
							G_CALLBACK (tray_menu_left_cb), NULL);
	g_signal_connect (G_OBJECT (menu), "enter-notify-event",
							G_CALLBACK (tray_menu_enter_cb), NULL);

	tray_menu_timer = g_timeout_add(500, (GSourceFunc) tray_check_hide, menu);
#endif

	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
						 userdata, button, time);
}
Exemplo n.º 7
0
void
menu_nickmenu (session *sess, GdkEventButton *event, char *nick, int num_sel)
{
	char buf[512];
	char *real, *fmt;
	struct User *user;
	struct away_msg *away;
	GtkWidget *submenu, *menu = gtk_menu_new ();

	if (str_copy)
		free (str_copy);
	str_copy = strdup (nick);

	submenu_list = 0;	/* first time through, might not be 0 */

	/* more than 1 nick selected? */
	if (num_sel > 1)
	{
		snprintf (buf, sizeof (buf), "%d nicks selected.", num_sel);
		menu_quick_item (0, buf, menu, 0, 0, 0);
		menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0);
	} else
	{
		user = userlist_find (sess, nick);	/* lasttalk is channel specific */
		if (!user)
			user = userlist_find_global (current_sess->server, nick);
		if (user)
		{
			submenu = menu_quick_sub (nick, menu, NULL, XCMENU_DOLIST, -1);

			/* let the translators tweak this if need be */
			fmt = _("<tt><b>%-11s</b></tt> %s");

			if (user->realname)
			{
				real = g_markup_escape_text (user->realname, -1);
				snprintf (buf, sizeof (buf), fmt, _("Real Name:"), real);
				g_free (real);
			} else
			{
				snprintf (buf, sizeof (buf), fmt, _("Real Name:"), _("Unknown"));
			}
			menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);

			snprintf (buf, sizeof (buf), fmt, _("User:"******"Unknown"));
			menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);

			snprintf (buf, sizeof (buf), fmt, _("Server:"),
						user->servername ? user->servername : _("Unknown"));
			menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);

			if (user->away)
			{
				away = server_away_find_message (current_sess->server, nick);
				if (away)
				{
					char *msg = strip_color (away->message ? away->message : _("Unknown"), -1, STRIP_ALL);
					real = g_markup_escape_text (msg, -1);
					free (msg);
					snprintf (buf, sizeof (buf), fmt, _("Away Msg:"), real);
					g_free (real);
					menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);
				}
			}

			if (user->lasttalk)
			{
				char min[96];

				snprintf (min, sizeof (min), _("%u minutes ago"),
							(unsigned int) ((time (0) - user->lasttalk) / 60));
				snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), min);
			} else
			{
				snprintf (buf, sizeof (buf), fmt, _("Last Msg:"), _("Unknown"));
			}

			menu_quick_item (0, buf, submenu, XCMENU_MARKUP, 0, 0);

			menu_quick_endsub ();
			menu_quick_item (0, 0, menu, XCMENU_SHADED, 0, 0);
		}
	}

	if (num_sel > 1)
		menu_create (menu, popup_list, NULL, FALSE);
	else
		menu_create (menu, popup_list, str_copy, FALSE);

	if (num_sel == 0)	/* xtext click */
		menu_add_plugin_items (menu, "\x5$NICK", str_copy);
	else	/* userlist treeview click */
		menu_add_plugin_items (menu, "\x5$NICK", NULL);

	menu_popup (menu, event, NULL);
}