Fix more "no previous declaration" warnings
[obnox/wireshark/wip.git] / gtk / color_dlg.c
index 5ae6f19567e3890105cfcc84cb0ccbea95e317f4..c85218bf13186434e3101e94d5083b7e845fbf71 100644 (file)
@@ -47,6 +47,7 @@
 #include "file_dlg.h"
 #include "gtkglobals.h"
 #include <epan/prefs.h>
+#include "help_dlg.h"
 
 static GtkWidget* colorize_dialog_new(char *filter);
 static void add_filter_to_list(gpointer filter_arg, gpointer list_arg);
@@ -156,7 +157,7 @@ int color_marked_count(void)
 {
   int count = 0;
 
-  g_slist_foreach(filter_list, count_this_mark, &count);
+  g_slist_foreach(color_filter_list, count_this_mark, &count);
 
   return count;
 }
@@ -200,6 +201,7 @@ colorize_dialog_new (char *filter)
   GtkWidget *color_apply;
   GtkWidget *color_save;
   GtkWidget *color_cancel;
+  GtkWidget *color_help;
 
 #if GTK_MAJOR_VERSION >= 2
   GtkListStore      *store;
@@ -340,7 +342,7 @@ colorize_dialog_new (char *filter)
 #endif
 
   num_of_filters = 0;
-  g_slist_foreach(filter_list, add_filter_to_list, color_filters);
+  g_slist_foreach(color_filter_list, add_filter_to_list, color_filters);
 
 #if GTK_MAJOR_VERSION < 2
   gtk_clist_set_selection_mode    (GTK_CLIST (color_filters),GTK_SELECTION_EXTENDED);
@@ -386,7 +388,11 @@ colorize_dialog_new (char *filter)
 
 
   /* Button row: OK and cancel buttons */
-  button_ok_hbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE/*, GTK_STOCK_CANCEL*/, NULL);
+  if(topic_available(HELP_COLORING_RULES_DIALOG)) {
+    button_ok_hbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
+  } else {
+    button_ok_hbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CLOSE/*, GTK_STOCK_CANCEL*/, NULL);
+  }
   gtk_box_pack_start (GTK_BOX (dlg_vbox), button_ok_hbox, FALSE, FALSE, 5);
 
   color_ok = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_OK);
@@ -402,6 +408,12 @@ colorize_dialog_new (char *filter)
   window_set_cancel_button(color_win, color_cancel, color_cancel_cb);
   gtk_tooltips_set_tip (tooltips, color_cancel, ("Close this dialog but don't apply the color filter changes to the display"), NULL);
 
+  if(topic_available(HELP_COLORING_RULES_DIALOG)) {
+      color_help = OBJECT_GET_DATA(button_ok_hbox, GTK_STOCK_HELP);
+      gtk_tooltips_set_tip (tooltips, color_help, ("Get help about this dialog"), NULL);
+      SIGNAL_CONNECT(color_help, "clicked", topic_cb, HELP_COLORING_RULES_DIALOG);
+  }
+
   gtk_widget_grab_default(color_ok);
 
   /* signals and such */
@@ -488,7 +500,7 @@ add_filter_to_list(gpointer filter_arg, gpointer list_arg)
   num_of_filters++;
 }
 
-void move_this_row (GtkWidget   *color_filters, 
+static void move_this_row (GtkWidget   *color_filters, 
                      gint         filter_number,
                      gint         amount)            /* only tested with +1(down) and -1(up) */
 {
@@ -552,8 +564,8 @@ void move_this_row (GtkWidget   *color_filters,
   
 #endif
 
-  filter_list = g_slist_remove(filter_list, colorf);
-  filter_list = g_slist_insert(filter_list, colorf, filter_number + amount);
+  color_filter_list = g_slist_remove(color_filter_list, colorf);
+  color_filter_list = g_slist_insert(color_filter_list, colorf, filter_number + amount);
 }
 
 /* Move the selected filters up in the list */
@@ -677,7 +689,7 @@ struct remember_data
 };
 /* called for each selected row in the tree.
 */
-void remember_this_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer arg)
+static void remember_this_row (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer arg)
 {
     gint         *path_index;
     color_filter_t *colorf;
@@ -721,7 +733,7 @@ remember_selected_row(GtkTreeSelection *sel, gpointer color_filters)
     data.count = 0; 
     data.color_filters = color_filters;
 
-    g_slist_foreach(filter_list, clear_mark, NULL);
+    g_slist_foreach(color_filter_list, clear_mark, NULL);
     gtk_tree_selection_selected_foreach(sel,remember_this_row, &data);
                                       
     if (data.count > 0)
@@ -810,7 +822,7 @@ color_destroy_cb                       (GtkButton       *button _U_,
                                         gpointer         user_data _U_)
 {
   /* Destroy any edit dialogs we have open. */
-  g_slist_foreach(filter_list, destroy_edit_dialog_cb, NULL);
+  g_slist_foreach(color_filter_list, destroy_edit_dialog_cb, NULL);
 
   colorize_win = NULL;
 }
@@ -857,7 +869,7 @@ color_add_colorf(GtkWidget *color_filters, color_filter_t *colorf)
 }
 
 void
-color_add_filter_cb (color_filter_t *colorf, gpointer arg)
+color_filter_add_cb(color_filter_t *colorf, gpointer arg)
 {
   GtkWidget        *color_filters = arg;
 
@@ -914,7 +926,7 @@ create_new_color_filter(GtkButton *button, char *filter)
   style = gtk_widget_get_style(packet_list);
   gdkcolor_to_color_t(&bg_color, &style->base[GTK_STATE_NORMAL]);
   gdkcolor_to_color_t(&fg_color, &style->text[GTK_STATE_NORMAL]);
-  colorf = new_color_filter("name", filter, &bg_color, &fg_color); /* Adds at end! */
+  colorf = color_filter_new("name", filter, &bg_color, &fg_color); /* Adds at end! */
 
   color_add_colorf(color_filters, colorf);
 
@@ -974,7 +986,7 @@ color_delete(gint row, GtkWidget  *color_filters)
     window_destroy(colorf->edit_dialog);
     
     /* Remove the color filter from the list of color filters. */
-    remove_color_filter(colorf);
+    color_filter_remove(colorf);
     
     /* If we grab the focus after updating the selection, the first
     * row is always selected, so we do it before */
@@ -992,7 +1004,7 @@ color_delete(gint row, GtkWidget  *color_filters)
         window_destroy(colorf->edit_dialog);
 
     /* Remove the color filter from the list of color filters. */
-    remove_color_filter(colorf);
+    color_filter_remove(colorf);
 
 #endif
 }
@@ -1038,7 +1050,7 @@ color_delete_cb(GtkWidget *widget, gpointer user_data _U_)
 static void
 color_save_cb(GtkButton *button _U_, gpointer user_data _U_)
 {
-  if (!write_filters())
+  if (!color_filters_write())
        simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
            "Could not open filter file: %s", strerror(errno));
 }
@@ -1056,12 +1068,12 @@ color_clear_cmd(GtkWidget *widget)
         color_delete (num_of_filters-1, color_filters);
     }
 
-    if (!revert_filters())
+    if (!color_filters_revert())
         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
             "Could not delete filter file: %s", strerror(errno));
 
     /* colorize list */
-    colorize_packets(&cfile);
+    cf_colorize_packets(&cfile);
 
     /* Destroy the dialog box. */
     /* XXX: is this useful? user might want to continue with editing new colors */
@@ -1069,7 +1081,7 @@ color_clear_cmd(GtkWidget *widget)
 }
 
 /* clear button: user responded to question */
-void color_clear_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
+static void color_clear_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
 {
     switch(btn) {
     case(ESD_BTN_CLEAR):
@@ -1101,7 +1113,7 @@ static void
 color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
 {
   /* colorize list */
-  colorize_packets(&cfile);
+  cf_colorize_packets(&cfile);
 
   /* Destroy the dialog box. */
   window_destroy(colorize_win);
@@ -1120,7 +1132,7 @@ color_cancel_cb(GtkWidget *widget _U_, gpointer user_data _U_)
 static void
 color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
 {
-  colorize_packets(&cfile);
+  cf_colorize_packets(&cfile);
 }
 
 /* Create an "Edit Color Filter" dialog for a given color filter, and
@@ -1234,6 +1246,7 @@ edit_color_filter_dialog(GtkWidget *color_filters,
     style->fg[GTK_STATE_NORMAL]   = colorf->fg_color;
 #endif
     gtk_widget_set_style(*colorize_filter_text, style);
+    gtk_style_unref(style);
     gtk_box_pack_start (GTK_BOX (filter_string_hbox), *colorize_filter_text, TRUE, TRUE, 0);
     gtk_tooltips_set_tip (tooltips, *colorize_filter_text, ("This is the editable text of the filter"), NULL);
 
@@ -1417,7 +1430,7 @@ edit_color_filter_ok_cb                (GtkButton       *button,
 
     if(!dfilter_compile(filter_text, &compiled_filter)) {
         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
-                      "Filter \"%s\" did not compile correctly.\n"
+                      "Filter \"%s\" didn't compile correctly.\n"
                       " Please try again. Filter unchanged.\n%s\n", filter_name,
                       dfilter_error_msg);
     } else {
@@ -1625,6 +1638,7 @@ color_sel_ok_cb                        (GtkButton       *button _U_,
 #endif
        gtk_widget_set_style(filt_name_entry, style);
        gtk_widget_set_style(filt_text_entry, style);
+       gtk_style_unref(style);
   }
 }