diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2008-04-06 23:57:02 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2008-04-06 23:57:02 +0000 |
commit | 242e3b78bc781b385fff40343500f04bc3b9bd41 (patch) | |
tree | 8206dbd71688c494b2b47762275c25474da9d4a5 /gtk | |
parent | da802127158bddf24967fe8119ef84fa35c273b3 (diff) |
remove GTK1 code
svn path=/trunk/; revision=24821
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkvumeter.c | 3 | ||||
-rw-r--r-- | gtk/gui_prefs.c | 22 | ||||
-rw-r--r-- | gtk/gui_utils.c | 147 | ||||
-rw-r--r-- | gtk/help_dlg.c | 216 |
4 files changed, 0 insertions, 388 deletions
diff --git a/gtk/gtkvumeter.c b/gtk/gtkvumeter.c index f2c13cc25f..8c01a3f86f 100644 --- a/gtk/gtkvumeter.c +++ b/gtk/gtkvumeter.c @@ -17,8 +17,6 @@ #include <gtk/gtk.h> #include "gtkvumeter.h" -#if GTK_MAJOR_VERSION >= 2 - #define MIN_DYNAMIC_SIDE 40 @@ -1282,4 +1280,3 @@ void gtk_vumeter_get_brightness (GtkVUMeter *vumeter, gint *foreground, gint *ba } } -#endif diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c index 21844c2d08..34b80ff3f3 100644 --- a/gtk/gui_prefs.c +++ b/gtk/gui_prefs.c @@ -84,29 +84,11 @@ static const enum_val_t selection_mode_vals[] = { { NULL, NULL, 0 } }; -#if GTK_MAJOR_VERSION < 2 -static const enum_val_t line_style_vals[] = { - { "NONE", "None", 0 }, - { "SOLID", "Solid", 1 }, - { "DOTTED", "Dotted", 2 }, - { "TABBED", "Tabbed", 3 }, - { NULL, NULL, 0 } -}; - -static const enum_val_t expander_style_vals[] = { - { "NONE", "None", 0 }, - { "SQUARE", "Square", 1 }, - { "TRIANGLE", "Triangle", 2 }, - { "CIRCULAR", "Circular", 3 }, - { NULL, NULL, 0 } -}; -#else static const enum_val_t altern_colors_vals[] _U_ = { { "FALSE", "No", FALSE }, { "TRUE", "Yes", TRUE }, { NULL, NULL, 0 } }; -#endif static const enum_val_t filter_toolbar_placement_vals[] _U_ = { { "FALSE", "Below the main toolbar", FALSE }, @@ -161,11 +143,7 @@ static char recent_files_count_max_str[128] = ""; /* Used to contain the string from the Open File preview timeout pref item */ static char open_file_preview_str[128] = ""; -#if GTK_MAJOR_VERSION < 2 -#define GUI_TABLE_ROWS 5 -#else #define GUI_TABLE_ROWS 4 -#endif GtkWidget* gui_prefs_show(void) diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c index 8ccf2dc83e..a00300a17e 100644 --- a/gtk/gui_utils.c +++ b/gtk/gui_utils.c @@ -145,19 +145,9 @@ window_new(GtkWindowType type, const gchar *title) /* a lot of people dislike GTK_WIN_POS_MOUSE */ /* set the initial position (must be done, before show is called!) */ -#if GTK_MAJOR_VERSION >= 2 /* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);*/ -#else -/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);*/ -#endif gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_NONE); -#if GTK_MAJOR_VERSION < 2 - /* allow window to be shrinked by user, as gtk_widget_set_usize() will set minimum size and */ - /* the user never could shrink the window again */ - gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, FALSE); -#endif - return win; } @@ -189,16 +179,6 @@ window_new_with_geom(GtkWindowType type, const gchar *title, const gchar *geom_n } -#if GTK_MAJOR_VERSION < 2 -/* We can't set the decorations until the window is realized. */ -static void -window_notitle_realize_cb (GtkWidget *win, gpointer data _U_) -{ - gdk_window_set_decorations(win->window, 0); -} -#endif - - /* Create a new window for a splash screen; it's a main window, with no title, positioned in the center of the screen. */ GtkWidget * @@ -207,11 +187,7 @@ splash_window_new(void) GtkWidget *win; win = gtk_window_new(GTK_WINDOW_TOPLEVEL); -#if GTK_MAJOR_VERSION >= 2 gtk_window_set_decorated(GTK_WINDOW(win), FALSE); -#else - SIGNAL_CONNECT(win, "realize", window_notitle_realize_cb, NULL); -#endif /* set the initial position (must be done, before show is called!) */ gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER); @@ -227,10 +203,8 @@ window_present(GtkWidget *win) window_geometry_t geom; const gchar *name; -#if GTK_MAJOR_VERSION >= 2 /* present this window */ gtk_window_present(GTK_WINDOW(win)); -#endif /* do we have a previously saved size and position of this window? */ name = OBJECT_GET_DATA(win, WINDOW_GEOM_KEY); @@ -314,9 +288,7 @@ void window_get_geometry(GtkWidget *widget, window_geometry_t *geom) { gint desk_x, desk_y; -#if GTK_MAJOR_VERSION >= 2 GdkWindowState state; -#endif /* Try to grab our geometry. @@ -352,10 +324,8 @@ window_get_geometry(GtkWidget *widget, window_geometry_t *geom) &geom->width, &geom->height); -#if GTK_MAJOR_VERSION >= 2 state = gdk_window_get_state(widget->window); geom->maximized = (state == GDK_WINDOW_STATE_MAXIMIZED); -#endif } @@ -366,32 +336,18 @@ window_set_geometry(GtkWidget *widget, window_geometry_t *geom) /* as we now have the geometry from the recent file, set it */ /* if the window was minimized, x and y are -32000 (at least on Win32) */ if (geom->set_pos && geom->x != -32000 && geom->y != -32000) { -#if GTK_MAJOR_VERSION >= 2 gtk_window_move(GTK_WINDOW(widget), geom->x, geom->y); -#else - gtk_widget_set_uposition(widget, - geom->x, - geom->y); -#endif } if (geom->set_size) { -#if GTK_MAJOR_VERSION >= 2 gtk_window_resize(GTK_WINDOW(widget), -#else - gtk_window_set_default_size(GTK_WINDOW(widget), - geom->width, - geom->height); - gtk_widget_set_usize(widget, -#endif /*WIDGET_SET_SIZE(widget,*/ geom->width, geom->height); } -#if GTK_MAJOR_VERSION >= 2 if(geom->set_maximized) { if (geom->maximized) { gdk_window_maximize(widget->window); @@ -399,7 +355,6 @@ window_set_geometry(GtkWidget *widget, window_geometry_t *geom) gdk_window_unmaximize(widget->window); } } -#endif } @@ -554,14 +509,6 @@ window_destroy(GtkWidget *win) /* convert an xpm to a GtkWidget, using the window settings from it's parent */ /* (be sure that the parent window is already being displayed) */ GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm) { -#if GTK_MAJOR_VERSION < 2 - GdkPixmap *icon; - GdkBitmap * mask; - - - icon = gdk_pixmap_create_from_xpm_d(parent->window, &mask, &parent->style->white, (char **) xpm); - return gtk_pixmap_new(icon, mask); -#else GdkPixbuf * pixbuf; GdkPixmap * pixmap; GdkBitmap * bitmap; @@ -571,7 +518,6 @@ GtkWidget *xpm_to_widget_from_parent(GtkWidget *parent, const char ** xpm) { gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf, gtk_widget_get_colormap(parent), &pixmap, &bitmap, 128); return gtk_image_new_from_pixmap (pixmap, bitmap); -#endif } @@ -894,41 +840,18 @@ static GList *trees; static void setup_tree(GtkWidget *tree); static void forget_tree(GtkWidget *tree, gpointer data); static void set_tree_styles(GtkWidget *tree); -#if GTK_MAJOR_VERSION >= 2 static int tree_view_key_pressed_cb(GtkWidget *tree, GdkEventKey *event, gpointer user_data _U_); -#endif /* Create a Tree, give it the right styles, and remember it. */ -#if GTK_MAJOR_VERSION < 2 -GtkWidget * -ctree_new(gint columns, gint tree_column) -#else GtkWidget * tree_view_new(GtkTreeModel *model) -#endif { GtkWidget *tree; -#if GTK_MAJOR_VERSION < 2 - tree = gtk_ctree_new(columns, tree_column); -#else tree = gtk_tree_view_new_with_model(model); -#endif - setup_tree(tree); - return tree; -} - -#if GTK_MAJOR_VERSION < 2 -GtkWidget * -ctree_new_with_titles(gint columns, gint tree_column, const gchar *titles[]) -{ - GtkWidget *tree; - - tree = gtk_ctree_new_with_titles(columns, tree_column, (gchar **) titles); setup_tree(tree); return tree; } -#endif /* Set a Tree's styles and add it to the list of Trees. */ static void @@ -941,9 +864,7 @@ setup_tree(GtkWidget *tree) /* Catch the "destroy" event on the widget, so that we remove it from the list when it's destroyed. */ SIGNAL_CONNECT(tree, "destroy", forget_tree, NULL); -#if GTK_MAJOR_VERSION >= 2 SIGNAL_CONNECT(tree, "key-press-event", tree_view_key_pressed_cb, NULL ); -#endif } /* Remove a Tree from the list of Trees. */ @@ -957,19 +878,9 @@ forget_tree(GtkWidget *tree, gpointer data _U_) static void set_tree_styles(GtkWidget *tree) { -#if GTK_MAJOR_VERSION < 2 - g_assert(prefs.gui_ptree_line_style >= GTK_CTREE_LINES_NONE && - prefs.gui_ptree_line_style <= GTK_CTREE_LINES_TABBED); - gtk_ctree_set_line_style(GTK_CTREE(tree), prefs.gui_ptree_line_style); - g_assert(prefs.gui_ptree_expander_style >= GTK_CTREE_EXPANDER_NONE && - prefs.gui_ptree_expander_style <= GTK_CTREE_EXPANDER_CIRCULAR); - gtk_ctree_set_expander_style(GTK_CTREE(tree), - prefs.gui_ptree_expander_style); -#else g_assert(prefs.gui_altern_colors >= 0 && prefs.gui_altern_colors <= 1); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), prefs.gui_altern_colors); -#endif } static void @@ -987,23 +898,6 @@ set_tree_styles_all(void) - -#if GTK_MAJOR_VERSION < 2 -/* convert variable argument list of values to array of strings (GTK2 -> GTK1) */ -static void -simple_list_convert(gchar **ent, va_list ap) -{ - int i; - char *s; - - while( (i = va_arg(ap, int)) != -1 ) { - s = va_arg(ap, char *); - ent[i] = s; - } -} -#endif - - /* append a row to the simple list */ /* use it like: simple_list_append(list, 0, "first", 1, "second", -1) */ void @@ -1011,22 +905,13 @@ simple_list_append(GtkWidget *list, ...) { va_list ap; -#if GTK_MAJOR_VERSION < 2 - gchar *ent[10]; /* new entry added in clist */ -#else GtkTreeIter iter; GtkListStore *store; -#endif va_start(ap, list); -#if GTK_MAJOR_VERSION < 2 - simple_list_convert(ent, ap); - gtk_clist_append(GTK_CLIST(list), ent); -#else store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list))); gtk_list_store_append(store, &iter); gtk_list_store_set_valist(store, &iter, ap); -#endif va_end(ap); } @@ -1034,26 +919,12 @@ simple_list_append(GtkWidget *list, ...) GtkWidget * simple_list_new(gint cols, const gchar **titles) { GtkWidget *plugins_list; -#if GTK_MAJOR_VERSION >= 2 int i; GtkListStore *store; GtkCellRenderer *renderer; GtkTreeViewColumn *column; -#endif -#if GTK_MAJOR_VERSION < 2 - plugins_list = gtk_clist_new_with_titles(cols, (gchar **) titles); - gtk_clist_set_selection_mode(GTK_CLIST(plugins_list), GTK_SELECTION_SINGLE); - gtk_clist_column_titles_passive(GTK_CLIST(plugins_list)); - if(titles) { - gtk_clist_column_titles_show(GTK_CLIST(plugins_list)); - } else { - gtk_clist_column_titles_hide(GTK_CLIST(plugins_list)); - } - gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 0, TRUE); - gtk_clist_set_column_auto_resize(GTK_CLIST(plugins_list), 1, TRUE); -#else g_assert(cols <= 10); store = gtk_list_store_new(cols, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, @@ -1068,7 +939,6 @@ simple_list_new(gint cols, const gchar **titles) { gtk_tree_view_column_set_sort_column_id(column, i); gtk_tree_view_append_column(GTK_TREE_VIEW(plugins_list), column); } -#endif return plugins_list; } @@ -1076,23 +946,10 @@ simple_list_new(gint cols, const gchar **titles) { void copy_to_clipboard(GString *str) { -#if (GTK_MAJOR_VERSION >= 2) GtkClipboard *cb; cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Get the default clipboard */ gtk_clipboard_set_text(cb, str->str, -1); /* Copy the byte data into the clipboard */ -#else - GtkWidget *window; - GtkWidget *text; - - window = window_new (GTK_WINDOW_TOPLEVEL,""); - text = gtk_text_new (NULL, NULL); /* Create the GtkText widget */ - gtk_container_add (GTK_CONTAINER (window), text); /* Avoid a GTK assertion */ - gtk_widget_realize (text); /* Realizing a widget creates a window for it, ready for us to insert some text */ - gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, str->str, -1); - gtk_editable_select_region((GtkEditable *)text, 0, -1); /* Select ALL text */ - gtk_editable_copy_clipboard((GtkEditable *)text); /* Copy the byte data into the clipboard */ -#endif } @@ -1101,7 +958,6 @@ typedef struct _copy_binary_t { int len; } copy_binary_t; -#if GTK_MAJOR_VERSION >= 2 static copy_binary_t* create_copy_binary_t(const guint8* data, int len) { @@ -1164,7 +1020,6 @@ void copy_binary_to_clipboard(const guint8* data_p, int len) destroy_copy_binary_t(copy_data); } } -#endif /* GTK_MAJOR_VERSION >= 2 */ /* * Create a new window title string with user-defined title preference. @@ -1185,7 +1040,6 @@ create_user_window_title(const gchar *caption) } /* XXX move toggle_tree over from proto_draw.c to handle GTK+ 1 */ -#if GTK_MAJOR_VERSION >= 2 static int tree_view_key_pressed_cb(GtkWidget *tree, GdkEventKey *event, gpointer user_data _U_) { @@ -1251,6 +1105,5 @@ tree_view_key_pressed_cb(GtkWidget *tree, GdkEventKey *event, gpointer user_data return FALSE; } -#endif diff --git a/gtk/help_dlg.c b/gtk/help_dlg.c index 8a7a302af5..6a2615d2b1 100644 --- a/gtk/help_dlg.c +++ b/gtk/help_dlg.c @@ -80,7 +80,6 @@ static GSList *help_text_pages = NULL; gboolean topic_available(topic_action_e action) { -#if (GLIB_MAJOR_VERSION >= 2) if(action == HELP_CAPTURE_INTERFACES_DETAILS_DIALOG) { /* XXX - add the page HELP_CAPTURE_INTERFACES_DETAILS_DIALOG and remove this if */ /* page currently not existing in user's guide */ @@ -88,32 +87,9 @@ gboolean topic_available(topic_action_e action) { } /* online: we have almost all possible pages available */ return TRUE; -#else - /* offline: we have only some pages available */ - switch(action) { - case(HELP_CONTENT): - return TRUE; - break; - case(HELP_GETTING_STARTED): - return TRUE; - break; - case(HELP_CAPTURE_OPTIONS_DIALOG): - return TRUE; - break; - case(HELP_CAPTURE_FILTERS_DIALOG): - return TRUE; - break; - case(HELP_DISPLAY_FILTERS_DIALOG): - return TRUE; - break; - default: - return FALSE; - } -#endif } -#if (GLIB_MAJOR_VERSION >= 2) /* * Open the help dialog and show a specific HTML help page. */ @@ -151,181 +127,8 @@ void help_topic_html(const gchar *topic) { g_string_free(url, TRUE /* free_segment */); } -#endif - - -#if (GLIB_MAJOR_VERSION < 2) -/* - * Helper function to show a simple help text page. - */ -static GtkWidget * help_page(const char *topic, const char *filename) -{ - GtkWidget *text_page; - char *relative_path, *absolute_path; - help_page_t *page; - - relative_path = g_strconcat(HELP_DIR, G_DIR_SEPARATOR_S, filename, NULL); - absolute_path = get_datafile_path(relative_path); - text_page = text_page_new(absolute_path); - g_free(relative_path); - gtk_widget_show(text_page); - - page = g_malloc(sizeof (help_page_t)); - page->topic = g_strdup(topic); - page->pathname = absolute_path; - page->page = text_page; - help_text_pages = g_slist_append(help_text_pages, page); - - return text_page; -} - - -/* - * Help dialog is closed now. - */ -static void help_destroy_cb(GtkWidget *w _U_, gpointer data _U_) -{ - GSList *help_page_ent; - help_page_t *page; - - /* Free up the list of help pages. */ - for (help_page_ent = help_text_pages; help_page_ent != NULL; - help_page_ent = g_slist_next(help_page_ent)) { - page = (help_page_t *)help_page_ent->data; - g_free(page->topic); - g_free(page->pathname); - g_free(page); - } - g_slist_free(help_text_pages); - help_text_pages = NULL; - - /* Note that we no longer have a Help window. */ - help_w = NULL; -} -/* - * Create and show help dialog. - */ -static -void help_dialog(void) -{ - GtkWidget *main_vb, *bbox, *help_nb, *close_bt, *label, *topic_vb; - char line[4096+1]; /* XXX - size? */ - char *p; - char *filename; - char *help_toc_file_path; - FILE *help_toc_file; - - if (help_w != NULL) { - /* There's already a "Help" dialog box; reactivate it. */ - reactivate_window(help_w); - return; - } - - help_toc_file_path = get_datafile_path(HELP_DIR G_DIR_SEPARATOR_S "toc"); - help_toc_file = eth_fopen(help_toc_file_path, "r"); - if (help_toc_file == NULL) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open file \"%s\": %s", - help_toc_file_path, strerror(errno)); - g_free(help_toc_file_path); - return; - } - - help_w = window_new_with_geom(GTK_WINDOW_TOPLEVEL, "Wireshark: Help", "help"); - gtk_window_set_default_size(GTK_WINDOW(help_w), DEF_WIDTH, DEF_HEIGHT); - gtk_container_border_width(GTK_CONTAINER(help_w), 2); - - /* Container for each row of widgets */ - main_vb = gtk_vbox_new(FALSE, 1); - gtk_container_border_width(GTK_CONTAINER(main_vb), 1); - gtk_container_add(GTK_CONTAINER(help_w), main_vb); - - /* help topics container */ - help_nb = gtk_notebook_new(); - gtk_container_add(GTK_CONTAINER(main_vb), help_nb); - OBJECT_SET_DATA(help_w, NOTEBOOK_KEY, help_nb); - - /* help topics */ - while (fgets(line, sizeof line, help_toc_file) != NULL) { - /* Strip off line ending. */ - p = strpbrk(line, "\r\n"); - if (p == NULL) - break; /* last line has no line ending */ - *p = '\0'; - /* {Topic title}:{filename of help file} */ - p = strchr(line, ':'); - if (p != NULL) { - *p++ = '\0'; - filename = p; - - /* - * "line" refers to the topic now, and "filename" refers to the - * file name. - */ - topic_vb = help_page(line, filename); - label = gtk_label_new(line); - gtk_notebook_append_page(GTK_NOTEBOOK(help_nb), topic_vb, label); - } - } - if(ferror(help_toc_file)) { - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Error reading file \"%s\": %s", - help_toc_file_path, strerror(errno)); - } - fclose(help_toc_file); - - - /* Button row */ - bbox = dlg_button_row_new(GTK_STOCK_OK, NULL); - gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5); - - close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_OK); - window_set_cancel_button(help_w, close_bt, window_cancel_button_cb); - - SIGNAL_CONNECT(help_w, "delete_event", window_delete_event_cb, NULL); - SIGNAL_CONNECT(help_w, "destroy", help_destroy_cb, NULL); - - gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(help_w)); - - gtk_widget_show_all(help_w); - window_present(help_w); -} /* help_dialog */ - - -/* - * Open the help dialog and show a specific GTK help page. - */ -static void help_topic_gtk(const gchar *topic) { - gchar *page_topic; - GtkWidget *help_nb; - GSList *help_page_ent; - gint page_num = 0; - help_page_t *page; - - - /* show help dialog, if not already opened */ - help_dialog(); - - help_nb = OBJECT_GET_DATA(help_w, NOTEBOOK_KEY); - - /* find page to display */ - for (help_page_ent = help_text_pages; help_page_ent != NULL; - help_page_ent = g_slist_next(help_page_ent)) - { - page = (help_page_t *)help_page_ent->data; - page_topic = page->topic; - if (strcmp (page_topic, topic) == 0) { - /* topic page found, switch to notebook page */ - gtk_notebook_set_page(GTK_NOTEBOOK(help_nb), page_num); - return; - } - page_num++; - } - - /* topic page not found, default (first page) will be shown */ -} -#endif /* GLIB_MAJOR_VERSION < 2 */ - /** * Redraw all help pages, to use a new font. @@ -396,7 +199,6 @@ topic_action(topic_action_e action) browser_open_data_file("text2pcap.html"); break; -#if (GLIB_MAJOR_VERSION >= 2) /* local help pages (User's Guide) */ case(HELP_CONTENT): help_topic_html( "index.html"); @@ -496,24 +298,6 @@ topic_action(topic_action_e action) case(HELP_SAVE_WIN32_DIALOG): help_topic_html("ChIOSaveSection.html"); break; -#else - /* only some help pages are available for offline reading */ - case(HELP_CONTENT): - help_topic_gtk("Overview"); - break; - case(HELP_GETTING_STARTED): - help_topic_gtk("Getting Started"); - break; - case(HELP_CAPTURE_OPTIONS_DIALOG): - help_topic_gtk("Capturing"); - break; - case(HELP_CAPTURE_FILTERS_DIALOG): - help_topic_gtk("Capture Filters"); - break; - case(HELP_DISPLAY_FILTERS_DIALOG): - help_topic_gtk("Display Filters"); - break; -#endif /* GLIB_MAJOR_VERSION */ default: g_assert_not_reached(); |