From dab56cf9cc8ba8d0c74bde309a13360084ce99c6 Mon Sep 17 00:00:00 2001 From: Daniel Carbonell Fraj Date: Wed, 9 Apr 2003 21:50:22 +0000 Subject: [PATCH] added the Enable/Disable Channel List option --- ChangeLog | 37 ++++++++++++++++++++++++++++++++ gtetrinet.schemas.in | 17 ++++++++++++++- src/client.c | 2 +- src/config.c | 16 ++++++++++++++ src/config.h | 10 +++++++-- src/dialogs.c | 18 ++++++++++++++-- src/gtetrinet.c | 6 ++++++ src/partyline.c | 51 ++++++++++++++++++++++++++++++-------------- src/partyline.h | 2 ++ src/tetrinet.c | 15 +++++++++++++ 10 files changed, 152 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e50bf4..caeed52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2003-04-09 Dani Carbonell + + * gtetrinet.schemas.in: added a new schema for the Enable Channel List + option. + + * src/client.c (client_readmsg): clarified the error message. + + * src/config.c: added support for the new option. + (partyline_enable_channel_list_changed): handler for the gconf key. + (config_loadconfig): added code to get the configuration of the new + option. + + * src/config.h: added the prototype for the new handler. + + * src/dialogs.c: added the UI for the new option. + (prefdialog_channeltoggle): new handler. + (prefdialog_new): added code for the new option. Also, modified the + policy of the keys scrolled window, so you can now horizontally scroll + it. + + * src/gtetrinet.c (main): added a GConf notification for the new option. + + * src/partyline.c: Added a convenience function for the Enable Channel + List option changed handler. Also, added code to parse the channel list + of one more server. + (partyline_page_new): slightly modified so we can now easily hide the + channel list. + (partyline_add_channel): added code to support a new server. + (partyline_show_channel_list): new convenience function, it will show + or hide the channel list as requested by the user. + + * src/partyline.h: two new declarations, the convenience function and + the variable that is used to cache the GConf setting. + + * src/tetrinet.c (tetrinet_inmessage): added code to support one more + server. + 2003-04-04 Jordi Mallach * Makefile.am: fix the install path for desktop files. diff --git a/gtetrinet.schemas.in b/gtetrinet.schemas.in index 80b5ff1..fdfb049 100644 --- a/gtetrinet.schemas.in +++ b/gtetrinet.schemas.in @@ -226,6 +226,21 @@ Enable/disable timestamps. Enables/disables timestamps in the partyline. - + + + + + /schemas/apps/gtetrinet/partyline/enable_channel_list + /apps/gtetrinet/partyline/enable_channel_list + gtetrinet + bool + 1 + + + Enable/disable channel list. + Enables/disables the channel list. Disable it if you experience problems when connecting or while playing + in your favorite tetrinet server. + + diff --git a/src/client.c b/src/client.c index 7be511b..fc2f3f6 100644 --- a/src/client.c +++ b/src/client.c @@ -448,7 +448,7 @@ int client_readmsg (gchar **str) switch (g_io_channel_read_chars (io_channel, &buf[i], 1, &bytes, &error)) { case G_IO_STATUS_EOF : - g_warning ("End of file."); + g_warning ("End of file (server closed connection)."); return -1; break; diff --git a/src/config.c b/src/config.c index f86e598..d7fe692 100644 --- a/src/config.c +++ b/src/config.c @@ -308,6 +308,9 @@ void config_loadconfig (void) /* Get the timestamp option. */ timestampsenable = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", NULL); + /* Get the channel list option */ + list_enabled = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list", NULL); + config_loadtheme (currenttheme->str); } @@ -499,3 +502,16 @@ partyline_enable_timestamps_changed (GConfClient *client, if (!timestampsenable) gconf_client_set_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", FALSE, NULL); } + +void +partyline_enable_channel_list_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry) +{ + + client = client; /* Suppress compile warnings */ + cnxn_id = cnxn_id; /* Suppress compile warnings */ + + partyline_show_channel_list (gconf_value_get_bool (gconf_entry_get_value (entry))); +} + diff --git a/src/config.h b/src/config.h index a96d090..fbba64e 100644 --- a/src/config.h +++ b/src/config.h @@ -73,8 +73,14 @@ keys_discard_changed (GConfClient *client, void partyline_enable_timestamps_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry); + guint cnxn_id, + GConfEntry *entry); + +void +partyline_enable_channel_list_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry); + #define GTETRINET_THEMES GTETRINET_DATA"/themes" #define DEFAULTTHEME GTETRINET_THEMES"/default/" diff --git a/src/dialogs.c b/src/dialogs.c index 01ea535..7e630d4 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -642,6 +642,12 @@ void prefdialog_soundtoggle (GtkWidget *widget) GTK_TOGGLE_BUTTON (widget)->active, NULL); } +void prefdialog_channeltoggle (GtkWidget *widget) +{ + gconf_client_set_bool (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list", + GTK_TOGGLE_BUTTON (widget)->active, NULL); +} + void prefdialog_miditoggle (GtkWidget *widget) { if (GTK_TOGGLE_BUTTON(widget)->active) { @@ -795,6 +801,7 @@ void prefdialog_new (void) { GtkWidget *label, *table, *frame, *button, *button1, *widget, *table1, *divider, *notebook; GtkWidget *themelist_scroll, *key_scroll; + GtkWidget *channel_list_check; GtkListStore *theme_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); GtkListStore *keys_store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); @@ -889,16 +896,23 @@ void prefdialog_new (void) /* partyline */ timestampcheck = gtk_check_button_new_with_label (_("Enable Timestamps")); gtk_widget_show(timestampcheck); + channel_list_check = gtk_check_button_new_with_label (_("Enable Channel List")); + gtk_widget_show (channel_list_check); - frame = gtk_hbox_new (FALSE, 0); + frame = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX(frame), timestampcheck, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX(frame), channel_list_check, FALSE, FALSE, 0); gtk_widget_show (frame); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(timestampcheck), timestampsenable); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (channel_list_check), + list_enabled); g_signal_connect (G_OBJECT(timestampcheck), "toggled", G_CALLBACK(prefdialog_timestampstoggle), NULL); + g_signal_connect (G_OBJECT (channel_list_check), "toggled", + G_CALLBACK (prefdialog_channeltoggle), NULL); table = gtk_table_new (3, 1, FALSE); gtk_container_set_border_width (GTK_CONTAINER(table), GNOME_PAD); @@ -916,7 +930,7 @@ void prefdialog_new (void) keyclist = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL(keys_store))); key_scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (key_scroll), - GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER(key_scroll), keyclist); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (keyclist), -1, _("Action"), renderer, diff --git a/src/gtetrinet.c b/src/gtetrinet.c index 32def07..e3f9f69 100644 --- a/src/gtetrinet.c +++ b/src/gtetrinet.c @@ -189,6 +189,10 @@ int main (int argc, char *argv[]) gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", (GConfClientNotifyFunc) partyline_enable_timestamps_changed, NULL, NULL, NULL); + + gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_channel_list", + (GConfClientNotifyFunc) partyline_enable_channel_list_changed, + NULL, NULL, NULL); /* load settings */ config_loadconfig (); @@ -272,6 +276,8 @@ int main (int argc, char *argv[]) gtk_widget_show (notebook); g_object_set (G_OBJECT (notebook), "can-focus", FALSE, NULL); + + partyline_show_channel_list (list_enabled); gtk_widget_show (app); // gtk_widget_set_size_request (partywidget, 480, 360); diff --git a/src/partyline.c b/src/partyline.c index b5fa633..c826c0a 100644 --- a/src/partyline.c +++ b/src/partyline.c @@ -34,12 +34,13 @@ #include "commands.h" int timestampsenable; +gboolean list_enabled; /* widgets that we have to do stuff with */ static GtkWidget *playerlist, *textbox, *entrybox, *namelabel, *teamlabel, *infolabel, *textboxscroll, *playerlist_scroll, *playerlist_vpaned, *channel_box, - *playerlist_channel_scroll, *label; + *playerlist_channel_scroll, *label, *channel_list; /* some more widgets for layout */ static GtkWidget *table, *leftbox, *rightbox; @@ -70,7 +71,7 @@ GtkWidget *partyline_page_new (void) leftbox = gtk_vbox_new (FALSE, 4); /* chat thingy */ /* channel list */ - box1 = gtk_vbox_new (FALSE, 0); + channel_list = gtk_vbox_new (FALSE, 0); channel_box = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL (playerlist_channels))); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (channel_box), -1, _("Name"), renderer, "text", 1, NULL); @@ -89,9 +90,9 @@ GtkWidget *partyline_page_new (void) gtk_container_add (GTK_CONTAINER(playerlist_channel_scroll), channel_box); gtk_widget_set_size_request (playerlist_channel_scroll, -1, 100); label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), "Channel List"); - gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box1), playerlist_channel_scroll, TRUE, TRUE, 0); + gtk_label_set_markup (GTK_LABEL (label), _("Channel List")); + gtk_box_pack_start (GTK_BOX (channel_list), label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (channel_list), playerlist_channel_scroll, TRUE, TRUE, 0); /* textbox with scrollbars */ box2 = gtk_vbox_new (FALSE, 0); @@ -112,7 +113,7 @@ GtkWidget *partyline_page_new (void) /* vpaned widget */ playerlist_vpaned = gtk_vpaned_new (); - gtk_paned_add1 (GTK_PANED (playerlist_vpaned), box1); + gtk_paned_add1 (GTK_PANED (playerlist_vpaned), channel_list); gtk_paned_add2 (GTK_PANED (playerlist_vpaned), box2); gtk_box_pack_start (GTK_BOX(leftbox), playerlist_vpaned, TRUE, TRUE, 0); @@ -448,18 +449,23 @@ void partyline_add_channel (gchar *line) while ((g_scanner_get_next_token (scan) != G_TOKEN_IDENTIFIER) && !g_scanner_eof (scan)); players = g_strdup (scan->value.v_identifier); - if (strncmp (players, "FULL", 4)) + if (players != NULL) { - while ((g_scanner_get_next_token (scan) != G_TOKEN_INT) && !g_scanner_eof (scan)); - actual = scan->value.v_int; - - while ((g_scanner_get_next_token (scan) != G_TOKEN_INT) && !g_scanner_eof (scan)); - max = scan->value.v_int; - - g_snprintf (final, 1024, "%d/%d %s", actual, max, players); + if (strncmp (players, "FULL", 4)) + { + while ((g_scanner_get_next_token (scan) != G_TOKEN_INT) && !g_scanner_eof (scan)); + actual = scan->value.v_int; + + while ((g_scanner_get_next_token (scan) != G_TOKEN_INT) && !g_scanner_eof (scan)); + max = scan->value.v_int; + + g_snprintf (final, 1024, "%d/%d %s", actual, max, players); + } + else + g_snprintf (final, 1024, "%s", players); } else - g_snprintf (final, 1024, "6/6 %s", players); + g_snprintf (final, 1024, "UNK"); g_scanner_get_next_token (scan); /* dump the ')' */ @@ -546,7 +552,7 @@ gboolean partyline_update_channel_list (void) gchar cad[1024]; /* if there is another update in progress, just go away silently */ - if (list_issued == 0) + if (list_enabled && (list_issued == 0)) { list_issued++; gtk_list_store_clear (work_model); @@ -607,3 +613,16 @@ void partyline_joining_channel (const gchar *channel) g_free (final); } + +void partyline_show_channel_list (gboolean show) +{ + /* + * If this function is called with TRUE, it will show the channel list, otherwise + * it'll hide it. + */ + list_enabled = show; + if (list_enabled) + gtk_widget_show (channel_list); + else + gtk_widget_hide (channel_list); +} diff --git a/src/partyline.h b/src/partyline.h index 238c0e5..0d2e318 100644 --- a/src/partyline.h +++ b/src/partyline.h @@ -1,6 +1,7 @@ #include extern int timestampsenable; +extern gboolean list_enabled; extern GtkWidget *partyline_page_new (void); extern void partyline_connectstatus (int status); @@ -17,3 +18,4 @@ extern void partyline_switch_entryfocus (void); extern void partyline_clear_list_channel (void); extern void partyline_joining_channel (const gchar *channel); extern void stop_list (void); +extern void partyline_show_channel_list (gboolean); diff --git a/src/tetrinet.c b/src/tetrinet.c index cb8f434..53feb93 100644 --- a/src/tetrinet.c +++ b/src/tetrinet.c @@ -410,6 +410,7 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data) else { gchar *line = nocolor (token); + gchar *aux; if (list_issued > 0) { @@ -436,6 +437,9 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data) stop_list(); break; } + + if (!strncmp ("Use", line, 3)) + break; //if (line != NULL) g_free (line); } @@ -456,6 +460,15 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data) { partyline_joining_channel (&line[16]); } + + aux = g_strconcat ("You tell ", playernames[playernum], ": --- MARK ---", NULL); + if (!strcmp (aux, line)) + { + list_issued--; + if (list_issued <= 0) + stop_list (); + break; + } if (tetrix) { g_snprintf (buf, sizeof(buf), "*** %s", token); @@ -477,6 +490,8 @@ void tetrinet_inmessage (enum inmsg_type msgtype, char *data) if (list_issued <= 0) stop_list(); } + else + plinemsg (playernames[pnum], token); //g_free (line); } else -- 2.50.1