summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel AINS <lains@caramail.com>2018-11-26 18:23:29 +0100
committerLionel AINS <lains@caramail.com>2018-11-26 18:23:29 +0100
commit9a71d6d29d51dd9b1e565252d092087b4b47457f (patch)
treef01730e1fa0049cda0a1e4bd2236ca036f7532a8
parente5bd1d58cddd5f4dc815343f173e48eb3d019412 (diff)
downloadnavit-9a71d6d29d51dd9b1e565252d092087b4b47457f.tar.gz
Moving widget-related swap and move functions to gui_internal_widget.c
-rw-r--r--navit/gui/internal/gui_internal_menu.c53
-rw-r--r--navit/gui/internal/gui_internal_widget.c53
-rw-r--r--navit/gui/internal/gui_internal_widget.h2
3 files changed, 55 insertions, 53 deletions
diff --git a/navit/gui/internal/gui_internal_menu.c b/navit/gui/internal/gui_internal_menu.c
index 153cccf0b..b5d27955b 100644
--- a/navit/gui/internal/gui_internal_menu.c
+++ b/navit/gui/internal/gui_internal_menu.c
@@ -336,59 +336,6 @@ void gui_internal_menu_resize(struct gui_priv *this, int w, int h) {
}
/**
- * @brief Transfer the content of one widget into another one (and optionally vice-versa)
- *
- * @param this The internal GUI instance
- * @param[in,out] first The first widget
- * @param[in,out] second The second widget
- * @param move_only If non nul, transfer only the second widget into the first widget. The second widget is then deallocated and should be be used anymore (this is a move operation)
- */
-static void gui_internal_widget_transfer_content(struct gui_priv *this, struct widget *first, struct widget *second, int move_only) {
- struct widget *temp;
-
- if (!first) {
- dbg(lvl_error, "Refusing copy: first argument is NULL");
- return;
- }
- if (!second) {
- dbg(lvl_error, "Refusing copy: second argument is NULL");
- return;
- }
- temp=g_new0(struct widget, 1);
- memcpy(temp, first, sizeof(struct widget));
- memcpy(first, second, sizeof(struct widget));
- if (move_only) {
- gui_internal_widget_destroy(this, temp); /* This will do a g_free(temp), but will also deallocate all children widgets */
- g_free(second); /* We also free the struct widget pointed to by second, so variable second should not be used anymore from this point */
- } else {
- memcpy(second, temp, sizeof(struct widget));
- g_free(temp);
- }
-}
-
-/**
- * @brief Swap two widgets
- *
- * @param this The internal GUI instance
- * @param[in,out] first The first widget
- * @param[in,out] second The second widget
- */
-static inline void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second) {
- gui_internal_widget_transfer_content(this, first, second, 0);
-}
-
-/**
- * @brief Move the content of one widget into another one (the @p src widget is then deallocated and should be be used anymore)
- *
- * @param this The internal GUI instance
- * @param[in,out] dst The destination widget
- * @param[in,out] src The source widget
- */
-static inline void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src) {
- gui_internal_widget_transfer_content(this, dst, src, 1);
-}
-
-/**
* @brief Resize a top bar created using gui_internal_top_bar()
*
* @param this The internal GUI instance
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
index 7d5d71058..65f786484 100644
--- a/navit/gui/internal/gui_internal_widget.c
+++ b/navit/gui/internal/gui_internal_widget.c
@@ -14,6 +14,59 @@
static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb);
void gui_internal_box_pack(struct gui_priv *this, struct widget *w);
+/**
+ * @brief Transfer the content of one widget into another one (and optionally vice-versa)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ * @param move_only If non nul, transfer only the second widget into the first widget. The second widget is then deallocated and should be be used anymore (this is a move operation)
+ */
+static void gui_internal_widget_transfer_content(struct gui_priv *this, struct widget *first, struct widget *second, int move_only) {
+ struct widget *temp;
+
+ if (!first) {
+ dbg(lvl_error, "Refusing copy: first argument is NULL");
+ return;
+ }
+ if (!second) {
+ dbg(lvl_error, "Refusing copy: second argument is NULL");
+ return;
+ }
+ temp=g_new0(struct widget, 1);
+ memcpy(temp, first, sizeof(struct widget));
+ memcpy(first, second, sizeof(struct widget));
+ if (move_only) {
+ gui_internal_widget_destroy(this, temp); /* This will do a g_free(temp), but will also deallocate all children widgets */
+ g_free(second); /* We also free the struct widget pointed to by second, so variable second should not be used anymore from this point */
+ } else {
+ memcpy(second, temp, sizeof(struct widget));
+ g_free(temp);
+ }
+}
+
+/**
+ * @brief Swap two widgets
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] first The first widget
+ * @param[in,out] second The second widget
+ */
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second) {
+ gui_internal_widget_transfer_content(this, first, second, 0);
+}
+
+/**
+ * @brief Move the content of one widget into another one (the @p src widget is then deallocated and should be be used anymore)
+ *
+ * @param this The internal GUI instance
+ * @param[in,out] dst The destination widget
+ * @param[in,out] src The source widget
+ */
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src) {
+ gui_internal_widget_transfer_content(this, dst, src, 1);
+}
+
static void gui_internal_background_render(struct gui_priv *this, struct widget *w) {
struct point pnt=w->p;
if (w->state & STATE_HIGHLIGHTED)
diff --git a/navit/gui/internal/gui_internal_widget.h b/navit/gui/internal/gui_internal_widget.h
index 56bfe12cf..cc24cb44e 100644
--- a/navit/gui/internal/gui_internal_widget.h
+++ b/navit/gui/internal/gui_internal_widget.h
@@ -156,6 +156,8 @@ struct gui_priv;
struct point;
struct table_data;
struct widget;
+void gui_internal_widget_swap(struct gui_priv *this, struct widget *first, struct widget *second);
+void gui_internal_widget_move(struct gui_priv *this, struct widget *dst, struct widget *src);
struct widget *gui_internal_label_font_new(struct gui_priv *this, const char *text, int font);
struct widget *gui_internal_label_new(struct gui_priv *this, const char *text);
struct widget *gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth);