chiark / gitweb /
Start on 'settings' window. Currently disabled as it's not very
authorRichard Kettlewell <rjk@greenend.org.uk>
Tue, 22 Jan 2008 20:36:30 +0000 (20:36 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Tue, 22 Jan 2008 20:36:30 +0000 (20:36 +0000)
useful yet.

disobedience/disobedience.h
disobedience/menu.c
disobedience/settings.c

index a664d58c4fb86177427176611abb9afccb71b61a..0e16474e5d0105eea62543723f60e137f1e068b3 100644 (file)
@@ -267,6 +267,7 @@ extern const char *browser;
 void save_settings(void);
 void load_settings(void);
 void set_tool_colors(GtkWidget *w);
 void save_settings(void);
 void load_settings(void);
 void set_tool_colors(GtkWidget *w);
+void popup_settings(void);
 
 /* Widget leakage debugging rubbish ---------------------------------------- */
 
 
 /* Widget leakage debugging rubbish ---------------------------------------- */
 
index 80e33cdc9f9a35d1f5927a2956d5080440bee264..f93e2f7a2dfce973d509cba04780c41435167b86 100644 (file)
@@ -94,6 +94,15 @@ static void login(gpointer attribute((unused)) callback_data,
   login_box();
 }
 
   login_box();
 }
 
+#if 0
+/** @brief Called when the settings option is activated */
+static void settings(gpointer attribute((unused)) callback_data,
+                     guint attribute((unused)) callback_action,
+                     GtkWidget attribute((unused)) *menu_item) {
+  popup_settings();
+}
+#endif
+
 /** @brief Update menu state
  *
  * Determines option sensitivity according to the current tab and adjusts the
 /** @brief Update menu state
  *
  * Determines option sensitivity according to the current tab and adjusts the
@@ -219,6 +228,16 @@ GtkWidget *menubar(GtkWidget *w) {
       0,                                /* item_type */
       0                                 /* extra_data */
     },
       0,                                /* item_type */
       0                                 /* extra_data */
     },
+#if 0
+    {
+      (char *)"/File/Settings",         /* path */
+      0,                                /* accelerator */
+      settings,                         /* callback */
+      0,                                /* callback_action */
+      0,                                /* item_type */
+      0                                 /* extra_data */
+    },
+#endif
     {
       (char *)"/File/Quit Disobedience", /* path */
       (char *)"<CTRL>Q",                /* accelerator */
     {
       (char *)"/File/Quit Disobedience", /* path */
       (char *)"<CTRL>Q",                /* accelerator */
index 0fe1237221cc28cf845e1f78934679bcd76f2894..3450085fdd52607a499211d62dbba360fc3b64d1 100644 (file)
@@ -282,6 +282,70 @@ void set_tool_colors(GtkWidget *w) {
     set_tool_colors(child);
 }
 
     set_tool_colors(child);
 }
 
+/** @brief Pop up a settings editor widget */
+void popup_settings(void) {
+  static GtkWidget *settings_window;
+  GtkWidget *table;
+  unsigned row, col;
+
+  if(settings_window) { 
+    gtk_window_present(GTK_WINDOW(settings_window));
+    return;
+  }
+  /* Create the window */
+  settings_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+  gtk_widget_set_style(settings_window, tool_style);
+  gtk_window_set_title(GTK_WINDOW(settings_window), "Disobedience Settings");
+  /* Clear the pointer to the window widget when it is closed */
+  g_signal_connect(settings_window, "destroy",
+                  G_CALLBACK(gtk_widget_destroyed), &settings_window);
+
+  /* The color settings live in a big table */
+  table = gtk_table_new(2 * NSTYLES + 1/*rows */, NSTATES + 1/*cols*/,
+                        TRUE/*homogeneous*/);
+  /* Titles */
+  for(row = 0; row < 2 * NSTYLES; ++row) {
+    char *legend;
+
+    byte_xasprintf(&legend, "%s %s", styles[row / 2].name,
+                   row % 2 ? "background" : "foreground");
+    gtk_table_attach(GTK_TABLE(table),
+                     gtk_label_new(legend),
+                     0, 1,
+                     row + 1, row + 2,
+                     GTK_FILL, GTK_FILL,
+                     1, 1);
+  }
+  for(col = 0; col < NSTATES; ++col) {
+    gtk_table_attach(GTK_TABLE(table),
+                     gtk_label_new(states[col]),
+                     col + 1, col + 2,
+                     0, 1,
+                     GTK_FILL, GTK_FILL,
+                     1, 1);
+  }
+  /* The actual colors */
+  for(row = 0; row < 2 * NSTYLES; ++row) {
+    for(col = 0; col <  NSTATES; ++col) {
+      GdkColor *const c = &(row % 2
+                            ? (**styles[row / 2].style).bg
+                            : (**styles[row / 2].style).fg)[col];
+      gtk_table_attach(GTK_TABLE(table),
+                       gtk_color_button_new_with_color(c),
+                       col + 1, col + 2,
+                       row + 1, row + 2,
+                       GTK_FILL, GTK_FILL,
+                       1, 1);
+    }
+  }
+  gtk_container_add(GTK_CONTAINER(settings_window), table);
+  gtk_widget_show_all(settings_window);
+  /* TODO: save settings
+     TODO: web browser
+     TODO: impose settings when they are set
+  */
+}
+
 /*
 Local Variables:
 c-basic-offset:2
 /*
 Local Variables:
 c-basic-offset:2