diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index 74a804355..13a2ed58d 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -87,22 +87,16 @@ static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data) struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;\ return nsgtk_on_##q##_activate(g);\ }\ -static gboolean nsgtk_on_##q##_activate_button(GtkButton *widget, gpointer data)\ -{\ - struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;\ - return nsgtk_on_##q##_activate(g);\ -}\ static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g) -/** Macro to define a handler for menu events. */ -#define MENUHANDLER(q)\ -static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data) /** Macro to define a handler for button events. */ #define BUTTONHANDLER(q)\ static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data) - +/** + * menu entry context + */ struct nsgtk_menu { GtkWidget *main; /* main menu entry */ GtkWidget *rclick; /* right click menu */ @@ -111,7 +105,9 @@ struct nsgtk_menu { bool sensitivity; /* menu item is sensitive */ }; -/** Core scaffolding structure. */ +/** + * Core scaffolding structure. + */ struct nsgtk_scaffolding { /** global linked list of scaffolding for gui interface adjustments */ struct nsgtk_scaffolding *next, *prev; @@ -146,7 +142,9 @@ struct nsgtk_scaffolding { struct nsgtk_menu menus[PLACEHOLDER_BUTTON]; }; -/** current scaffold for model dialogue use */ +/** + * current scaffold for model dialogue use + */ static struct nsgtk_scaffolding *scaf_current; /** global list for interface changes */ @@ -336,8 +334,6 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g) } - - /** * edit the sensitivity of focused widget * @@ -727,16 +723,19 @@ MULTIHANDLER(savepage) if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level))) return FALSE; - GtkWidget *fc = gtk_file_chooser_dialog_new( + GtkWidget *fc; + DIR *d; + char *path; + nserror res; + GtkFileFilter *filter; + + fc = gtk_file_chooser_dialog_new( messages_get("gtkcompleteSave"), g->window, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NSGTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - DIR *d; - char *path; - nserror res; - GtkFileFilter *filter = gtk_file_filter_new(); + filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, "Directories"); gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME, nsgtk_filter_directory, NULL, NULL); @@ -1023,7 +1022,9 @@ MULTIHANDLER(quit) return TRUE; } -MENUHANDLER(savelink) + +static gboolean +nsgtk_on_savelink_activate_menu(GtkMenuItem *widget, gpointer data) { struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data; struct gui_window *gui = g->top_level; @@ -1050,7 +1051,8 @@ MENUHANDLER(savelink) /** * Handler for opening new window from a link. attached to the popup menu. */ -MENUHANDLER(link_openwin) +static gboolean +nsgtk_on_link_openwin_activate_menu(GtkMenuItem *widget, gpointer data) { struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data; struct gui_window *gui = g->top_level; @@ -1072,7 +1074,8 @@ MENUHANDLER(link_openwin) /** * Handler for opening new tab from a link. attached to the popup menu. */ -MENUHANDLER(link_opentab) +static gboolean +nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data) { struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data; struct gui_window *gui = g->top_level; @@ -1100,7 +1103,8 @@ MENUHANDLER(link_opentab) /** * Handler for bookmarking a link. attached to the popup menu. */ -MENUHANDLER(link_bookmark) +static gboolean +nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data) { if (current_menu_features.link == NULL) return FALSE; @@ -1113,7 +1117,8 @@ MENUHANDLER(link_bookmark) /** * Handler for copying a link. attached to the popup menu. */ -MENUHANDLER(link_copy) +static gboolean +nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data) { GtkClipboard *clipboard; @@ -1177,7 +1182,9 @@ MULTIHANDLER(delete) return TRUE; } -MENUHANDLER(customize) + +static gboolean +nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data) { struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; nsgtk_toolbar_customization_init(g); @@ -1272,7 +1279,9 @@ MULTIHANDLER(viewsource) return TRUE; } -MENUHANDLER(menubar) + +static gboolean +nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data) { GtkWidget *w; struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; @@ -1318,7 +1327,9 @@ MENUHANDLER(menubar) return TRUE; } -MENUHANDLER(toolbar) + +static gboolean +nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data) { GtkWidget *w; struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; @@ -1751,6 +1762,7 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g) } + /** * Create and connect handlers to popup menu. * @@ -1769,20 +1781,30 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group) return NULL; } - g_signal_connect(nmenu->popup_menu, "hide", - G_CALLBACK(nsgtk_window_popup_menu_hidden), g); + g_signal_connect(nmenu->popup_menu, + "hide", + G_CALLBACK(nsgtk_window_popup_menu_hidden), + g); - g_signal_connect(nmenu->cut_menuitem, "activate", - G_CALLBACK(nsgtk_on_cut_activate_menu), g); + g_signal_connect(nmenu->cut_menuitem, + "activate", + G_CALLBACK(nsgtk_on_cut_activate_menu), + g); - g_signal_connect(nmenu->copy_menuitem, "activate", - G_CALLBACK(nsgtk_on_copy_activate_menu), g); + g_signal_connect(nmenu->copy_menuitem, + "activate", + G_CALLBACK(nsgtk_on_copy_activate_menu), + g); - g_signal_connect(nmenu->paste_menuitem, "activate", - G_CALLBACK(nsgtk_on_paste_activate_menu), g); + g_signal_connect(nmenu->paste_menuitem, + "activate", + G_CALLBACK(nsgtk_on_paste_activate_menu), + g); - g_signal_connect(nmenu->customize_menuitem, "activate", - G_CALLBACK(nsgtk_on_customize_activate_menu), g); + g_signal_connect(nmenu->customize_menuitem, + "activate", + G_CALLBACK(nsgtk_on_customize_activate_menu), + g); /* set initial popup menu visibility */ popup_menu_hide(nmenu, true, false, false, true); @@ -1798,7 +1820,8 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group) * \return true on success or false on error. */ static struct nsgtk_link_menu * -nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group) +nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g, + GtkAccelGroup *group) { struct nsgtk_link_menu *nmenu; @@ -1808,20 +1831,30 @@ nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *gro return NULL; } - g_signal_connect(nmenu->save_menuitem, "activate", - G_CALLBACK(nsgtk_on_savelink_activate_menu), g); + g_signal_connect(nmenu->save_menuitem, + "activate", + G_CALLBACK(nsgtk_on_savelink_activate_menu), + g); - g_signal_connect(nmenu->opentab_menuitem, "activate", - G_CALLBACK(nsgtk_on_link_opentab_activate_menu), g); + g_signal_connect(nmenu->opentab_menuitem, + "activate", + G_CALLBACK(nsgtk_on_link_opentab_activate_menu), + g); - g_signal_connect(nmenu->openwin_menuitem, "activate", - G_CALLBACK(nsgtk_on_link_openwin_activate_menu), g); + g_signal_connect(nmenu->openwin_menuitem, + "activate", + G_CALLBACK(nsgtk_on_link_openwin_activate_menu), + g); - g_signal_connect(nmenu->bookmark_menuitem, "activate", - G_CALLBACK(nsgtk_on_link_bookmark_activate_menu), g); + g_signal_connect(nmenu->bookmark_menuitem, + "activate", + G_CALLBACK(nsgtk_on_link_bookmark_activate_menu), + g); - g_signal_connect(nmenu->copy_menuitem, "activate", - G_CALLBACK(nsgtk_on_link_copy_activate_menu), g); + g_signal_connect(nmenu->copy_menuitem, + "activate", + G_CALLBACK(nsgtk_on_link_copy_activate_menu), + g); return nmenu; } diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c index bf7f1efb2..b1cd51c15 100644 --- a/frontends/gtk/toolbar.c +++ b/frontends/gtk/toolbar.c @@ -65,16 +65,16 @@ */ struct nsgtk_toolbar_item { GtkToolItem *button; - int location; /* in toolbar */ - bool sensitivity; + int location; /* in toolbar */ + bool sensitivity; /** * button clicked handler */ gboolean (*bhandler)(GtkWidget *widget, gpointer data); - void *dataplus; /* customization -> toolbar */ - void *dataminus; /* customization -> store */ + void *dataplus; /* customization -> toolbar */ + void *dataminus; /* customization -> store */ }; @@ -225,39 +225,39 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton, switch(tbbutton) { -#define BUTTON_IMAGE(p, q) \ +#define BUTTON_IMAGE(p, q) \ case p##_BUTTON: \ image = GTK_IMAGE(nsgtk_image_new_from_stock(q, iconsize)); \ break - BUTTON_IMAGE(BACK, NSGTK_STOCK_GO_BACK); - BUTTON_IMAGE(FORWARD, NSGTK_STOCK_GO_FORWARD); - BUTTON_IMAGE(STOP, NSGTK_STOCK_STOP); - BUTTON_IMAGE(RELOAD, NSGTK_STOCK_REFRESH); - BUTTON_IMAGE(HOME, NSGTK_STOCK_HOME); - BUTTON_IMAGE(NEWWINDOW, "gtk-new"); - BUTTON_IMAGE(NEWTAB, "gtk-new"); - BUTTON_IMAGE(OPENFILE, NSGTK_STOCK_OPEN); - BUTTON_IMAGE(CLOSETAB, NSGTK_STOCK_CLOSE); - BUTTON_IMAGE(CLOSEWINDOW, NSGTK_STOCK_CLOSE); - BUTTON_IMAGE(SAVEPAGE, NSGTK_STOCK_SAVE_AS); - BUTTON_IMAGE(PRINTPREVIEW, "gtk-print-preview"); - BUTTON_IMAGE(PRINT, "gtk-print"); - BUTTON_IMAGE(QUIT, "gtk-quit"); - BUTTON_IMAGE(CUT, "gtk-cut"); - BUTTON_IMAGE(COPY, "gtk-copy"); - BUTTON_IMAGE(PASTE, "gtk-paste"); - BUTTON_IMAGE(DELETE, "gtk-delete"); - BUTTON_IMAGE(SELECTALL, "gtk-select-all"); - BUTTON_IMAGE(FIND, NSGTK_STOCK_FIND); - BUTTON_IMAGE(PREFERENCES, "gtk-preferences"); - BUTTON_IMAGE(ZOOMPLUS, "gtk-zoom-in"); - BUTTON_IMAGE(ZOOMMINUS, "gtk-zoom-out"); - BUTTON_IMAGE(ZOOMNORMAL, "gtk-zoom-100"); - BUTTON_IMAGE(FULLSCREEN, "gtk-fullscreen"); - BUTTON_IMAGE(VIEWSOURCE, "gtk-index"); - BUTTON_IMAGE(CONTENTS, "gtk-help"); - BUTTON_IMAGE(ABOUT, "gtk-about"); + BUTTON_IMAGE(BACK, NSGTK_STOCK_GO_BACK); + BUTTON_IMAGE(FORWARD, NSGTK_STOCK_GO_FORWARD); + BUTTON_IMAGE(STOP, NSGTK_STOCK_STOP); + BUTTON_IMAGE(RELOAD, NSGTK_STOCK_REFRESH); + BUTTON_IMAGE(HOME, NSGTK_STOCK_HOME); + BUTTON_IMAGE(NEWWINDOW, "gtk-new"); + BUTTON_IMAGE(NEWTAB, "gtk-new"); + BUTTON_IMAGE(OPENFILE, NSGTK_STOCK_OPEN); + BUTTON_IMAGE(CLOSETAB, NSGTK_STOCK_CLOSE); + BUTTON_IMAGE(CLOSEWINDOW, NSGTK_STOCK_CLOSE); + BUTTON_IMAGE(SAVEPAGE, NSGTK_STOCK_SAVE_AS); + BUTTON_IMAGE(PRINTPREVIEW, "gtk-print-preview"); + BUTTON_IMAGE(PRINT, "gtk-print"); + BUTTON_IMAGE(QUIT, "gtk-quit"); + BUTTON_IMAGE(CUT, "gtk-cut"); + BUTTON_IMAGE(COPY, "gtk-copy"); + BUTTON_IMAGE(PASTE, "gtk-paste"); + BUTTON_IMAGE(DELETE, "gtk-delete"); + BUTTON_IMAGE(SELECTALL, "gtk-select-all"); + BUTTON_IMAGE(FIND, NSGTK_STOCK_FIND); + BUTTON_IMAGE(PREFERENCES, "gtk-preferences"); + BUTTON_IMAGE(ZOOMPLUS, "gtk-zoom-in"); + BUTTON_IMAGE(ZOOMMINUS, "gtk-zoom-out"); + BUTTON_IMAGE(ZOOMNORMAL, "gtk-zoom-100"); + BUTTON_IMAGE(FULLSCREEN, "gtk-fullscreen"); + BUTTON_IMAGE(VIEWSOURCE, "gtk-index"); + BUTTON_IMAGE(CONTENTS, "gtk-help"); + BUTTON_IMAGE(ABOUT, "gtk-about"); #undef BUTTON_IMAGE case HISTORY_BUTTON: @@ -411,7 +411,8 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g) gtk_widget_show_all(GTK_WIDGET(button->popup)); } #endif - if ((button->location != -1) && (button->button != NULL) && + if ((button->location != -1) && + (button->button != NULL) && (theme[IMAGE_SET_BUTTONS] != NULL)) { gtk_tool_button_set_icon_widget( GTK_TOOL_BUTTON(button->button), @@ -2017,7 +2018,7 @@ static gboolean websearch_entry_activate_cb(GtkWidget *widget, gpointer data) * \return TRUE */ static gboolean -websearch_entry_button_press(GtkWidget *widget, +websearch_entry_button_press_cb(GtkWidget *widget, GdkEventFocus *f, gpointer data) { @@ -2174,7 +2175,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid) tb); g_signal_connect(GTK_WIDGET(entry), "button-press-event", - G_CALLBACK(websearch_entry_button_press), + G_CALLBACK(websearch_entry_button_press_cb), tb); break;