]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
added the Enable/Disable Channel List option
authorDaniel Carbonell Fraj <bocata@src.gnome.org>
Wed, 9 Apr 2003 21:50:22 +0000 (21:50 +0000)
committerDaniel Carbonell Fraj <bocata@src.gnome.org>
Wed, 9 Apr 2003 21:50:22 +0000 (21:50 +0000)
ChangeLog
gtetrinet.schemas.in
src/client.c
src/config.c
src/config.h
src/dialogs.c
src/gtetrinet.c
src/partyline.c
src/partyline.h
src/tetrinet.c

index 1e50bf4de68d6a90b3c1414a9038e01106771ae0..caeed5263b805cc8eed95f989790551da6b00425 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2003-04-09  Dani Carbonell  <bocata@panete.net>
+
+       * 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  <jordi@sindominio.net>
 
        * Makefile.am: fix the install path for desktop files.
index 80b5ff1a05ccb41b07f49e74939f50161fa398f5..fdfb049474b86e09db1ce219955de52ffeff2cd1 100644 (file)
         <short>Enable/disable timestamps.</short>
         <long>Enables/disables timestamps in the partyline.</long>
       </locale>
-       </schema>
+    </schema>
+
+
+    <schema>
+      <key>/schemas/apps/gtetrinet/partyline/enable_channel_list</key>
+      <applyto>/apps/gtetrinet/partyline/enable_channel_list</applyto>
+      <owner>gtetrinet</owner>
+      <type>bool</type>
+      <default>1</default>
+
+      <locale name="C">
+        <short>Enable/disable channel list.</short>
+        <long>Enables/disables the channel list. Disable it if you experience problems when connecting or while playing
+        in your favorite tetrinet server.</long>
+      </locale>
+    </schema>
   </schemalist>
 </gconfschemafile>
index 7be511bca2a8fad4cc36b74e4044304374513a04..fc2f3f6a96119a9917a0b93c51c8c3f860fa45fa 100644 (file)
@@ -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;
         
index f86e5980db443ceea2cc34bbf4f77d06054e7e24..d7fe692174abf741c3a2522d01b14c79550186eb 100644 (file)
@@ -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)));
+}
+
index a96d090382afc9d38260eaa50a16ea47fcc13bdb..fbba64e2e62309583e479e13ad4ca5dccf59bc74 100644 (file)
@@ -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/"
index 01ea535b3c310c19774ebc7de736fc960320581d..7e630d497252edf198d7ab713ba2fae2ab16a471 100644 (file)
@@ -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,
index 32def0724cd1f7be0acf49f4ec788ca8cc86eab8..e3f9f69f5d0053b47c5d8f8bbaf16a3be2896713 100644 (file)
@@ -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);
index b5fa63356ee8c99ddbd1c1d95b5d92c4006c066d..c826c0a685f67c77128349a432c6250099b80355 100644 (file)
 #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), "<b>Channel List</b>");
-    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), _("<b>Channel List</b>"));
+    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);
+}
index 238c0e537d0b99620cf5d882710f9c70a937b423..0d2e318643d92d5679e582f098395fd2dcfb521a 100644 (file)
@@ -1,6 +1,7 @@
 #include <gtk/gtk.h>
 
 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);
index cb8f434b3e6c5815f1d290e5ea425dfaa9121525..53feb936e2857409bbff79d2f4f3a4427e7a712e 100644 (file)
@@ -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