/* X-Chat * Copyright (C) 2005 Peter Zelezny. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ /* joind.c - The Join Dialog. Popups up when you connect without any autojoin channels and helps you to find or join a channel. */ #include #include #include #include #ifndef WIN32 #include #endif #include "../common/hexchat.h" #include "../common/hexchatc.h" #include "../common/server.h" #include "../common/fe.h" #include "fe-gtk.h" #include "chanlist.h" static void joind_radio2_cb (GtkWidget *radio, server *serv) { if (GTK_TOGGLE_BUTTON (radio)->active) { gtk_widget_grab_focus (serv->gui->joind_entry); gtk_editable_set_position (GTK_EDITABLE (serv->gui->joind_entry), 999); } } static void joind_entryenter_cb (GtkWidget *entry, GtkWidget *ok) { gtk_widget_grab_focus (ok); } static void joind_entryfocus_cb (GtkWidget *entry, GdkEventFocus *event, server *serv) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (serv->gui->joind_radio2), TRUE); } static void joind_destroy_cb (GtkWidget *win, server *serv) { if (is_server (serv)) serv->gui->joind_win = NULL; } static void joind_ok_cb (GtkWidget *ok, server *serv) { if (!is_server (serv)) { gtk_widget_destroy (gtk_widget_get_toplevel (ok)); return; } /* do nothing */ if (GTK_TOGGLE_BUTTON (serv->gui->joind_radio1)->active) goto xit; /* join specific channel */ if (GTK_TOGGLE_BUTTON (serv->gui->joind_radio2)->active) { char *text = GTK_ENTRY (serv->gui->joind_entry)->text; if (strlen (text) < 2) { fe_message (_("Channel name too short, try again."), FE_MSG_ERROR); return; } serv->p_join (serv, text, ""); goto xit; } /* channel list */ chanlist_opengui (serv, TRUE); xit: prefs.hex_gui_join_dialog = 0; if (GTK_TOGGLE_BUTTON (serv->gui->joind_check)->active) prefs.hex_gui_join_dialog = 1; gtk_widget_destroy (serv->gui->joind_win); serv->gui->joind_win = NULL; } static void joind_show_dialog (server *serv) { GtkWidget *dialog1; GtkWidget *dialog_vbox1; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *image1; GtkWidget *vbox2; GtkWidget *label; GtkWidget *radiobutton1; GtkWidget *radiobutton2; GtkWidget *radiobutton3; GSList *radiobutton1_group; GtkWidget *hbox2; GtkWidget *entry1; GtkWidget *checkbutton1; GtkWidget *dialog_action_area1; GtkWidget *okbutton1; char buf[256]; char buf2[256]; serv->gui->joind_win = dialog1 = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog1), _(DISPLAY_NAME": Connection Complete")); gtk_window_set_type_hint (GTK_WINDOW (dialog1), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_position (GTK_WINDOW (dialog1), GTK_WIN_POS_MOUSE); dialog_vbox1 = GTK_DIALOG (dialog1)->vbox; gtk_widget_show (dialog_vbox1); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0); image1 = gtk_image_new_from_stock (GTK_STOCK_NETWORK, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, TRUE, 24); gtk_misc_set_alignment (GTK_MISC (image1), 0.5, 0.06); vbox2 = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 6); gtk_widget_show (vbox2); gtk_box_pack_s