コード例 #1
0
ファイル: about.c プロジェクト: fuzzmz/hexchat
void
menu_about (GtkWidget * wid, gpointer sess)
{
	GtkWidget *vbox;									/* the main vertical box inside the about dialog */
	GtkWidget *hbox_main;								/* horizontal box for containing text on the left and logo on the right */
	GtkWidget *vbox_logo;								/* vertical box for our logo */
	GtkWidget *vbox_text;								/* vertical box for text */
	GtkWidget *label_title;								/* label for the main title */
	GtkWidget *label_subtitle;							/* label for the subtitle */
	GtkWidget *label_info;								/* for the informative text */
	GtkWidget *label_copyright;							/* for copyright notices */
	GdkColor color;										/* color buffer for our nice paintings */
	char buf[512];										/* text buffer for the labels */
	const char *locale = NULL;
	extern GtkWindow *parent_window;					/* maingui.c */

	if (about)
	{
		gtk_window_present (GTK_WINDOW (about));
		return;
	}

	/* general about dialog initialization */
	about = gtk_dialog_new ();
	gtk_window_set_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_window_set_resizable (GTK_WINDOW (about), FALSE);
	gtk_window_set_title (GTK_WINDOW (about), _("About "DISPLAY_NAME));
	if (parent_window)
	{
		gtk_window_set_transient_for (GTK_WINDOW (about), parent_window);
	}
	g_signal_connect (G_OBJECT (about), "destroy", G_CALLBACK (about_close), 0);
	vbox = GTK_DIALOG (about)->vbox;

	/* main horizontal box, text on the left, logo on the right */
	hbox_main = gtk_hbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (hbox_main));

	/* textbox on the left */
	vbox_text = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox_main), vbox_text, 0, 0, 5);

	/* label for title */
	snprintf (buf, sizeof (buf), "<span size=\"x-large\"><b>"DISPLAY_NAME"</b></span>");
	label_title = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label_title), 0, 0);
	gtk_box_pack_start (GTK_BOX (vbox_text), label_title, 0, 0, 10);
	color.red   = 0xd7d7;
	color.green = 0x4343;
	color.blue  = 0x0404;
	gtk_widget_modify_fg (label_title, GTK_STATE_NORMAL, &color);
	gtk_label_set_markup (GTK_LABEL (label_title), buf);

	/* label for subtitle */
	snprintf (buf, sizeof (buf), "%s", _("<b>A multiplatform IRC Client</b>"));
	label_subtitle = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label_subtitle), 0, 0);
	gtk_box_pack_start (GTK_BOX (vbox_text), label_subtitle, 0, 0, 10);
	color.red   = 0x5555;
	color.green = 0x5555;
	color.blue  = 0x5555;
	gtk_widget_modify_fg (label_subtitle, GTK_STATE_NORMAL, &color);
	gtk_label_set_markup (GTK_LABEL (label_subtitle), buf);

	/* label for additional info */
	g_get_charset (&locale);
	(snprintf) (buf, sizeof (buf),
				"<b>Version:</b> "PACKAGE_VERSION"\n"
				"<b>Compiled:</b> "__DATE__"\n"
#ifdef WIN32
				"<b>Portable Mode:</b> %s\n"
				"<b>Build Type:</b> x%d\n"
#endif
				"<b>OS:</b> %s\n"
				"<b>Charset:</b> %s",
#ifdef WIN32
				(portable_mode () ? "Yes" : "No"),
				get_cpu_arch (),
#endif
				get_sys_str (0),
				locale);

	label_info = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label_info), 0, 0);
	gtk_box_pack_start (GTK_BOX (vbox_text), label_info, 0, 0, 10);
	gtk_label_set_selectable (GTK_LABEL (label_info), TRUE);
	gtk_label_set_markup (GTK_LABEL (label_info), buf);

	/* label for copyright notices */
	snprintf (buf, sizeof (buf), "<small>\302\251 1998-2010 Peter \305\275elezn\303\275\n\302\251 2009-2012 Berke Viktor</small>");
	label_copyright = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label_copyright), 0, 0);
	gtk_box_pack_start (GTK_BOX (vbox_text), label_copyright, 0, 0, 10);
	gtk_label_set_markup (GTK_LABEL (label_copyright), buf);

	/* imagebox on the right */
	vbox_logo = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox_main), vbox_logo, 0, 0, 10);

	/* the actual image */
	wid = gtk_image_new_from_pixbuf (pix_hexchat);
	gtk_box_pack_start (GTK_BOX (vbox_logo), wid, 0, 0, 10);

	/* our close button on the bottom right */
	wid = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
	GTK_WIDGET_SET_FLAGS (GTK_WIDGET (wid), GTK_CAN_DEFAULT);
	gtk_box_pack_end (GTK_BOX (GTK_DIALOG (about)->action_area), wid, 0, 0, 0);
	gtk_widget_grab_default (wid);
	g_signal_connect (G_OBJECT (wid), "clicked", G_CALLBACK (gtkutil_destroy), about);

	/* pure white background for the whole about widget*/
	color.red = color.green = color.blue = 0xffff;
	gtk_widget_modify_bg (about, GTK_STATE_NORMAL, &color);

	/* show off! */
	gtk_widget_show_all (about);
}
コード例 #2
0
ファイル: ctcp.cpp プロジェクト: leeter/hexchat
void
ctcp_handle (session *sess, char *to, char *nick, char *ip,
				 char *msg, char *word[], char *word_eol[], bool id,
				 const message_tags_data *tags_data)
{
	char *po;
	session *chansess;
	server *serv = sess->server;
	char outbuf[1024];
	int ctcp_offset = 2;

	if (serv->have_idmsg && (word[4][1] == '+' || word[4][1] == '-') )
			ctcp_offset = 3;

	/* consider DCC to be different from other CTCPs */
	if (!g_ascii_strncasecmp (msg, "DCC", 3))
	{
		/* but still let CTCP replies override it */
		if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
		{
			if (!ignore_check(word[1], ignore::IG_DCC))
				dcc::handle_dcc (sess, nick, word, word_eol, tags_data);
		}
		return;
	}

	/* consider ACTION to be different from other CTCPs. Check
	  ignore as if it was a PRIV/CHAN. */
	if (!g_ascii_strncasecmp (msg, "ACTION ", 7))
	{
		if (serv->is_channel_name (to))
		{
			/* treat a channel action as a CHAN */
			if (ignore_check(word[1], ignore::IG_CHAN))
				return;
		} else
		{
			/* treat a private action as a PRIV */
			if (ignore_check(word[1], ignore::IG_PRIV))
				return;
		}

		/* but still let CTCP replies override it */
		if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
			goto generic;

		inbound_action (sess, to, nick, ip, msg + 7, false, id, tags_data);
		return;
	}

	if (ignore_check(word[1], ignore::IG_CTCP))
		return;

	if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hex_irc_hide_version)
	{
#ifdef WIN32
		snprintf (outbuf, sizeof (outbuf), "VERSION HexChat " PACKAGE_VERSION " [x%d] / %s",
					 get_cpu_arch (), get_sys_str (true));
#else
		snprintf (outbuf, sizeof (outbuf), "VERSION HexChat " PACKAGE_VERSION " / %s",
					 get_sys_str (true));
#endif
		serv->p_nctcp (nick, outbuf);
	}

	if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
	{
		if (!g_ascii_strncasecmp (msg, "SOUND", 5))
		{
			po = std::strchr (word[5], '\001');
			if (po)
				po[0] = 0;

			if (sess->server->is_channel_name(to))
			{
				chansess = find_channel (*(sess->server), to);
				if (!chansess)
					chansess = sess;

				EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSNDC, chansess, word[5],
											  nick, to, nullptr, 0, tags_data->timestamp);
			} else
			{
				EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPSND, sess->server->front_session,
											  word[5], nick, nullptr, nullptr, 0,
											  tags_data->timestamp);
			}

			/* don't let IRCers specify path */
#ifdef WIN32
			if (std::strchr (word[5], '/') == nullptr && std::strchr (word[5], '\\') == nullptr)
#else
			if (std::strchr (word[5], '/') == nullptr)
#endif
				sound_play (word[5], true);
			return;
		}
	}

generic:
	po = std::strchr (msg, '\001');
	if (po)
		po[0] = 0;

	if (!sess->server->is_channel_name (to))
	{
		EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGEN, sess->server->front_session, msg,
									  nick, nullptr, nullptr, 0, tags_data->timestamp);
	} else
	{
		chansess = find_channel (*(sess->server), to);
		if (!chansess)
			chansess = sess;
		EMIT_SIGNAL_TIMESTAMP (XP_TE_CTCPGENC, chansess, msg, nick, to, nullptr, 0,
									  tags_data->timestamp);
	}
}