]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
Add config for timestamping partyline text. Add config for timestamping
authorChipX86 <chipx86@chipx86.com>
Sat, 22 Feb 2003 22:00:51 +0000 (22:00 +0000)
committerJames Antill <james@src.gnome.org>
Sat, 22 Feb 2003 22:00:51 +0000 (22:00 +0000)
2003-02-22  ChipX86 <chipx86@chipx86.com>

        * src/config.c: Add config for timestamping partyline text.
        * src/config.h: Add config for timestamping partyline text.
        * src/dialogs.c: Add config for timestamping partyline text.
        * src/gtetrinet.c: Add config for timestamping partyline text.
        * src/partyline.c: Add timestamps if config is set.
        * src/partyline.h: Add config for timestamping partyline text.

2003-02-22  James Antill  <james@and.org>

        * src/config.c (config_loadtheme): If current theme has no name,
        revert to default.

        * src/fields.c (fields_init): If the current theme fails to load,
        change the preference.

ChangeLog
src/config.c
src/config.h
src/dialogs.c
src/fields.c
src/gtetrinet.c
src/partyline.c
src/partyline.h

index ee7bec0a227f5aec8bb9c87135026946e4eeaf00..6ff82dd56ba048b77ad0323fea97b070ed1f2ef8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2003-02-22  ChipX86 <chipx86@chipx86.com>
+
+       * src/config.c: Add config for timestamping partyline text.
+       * src/config.h: Add config for timestamping partyline text.
+       * src/dialogs.c: Add config for timestamping partyline text.
+       * src/gtetrinet.c: Add config for timestamping partyline text.
+       * src/partyline.c: Add timestamps if config is set.
+       * src/partyline.h: Add config for timestamping partyline text.
+
+2003-02-22  James Antill  <james@and.org>
+
+       * src/config.c (config_loadtheme): If current theme has no name,
+       revert to default.
+
+       * src/fields.c (fields_init): If the current theme fails to load,
+       change the preference.
+
 2003-02-20  Jordi Mallach  <jordi@sindominio.net>
 
        * src/tetrinet.c (tetrinet_sendfield): Patch from Ian Zink with big
index ce19d1b510d4d7fd23ef00d172f6c8e7fbe02956..9454910411f56d5d478953bd0132290da08ea581 100644 (file)
@@ -36,6 +36,7 @@
 #include "misc.h"
 #include "tetris.h"
 #include "fields.h"
+#include "partyline.h"
 
 char blocksfile[1024];
 int bsize;
@@ -130,9 +131,13 @@ void config_loadtheme (const gchar *themedir)
                                    0,
                                    GTK_MESSAGE_WARNING,
                                    GTK_BUTTONS_OK,
-                                   _("Warning: theme does not have a name"));
+                                   _("Warning: theme does not have a name,"
+                                     "reverting to default."));
       gtk_dialog_run (GTK_DIALOG (mb));
       gtk_widget_destroy (mb);
+      gnome_config_pop_prefix ();
+      g_string_assign(currenttheme, DEFAULTTHEME);
+      config_loadtheme (currenttheme->str);
     }
 }
 
@@ -300,6 +305,9 @@ void config_loadconfig (void)
     else
       keys[K_GAMEMSG] = defaultkeys[K_GAMEMSG];
 
+    /* Get the timestamp option. */
+    timestampsenable = gconf_client_get_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", NULL);
+
     config_loadtheme (currenttheme->str);
 }
 
@@ -478,3 +486,16 @@ keys_discard_changed (GConfClient *client,
   keys[K_DISCARD] = gdk_keyval_to_lower (gdk_keyval_from_name (gconf_value_get_string (gconf_entry_get_value (entry))));
 }
 
+void
+partyline_enable_timestamps_changed (GConfClient *client,
+                                     guint cnxn_id,
+                                     GConfEntry *entry)
+{
+
+  client = client;     /* Suppress compile warnings */
+  cnxn_id = cnxn_id;   /* Suppress compile warnings */
+
+  timestampsenable = gconf_value_get_bool (gconf_entry_get_value (entry));
+  if (!timestampsenable)
+    gconf_client_set_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps", FALSE, NULL);
+}
index f8a23f6d7992eeb6ceea3d8b073130e2071372ec..a96d090382afc9d38260eaa50a16ea47fcc13bdb 100644 (file)
@@ -71,6 +71,11 @@ keys_discard_changed (GConfClient *client,
                    guint cnxn_id,
                    GConfEntry *entry);
 
+void
+partyline_enable_timestamps_changed (GConfClient *client,
+                                                                        guint cnxn_id,
+                                                                        GConfEntry *entry);
+
 #define GTETRINET_THEMES GTETRINET_DATA"/themes"
 #define DEFAULTTHEME GTETRINET_THEMES"/default/"
 
index cc73de76ec4eaf86793ad502ca2fadb5b270053a..01ea535b3c310c19774ebc7de736fc960320581d 100644 (file)
@@ -35,6 +35,7 @@
 #include "misc.h"
 #include "sound.h"
 #include "string.h"
+#include "partyline.h"
 
 extern GConfClient *gconf_client;
 extern GtkWidget *app;
@@ -507,6 +508,7 @@ gint key_dialog (char *msg)
 /* the preferences dialog */
 /**************************/
 GtkWidget *themelist, *keyclist;
+GtkWidget *timestampcheck;
 GtkWidget *midientry, *miditable, *midicheck, *soundcheck;
 GtkWidget *namelabel, *authlabel, *desclabel;
 
@@ -669,6 +671,12 @@ void prefdialog_restoremidi (void)
                              NULL);
 }
 
+void prefdialog_timestampstoggle (GtkWidget *widget)
+{
+    gconf_client_set_bool (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps",
+                           GTK_TOGGLE_BUTTON (widget)->active, NULL);
+}
+
 void prefdialog_themelistselect (int n)
 {
     char author[1024], desc[1024];
@@ -878,6 +886,32 @@ void prefdialog_new (void)
     gtk_widget_show (label);
     gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label);
 
+    /* partyline */
+    timestampcheck = gtk_check_button_new_with_label (_("Enable Timestamps"));
+    gtk_widget_show(timestampcheck);
+
+    frame = gtk_hbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX(frame), timestampcheck, FALSE, FALSE, 0);
+    gtk_widget_show (frame);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(timestampcheck),
+                                  timestampsenable);
+
+    g_signal_connect (G_OBJECT(timestampcheck), "toggled",
+                      G_CALLBACK(prefdialog_timestampstoggle), NULL);
+
+    table = gtk_table_new (3, 1, FALSE);
+    gtk_container_set_border_width (GTK_CONTAINER(table), GNOME_PAD);
+    gtk_table_set_row_spacings (GTK_TABLE(table), GNOME_PAD_SMALL);
+    gtk_table_set_col_spacings (GTK_TABLE(table), GNOME_PAD_SMALL);
+    gtk_table_attach (GTK_TABLE(table), frame, 0, 1, 0, 1,
+                      GTK_EXPAND | GTK_FILL, 0, 0, 0);
+    gtk_widget_show (table);
+
+    label = gtk_label_new (_("Partyline"));
+    gtk_widget_show (label);
+    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, label);
+
     /* keyboard */
     keyclist = GTK_WIDGET (gtk_tree_view_new_with_model (GTK_TREE_MODEL(keys_store)));
     key_scroll = gtk_scrolled_window_new (NULL, NULL);
index a3ae279604b4b2b3fe0dd386d58652726c18e488..7fe8c0345f881a368e5733bd016bcedbb645bbb1 100644 (file)
@@ -73,6 +73,7 @@ void fields_init (void)
                                       "Falling back to default"));
         gtk_dialog_run (GTK_DIALOG (mb));
         gtk_widget_destroy (mb);
+       g_string_assign(currenttheme, DEFAULTTHEME);
         config_loadtheme (DEFAULTTHEME);
         err = NULL;
         if (!(pb = gdk_pixbuf_new_from_file(blocksfile, &err))) {
index 2f3daeadfd0cac2a782aa2e9cdd5901cd35e9b60..32def0724cd1f7be0acf49f4ec788ca8cc86eab8 100644 (file)
@@ -135,6 +135,9 @@ int main (int argc, char *argv[])
     gconf_client_add_dir (gconf_client, "/apps/gtetrinet/keys",
                           GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
 
+    gconf_client_add_dir (gconf_client, "/apps/gtetrinet/partyline",
+                          GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+
     /* Request notification of change for these gconf keys */
     gconf_client_notify_add (gconf_client, "/apps/gtetrinet/sound/midi_player",
                              (GConfClientNotifyFunc) sound_midi_player_changed,
@@ -183,6 +186,10 @@ int main (int argc, char *argv[])
                              (GConfClientNotifyFunc) keys_message_changed,
                             NULL, NULL, NULL);
 
+    gconf_client_notify_add (gconf_client, "/apps/gtetrinet/partyline/enable_timestamps",
+                             (GConfClientNotifyFunc) partyline_enable_timestamps_changed,
+                            NULL, NULL, NULL);
+
     /* load settings */
     config_loadconfig ();
 
index cf496d57b13c4c53dbacfbfd50c862a85151685e..3807379dee07fe3323b68f905acaf9cf2c475260 100644 (file)
@@ -33,6 +33,8 @@
 #include "misc.h"
 #include "commands.h"
 
+int timestampsenable;
+
 /* widgets that we have to do stuff with */
 static GtkWidget *playerlist, *textbox, *entrybox,
     *namelabel, *teamlabel, *infolabel, *textboxscroll, 
@@ -228,7 +230,22 @@ void partyline_status (char *status)
 
 void partyline_text (char *text)
 {
-    textbox_addtext (GTK_TEXT_VIEW(textbox), text);
+    if (timestampsenable) {
+        time_t now;
+        char buf[1024];
+        char timestamp[9];
+
+        now = time(NULL);
+
+        strftime(timestamp, sizeof(timestamp), "%H:%M:%S", localtime(&now));
+        g_snprintf (buf, sizeof(buf), "%c[%s]%c %s",
+                    TETRI_TB_C_GREY, timestamp, TETRI_TB_RESET, text);
+
+        textbox_addtext (GTK_TEXT_VIEW(textbox), buf);
+    }
+    else
+        textbox_addtext (GTK_TEXT_VIEW(textbox), text);
+
     adjust_bottom_text_view(GTK_TEXT_VIEW(textbox));
 }
 
index 8f05a2e6f6f3c95030c552817b68defc0d8843b6..238c0e537d0b99620cf5d882710f9c70a937b423 100644 (file)
@@ -1,4 +1,7 @@
 #include <gtk/gtk.h>
+
+extern int timestampsenable;
+
 extern GtkWidget *partyline_page_new (void);
 extern void partyline_connectstatus (int status);
 extern void partyline_namelabel (char *nick, char *team);