Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/636c5c013f2b7f747843c4609169bcd480434414
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/636c5c013f2b7f747843c4609169bcd480434414
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/636c5c013f2b7f747843c4609169bcd480434414

The branch, vince/gtk-tab-restyle has been updated
       via  636c5c013f2b7f747843c4609169bcd480434414 (commit)
      from  feaaf39cf0602875c8a504d40cc7f8deb287fbc8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=636c5c013f2b7f747843c4609169bcd480434414
commit 636c5c013f2b7f747843c4609169bcd480434414
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    allow toolbar customisation to remove widgets from the toolbar

diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 7184ead..dca1524 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1205,52 +1205,7 @@ static gboolean nsgtk_toolbar_delete(GtkWidget *widget, 
GdkEvent *event,
        return TRUE;
 }
 
-/**
- * called when a widget is dropped onto the store window
- */
-static gboolean
-nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc,
-               gint x, gint y, guint time, gpointer data)
-{
-       struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
-       int q, i;
 
-       if ((window->fromstore) || (window->currentbutton == -1)) {
-               window->currentbutton = -1;
-               return FALSE;
-       }
-       if (nsgtk_scaffolding_button(g, window->currentbutton)->location
-                       != -1) {
-               /* 'move' all widgets further right, one place to the left
-                * in logical schema */
-               for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
-                               location + 1; i < PLACEHOLDER_BUTTON; i++) {
-                       q = nsgtk_toolbar_get_id_at_location(g, i);
-                       if (q == -1)
-                               continue;
-                       nsgtk_scaffolding_button(g, q)->location--;
-               }
-               gtk_container_remove(GTK_CONTAINER(
-                               nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
-                               nsgtk_scaffolding_button(g,
-                               window->currentbutton)->button));
-               nsgtk_scaffolding_button(g, window->currentbutton)->location
-                               = -1;
-       }
-       window->currentbutton = -1;
-       gtk_drag_finish(gdc, TRUE, TRUE, time);
-       return FALSE;
-}
-
-/**
- * called when hovering above the store
- */
-static gboolean
-nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc,
-               gint x, gint y, guint time, gpointer data)
-{
-       return FALSE;
-}
 
 /**
  * create store window
@@ -1446,8 +1401,94 @@ void nsgtk_toolbar_customisation_init(struct 
nsgtk_scaffolding *g)
 }
 #endif
 
+/**
+ * find the toolbar item with a given location.
+ *
+ * \param tb the toolbar instance
+ * \param locaction the location to search for
+ * \return the item id for a location
+ */
+static nsgtk_toolbar_button
+itemid_from_location(struct nsgtk_toolbar *tb, int location)
+{
+       int iidx;
+       for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+               if (tb->buttons[iidx]->location == location) {
+                       break;
+               }
+       }
+       return iidx;
+}
+
+
+/**
+ * customisation container handler for drag drop signal
+ *
+ * called when a widget is dropped onto the store window
+ */
+static gboolean
+customisation_container_drag_drop_cb(GtkWidget *widget,
+                                    GdkDragContext *gdc,
+                                    gint x, gint y,
+                                    guint time,
+                                    gpointer data)
+{
+       struct nsgtk_toolbar_customisation *tbc;
+       tbc = (struct nsgtk_toolbar_customisation *)data;
+       int location;
+       int itemid;
+
+       if ((tbc->dragfrom) || (tbc->dragitem == -1)) {
+               tbc->dragitem = -1;
+               return FALSE;
+       }
+
+       if (tbc->toolbar.buttons[tbc->dragitem]->location == INACTIVE_LOCATION) 
{
+               tbc->dragitem = -1;
+               gtk_drag_finish(gdc, TRUE, TRUE, time);
+               return FALSE;
+
+       }
+
+       /* update the locations for all the subsequent toolbar items */
+       for (location = tbc->toolbar.buttons[tbc->dragitem]->location;
+            location < PLACEHOLDER_BUTTON;
+            location++) {
+               itemid = itemid_from_location(&tbc->toolbar, location);
+               if (itemid == PLACEHOLDER_BUTTON) {
+                       break;
+               }
+               tbc->toolbar.buttons[itemid]->location--;
+       }
+
+       tbc->toolbar.buttons[tbc->dragitem]->location = -1;
+       gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
+                            
GTK_WIDGET(tbc->toolbar.buttons[tbc->dragitem]->button));
+
+       tbc->dragitem = -1;
+       gtk_drag_finish(gdc, TRUE, TRUE, time);
+       return FALSE;
+}
+
+/**
+ * customisation container handler for drag motion signal
+ *
+ * called when hovering above the store
+ */
+static gboolean
+customisation_container_drag_motion_cb(GtkWidget *widget,
+                                      GdkDragContext *gdc,
+                                      gint x, gint y,
+                                      guint time,
+                                      gpointer data)
+{
+       return FALSE;
+}
+
 
 /**
+ * customisation toolbar handler for drag drop signal
+ *
  * called when a widget is dropped onto the toolbar
  */
 static gboolean
@@ -1814,24 +1855,6 @@ static nserror populate_gtk_toolbar_widget(struct 
nsgtk_toolbar *tb)
 }
 
 
-/**
- * find the toolbar item with a given location.
- *
- * \param tb the toolbar instance
- * \param locaction the location to search for
- * \return the item id for a location
- */
-static nsgtk_toolbar_button
-itemid_from_location(struct nsgtk_toolbar *tb, int location)
-{
-       int iidx;
-       for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
-               if (tb->buttons[iidx]->location == location) {
-                       break;
-               }
-       }
-       return iidx;
-}
 
 /**
  * find the toolbar item with a given gtk widget.
@@ -2275,7 +2298,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget 
*widget, gpointer data)
                                 tbc->container);
 
 #if 0
-       g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "close")),
+       g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "apply")),
                         "clicked",
                         G_CALLBACK(nsgtk_toolbar_persist),
                         g);
@@ -2290,16 +2313,17 @@ static gboolean cutomize_button_clicked_cb(GtkWidget 
*widget, gpointer data)
                         G_CALLBACK(nsgtk_toolbar_delete),
                         g);
 
+
+#endif
        g_signal_connect(tbc->container,
                         "drag-drop",
-                        G_CALLBACK(nsgtk_toolbar_store_return),
-                        g);
+                        G_CALLBACK(customisation_container_drag_drop_cb),
+                        tbc);
 
        g_signal_connect(tbc->container,
                         "drag-motion",
-                        G_CALLBACK(nsgtk_toolbar_store_action),
-                        g);
-#endif
+                        G_CALLBACK(customisation_container_drag_motion_cb),
+                        tbc);
 
 
        nsgtk_tab_add_page(notebook,


-----------------------------------------------------------------------

Summary of changes:
 frontends/gtk/toolbar.c |  162 +++++++++++++++++++++++++++--------------------
 1 file changed, 93 insertions(+), 69 deletions(-)

diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 7184ead..dca1524 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1205,52 +1205,7 @@ static gboolean nsgtk_toolbar_delete(GtkWidget *widget, 
GdkEvent *event,
        return TRUE;
 }
 
-/**
- * called when a widget is dropped onto the store window
- */
-static gboolean
-nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc,
-               gint x, gint y, guint time, gpointer data)
-{
-       struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
-       int q, i;
 
-       if ((window->fromstore) || (window->currentbutton == -1)) {
-               window->currentbutton = -1;
-               return FALSE;
-       }
-       if (nsgtk_scaffolding_button(g, window->currentbutton)->location
-                       != -1) {
-               /* 'move' all widgets further right, one place to the left
-                * in logical schema */
-               for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
-                               location + 1; i < PLACEHOLDER_BUTTON; i++) {
-                       q = nsgtk_toolbar_get_id_at_location(g, i);
-                       if (q == -1)
-                               continue;
-                       nsgtk_scaffolding_button(g, q)->location--;
-               }
-               gtk_container_remove(GTK_CONTAINER(
-                               nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
-                               nsgtk_scaffolding_button(g,
-                               window->currentbutton)->button));
-               nsgtk_scaffolding_button(g, window->currentbutton)->location
-                               = -1;
-       }
-       window->currentbutton = -1;
-       gtk_drag_finish(gdc, TRUE, TRUE, time);
-       return FALSE;
-}
-
-/**
- * called when hovering above the store
- */
-static gboolean
-nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc,
-               gint x, gint y, guint time, gpointer data)
-{
-       return FALSE;
-}
 
 /**
  * create store window
@@ -1446,8 +1401,94 @@ void nsgtk_toolbar_customisation_init(struct 
nsgtk_scaffolding *g)
 }
 #endif
 
+/**
+ * find the toolbar item with a given location.
+ *
+ * \param tb the toolbar instance
+ * \param locaction the location to search for
+ * \return the item id for a location
+ */
+static nsgtk_toolbar_button
+itemid_from_location(struct nsgtk_toolbar *tb, int location)
+{
+       int iidx;
+       for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+               if (tb->buttons[iidx]->location == location) {
+                       break;
+               }
+       }
+       return iidx;
+}
+
+
+/**
+ * customisation container handler for drag drop signal
+ *
+ * called when a widget is dropped onto the store window
+ */
+static gboolean
+customisation_container_drag_drop_cb(GtkWidget *widget,
+                                    GdkDragContext *gdc,
+                                    gint x, gint y,
+                                    guint time,
+                                    gpointer data)
+{
+       struct nsgtk_toolbar_customisation *tbc;
+       tbc = (struct nsgtk_toolbar_customisation *)data;
+       int location;
+       int itemid;
+
+       if ((tbc->dragfrom) || (tbc->dragitem == -1)) {
+               tbc->dragitem = -1;
+               return FALSE;
+       }
+
+       if (tbc->toolbar.buttons[tbc->dragitem]->location == INACTIVE_LOCATION) 
{
+               tbc->dragitem = -1;
+               gtk_drag_finish(gdc, TRUE, TRUE, time);
+               return FALSE;
+
+       }
+
+       /* update the locations for all the subsequent toolbar items */
+       for (location = tbc->toolbar.buttons[tbc->dragitem]->location;
+            location < PLACEHOLDER_BUTTON;
+            location++) {
+               itemid = itemid_from_location(&tbc->toolbar, location);
+               if (itemid == PLACEHOLDER_BUTTON) {
+                       break;
+               }
+               tbc->toolbar.buttons[itemid]->location--;
+       }
+
+       tbc->toolbar.buttons[tbc->dragitem]->location = -1;
+       gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
+                            
GTK_WIDGET(tbc->toolbar.buttons[tbc->dragitem]->button));
+
+       tbc->dragitem = -1;
+       gtk_drag_finish(gdc, TRUE, TRUE, time);
+       return FALSE;
+}
+
+/**
+ * customisation container handler for drag motion signal
+ *
+ * called when hovering above the store
+ */
+static gboolean
+customisation_container_drag_motion_cb(GtkWidget *widget,
+                                      GdkDragContext *gdc,
+                                      gint x, gint y,
+                                      guint time,
+                                      gpointer data)
+{
+       return FALSE;
+}
+
 
 /**
+ * customisation toolbar handler for drag drop signal
+ *
  * called when a widget is dropped onto the toolbar
  */
 static gboolean
@@ -1814,24 +1855,6 @@ static nserror populate_gtk_toolbar_widget(struct 
nsgtk_toolbar *tb)
 }
 
 
-/**
- * find the toolbar item with a given location.
- *
- * \param tb the toolbar instance
- * \param locaction the location to search for
- * \return the item id for a location
- */
-static nsgtk_toolbar_button
-itemid_from_location(struct nsgtk_toolbar *tb, int location)
-{
-       int iidx;
-       for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
-               if (tb->buttons[iidx]->location == location) {
-                       break;
-               }
-       }
-       return iidx;
-}
 
 /**
  * find the toolbar item with a given gtk widget.
@@ -2275,7 +2298,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget 
*widget, gpointer data)
                                 tbc->container);
 
 #if 0
-       g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "close")),
+       g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "apply")),
                         "clicked",
                         G_CALLBACK(nsgtk_toolbar_persist),
                         g);
@@ -2290,16 +2313,17 @@ static gboolean cutomize_button_clicked_cb(GtkWidget 
*widget, gpointer data)
                         G_CALLBACK(nsgtk_toolbar_delete),
                         g);
 
+
+#endif
        g_signal_connect(tbc->container,
                         "drag-drop",
-                        G_CALLBACK(nsgtk_toolbar_store_return),
-                        g);
+                        G_CALLBACK(customisation_container_drag_drop_cb),
+                        tbc);
 
        g_signal_connect(tbc->container,
                         "drag-motion",
-                        G_CALLBACK(nsgtk_toolbar_store_action),
-                        g);
-#endif
+                        G_CALLBACK(customisation_container_drag_motion_cb),
+                        tbc);
 
 
        nsgtk_tab_add_page(notebook,


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to