diff options
author | Vincent Sanders <vince@kyllikki.org> | 2014-07-27 18:06:07 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2014-07-27 18:07:00 +0100 |
commit | 55669387ffcb802307e91deb7027f17b8de20e00 (patch) | |
tree | c567160e413d1fdc3160708f98e1120b835fa791 /gtk/toolbar.c | |
parent | 06a1d75d52dc533474194c0c9b33eecf09b59068 (diff) | |
download | netsurf-55669387ffcb802307e91deb7027f17b8de20e00.tar.gz netsurf-55669387ffcb802307e91deb7027f17b8de20e00.tar.bz2 |
clean up gtk scaffolding interface, remove lots of cruft and globals
Diffstat (limited to 'gtk/toolbar.c')
-rw-r--r-- | gtk/toolbar.c | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/gtk/toolbar.c b/gtk/toolbar.c index 39d8cf510..845344757 100644 --- a/gtk/toolbar.c +++ b/gtk/toolbar.c @@ -67,11 +67,10 @@ possible into the store */ static struct nsgtk_toolbar_custom_store store; static struct nsgtk_toolbar_custom_store *window = &store; -static void nsgtk_toolbar_close(nsgtk_scaffolding *g); -static void nsgtk_toolbar_window_open(nsgtk_scaffolding *g); -static void nsgtk_toolbar_customization_save(nsgtk_scaffolding *g); -static void nsgtk_toolbar_add_item_to_toolbar(nsgtk_scaffolding *g, int i, - struct nsgtk_theme *theme); +static void nsgtk_toolbar_close(struct nsgtk_scaffolding *g); +static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g); +static void nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g); +static void nsgtk_toolbar_add_item_to_toolbar(struct nsgtk_scaffolding *g, int i, struct nsgtk_theme *theme); static bool nsgtk_toolbar_add_store_widget(GtkWidget *widget); static gboolean nsgtk_toolbar_data(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer data); @@ -90,28 +89,30 @@ static gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event, static gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data); static gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data); static gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data); -static void nsgtk_toolbar_cast(nsgtk_scaffolding *g); -static GtkWidget *nsgtk_toolbar_make_widget(nsgtk_scaffolding *g, +static void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g); +static GtkWidget *nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i, struct nsgtk_theme *theme); -static void nsgtk_toolbar_set_handler(nsgtk_scaffolding *g, +static void nsgtk_toolbar_set_handler(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i); -static void nsgtk_toolbar_temp_connect(nsgtk_scaffolding *g, +static void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i); static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data); static nsgtk_toolbar_button nsgtk_toolbar_get_id_at_location( - nsgtk_scaffolding *g, int i); + struct nsgtk_scaffolding *g, int i); /** - * change behaviour of scaffoldings while editing toolbar; all buttons as - * well as window clicks are desensitized; then buttons in the front window - * are changed to movable buttons + * change behaviour of scaffoldings while editing toolbar + * + * All buttons as well as window clicks are desensitized; then buttons + * in the front window are changed to movable buttons */ -void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g) +void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g) { int i; - nsgtk_scaffolding *list = scaf_list; + struct nsgtk_scaffolding *list; edit_mode = true; + list = nsgtk_scaffolding_iterate(NULL); while (list) { g_signal_handler_block(GTK_WIDGET( nsgtk_window_get_layout( @@ -187,7 +188,7 @@ void nsgtk_toolbar_customization_init(nsgtk_scaffolding *g) /** * create store window */ -void nsgtk_toolbar_window_open(nsgtk_scaffolding *g) +void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) { int x = 0, y = 0; GError* error = NULL; @@ -286,7 +287,7 @@ gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event, gpointer data) { edit_mode = false; - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; /* reset g->buttons->location */ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { nsgtk_scaffolding_button(g, i)->location = @@ -306,7 +307,7 @@ gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event, gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data) { edit_mode = false; - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; /* reset g->buttons->location */ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { nsgtk_scaffolding_button(g, i)->location = @@ -326,7 +327,7 @@ gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data) gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data) { edit_mode = false; - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; /* save state to file, update toolbars for all windows */ nsgtk_toolbar_customization_save(g); nsgtk_toolbar_cast(g); @@ -341,7 +342,7 @@ gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data) */ gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data) { - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; int i; for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) nsgtk_scaffolding_button(g, i)->location = @@ -365,7 +366,7 @@ gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data) * to correspond to the logically stored schema in terms of location * visibility etc */ -void nsgtk_toolbar_set_physical(nsgtk_scaffolding *g) +void nsgtk_toolbar_set_physical(struct nsgtk_scaffolding *g) { int i; struct nsgtk_theme *theme = @@ -387,13 +388,16 @@ void nsgtk_toolbar_set_physical(nsgtk_scaffolding *g) * cleanup code physical update of all toolbars; resensitize * \param g the 'front' scaffolding that called customize */ -void nsgtk_toolbar_close(nsgtk_scaffolding *g) +void nsgtk_toolbar_close(struct nsgtk_scaffolding *g) { int i; - nsgtk_scaffolding *list = scaf_list; + + struct nsgtk_scaffolding *list; + struct nsgtk_theme *theme; + + list = nsgtk_scaffolding_iterate(NULL); while (list) { - struct nsgtk_theme *theme = - nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR); + theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR); if (theme == NULL) { warn_user(messages_get("NoMemory"), 0); continue; @@ -447,7 +451,7 @@ void nsgtk_toolbar_close(nsgtk_scaffolding *g) */ void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data) { - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; gtk_container_remove(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)), widget); } @@ -458,7 +462,7 @@ void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data) * the function should be called, when multiple items are being added, * in ascending order */ -void nsgtk_toolbar_add_item_to_toolbar(nsgtk_scaffolding *g, int i, +void nsgtk_toolbar_add_item_to_toolbar(struct nsgtk_scaffolding *g, int i, struct nsgtk_theme *theme) { int q; @@ -510,7 +514,7 @@ bool nsgtk_toolbar_add_store_widget(GtkWidget *widget) gboolean nsgtk_toolbar_data(GtkWidget *widget, GdkDragContext *gdc, gint x, gint y, guint time, gpointer data) { - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g), x, y); int q, i; @@ -602,7 +606,7 @@ gboolean nsgtk_toolbar_move_complete(GtkWidget *widget, GdkDragContext *gdc, gboolean nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc, gint x, gint y, guint time, gpointer data) { - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; int q, i; if ((window->fromstore) || (window->currentbutton == -1)) { @@ -637,7 +641,7 @@ gboolean nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc, gboolean nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x, gint y, guint time, gpointer data) { - nsgtk_scaffolding *g = (nsgtk_scaffolding *)data; + struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data; GtkToolItem *item = gtk_tool_button_new(NULL, NULL); if (item != NULL) gtk_toolbar_set_drop_highlight_item( @@ -671,7 +675,7 @@ void nsgtk_toolbar_clear(GtkWidget *widget, GdkDragContext *gdc, guint time, * \param i the id of the widget * \param theme the theme to make the widgets from */ -GtkWidget *nsgtk_toolbar_make_widget(nsgtk_scaffolding *g, +GtkWidget *nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i, struct nsgtk_theme *theme) { switch(i) { @@ -829,7 +833,7 @@ GtkWidget *nsgtk_toolbar_make_widget(nsgtk_scaffolding *g, * \return toolbar item id when a widget is an element of the scaffolding * else -1 */ -int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, nsgtk_scaffolding *g) +int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g) { int i; for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { @@ -846,8 +850,8 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, nsgtk_scaffolding *g) * \return toolbar item id from location when there is an item at that logical * location; else -1 */ -nsgtk_toolbar_button nsgtk_toolbar_get_id_at_location(nsgtk_scaffolding *g, - int i) +nsgtk_toolbar_button +nsgtk_toolbar_get_id_at_location(struct nsgtk_scaffolding *g, int i) { int q; for (q = BACK_BUTTON; q < PLACEHOLDER_BUTTON; q++) @@ -860,7 +864,7 @@ nsgtk_toolbar_button nsgtk_toolbar_get_id_at_location(nsgtk_scaffolding *g, * connect 'normal' handlers to toolbar buttons */ -void nsgtk_toolbar_connect_all(nsgtk_scaffolding *g) +void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g) { int q, i; for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { @@ -882,7 +886,8 @@ void nsgtk_toolbar_connect_all(nsgtk_scaffolding *g) * \param g the scaffolding to attach handlers to * \param i the toolbar item id */ -void nsgtk_toolbar_set_handler(nsgtk_scaffolding *g, nsgtk_toolbar_button i) +void +nsgtk_toolbar_set_handler(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i) { switch(i){ case URL_BAR_ITEM: @@ -1010,7 +1015,7 @@ DATAHANDLER(websearch, WEBSEARCH, window) /** * connect temporary handler for toolbar edit events */ -void nsgtk_toolbar_temp_connect(nsgtk_scaffolding *g, nsgtk_toolbar_button i) +void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i) { if ((i == URL_BAR_ITEM) || (nsgtk_scaffolding_button(g, i)->button == NULL) || @@ -1025,7 +1030,7 @@ void nsgtk_toolbar_temp_connect(nsgtk_scaffolding *g, nsgtk_toolbar_button i) * load toolbar settings from file; file is a set of fields arranged as * [itemreference];[itemlocation]|[itemreference];[itemlocation]| etc */ -void nsgtk_toolbar_customization_load(nsgtk_scaffolding *g) +void nsgtk_toolbar_customization_load(struct nsgtk_scaffolding *g) { int i, ii; char *val; @@ -1066,17 +1071,21 @@ void nsgtk_toolbar_customization_load(nsgtk_scaffolding *g) * cast toolbar settings to all scaffoldings referenced from the global linked * list of gui_windows */ -void nsgtk_toolbar_cast(nsgtk_scaffolding *g) +void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g) { int i; - nsgtk_scaffolding *list = scaf_list; - for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) + struct nsgtk_scaffolding *list; + + for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { window->buttonlocations[i] = ((nsgtk_scaffolding_button(g, i)->location >= -1) && (nsgtk_scaffolding_button(g, i)->location < PLACEHOLDER_BUTTON)) ? nsgtk_scaffolding_button(g, i)->location : -1; + } + + list = nsgtk_scaffolding_iterate(NULL); while (list) { if (list != g) for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) @@ -1089,7 +1098,7 @@ void nsgtk_toolbar_cast(nsgtk_scaffolding *g) /** * save toolbar settings to file */ -void nsgtk_toolbar_customization_save(nsgtk_scaffolding *g) +void nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g) { int i; FILE *f = fopen(toolbar_indices_file_location, "w"); |