diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-03-09 01:36:44 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-03-09 17:15:07 +0100 |
commit | 0fec6f28c91c12b7d7d264c296986de74fca23f6 (patch) | |
tree | 033eb61f1438857dbdf667f61f14e3660fb12736 /src/gtk/gtk-code-generator.sh | |
parent | 3bf5fcfc89de5c3245034ee4752392fe42291924 (diff) | |
download | nautilus-0fec6f28c91c12b7d7d264c296986de74fca23f6.tar.gz |
placesview: auto generate code
We have been manually copying the code inside nautilus since we
introduced the places view.
It has been a pain to maintain, mostly because we needed to remove the
bits that only work inside gtk+ and instead either remove them or make
a substitution. But that was doable.
However, it reached a new level when we realized that we use the file
chooser inside nautilus, for the "move to" and "copy to" actions, which
create makes symbols clash. So we needed to rename all the symbols in
those files.
Instead of making it manually, create a shell script that fetches gtk+
repository and make the appropriate substitutions, deletions and what
not.
https://bugzilla.gnome.org/show_bug.cgi?id=760307
Diffstat (limited to 'src/gtk/gtk-code-generator.sh')
-rwxr-xr-x | src/gtk/gtk-code-generator.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/gtk/gtk-code-generator.sh b/src/gtk/gtk-code-generator.sh new file mode 100755 index 000000000..0749a272f --- /dev/null +++ b/src/gtk/gtk-code-generator.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# Fetch the GtkPlacesView files but rename the symbols to avoid symbol clashes +# when using the file chooser inside nautilus i.e. when activating the "move to" +# action. +# Also remove/add the neccesary bits to make it work inside nautilus + +URL=https://git.gnome.org/browse/gtk+/plain/gtk/ +URLUI=https://git.gnome.org/browse/gtk+/plain/gtk/ui/ + +# Since comments are not allowed inside the sed line, this is what it will do +# by order: +# type substitution +# remove marshalers +# add external localization library after the always there config.h +# and remove the gtk internal P_ and I_ localization, we don't actually +# want localization of this in nautilus +# include gtk.h library after the always there config.h +# and remove all the other types that get included by the general gtk.h +# remove the error when including gtk.h +# load nautilus resources, not gtk resources + +update_file () { + _source="$1" + _dest="$2" + + curl "${_source}" | sed \ + -e 's/gtkplacesview/nautilusgtkplacesview/g' \ + -e 's/gtk_places_view/nautilus_gtk_places_view/g' \ + -e 's/GtkPlacesView/NautilusGtkPlacesView/g' \ + -e 's/GTK_PLACES_VIEW/NAUTILUS_GTK_PLACES_VIEW/g' \ + -e 's/GTK_TYPE_PLACES_VIEW/NAUTILUS_TYPE_GTK_PLACES_VIEW/g' \ + -e 's/GTK_IS_PLACES_VIEW/NAUTILUS_IS_GTK_PLACES_VIEW/g' \ + -e 's/_gtk_marshal_VOID__STRING_STRING/NULL/g' \ + -e '/gtkmarshalers.h/d' \ + -e '/"config.h"/a #include <glib\/gi18n.h>' \ + -e "s/P_(\(.*\))/\1/" \ + -e "s/I_(\(.*\))/\1/" \ + -e '/"config.h"/a #include <gtk\/gtk.h>' \ + -e '/gtktypebuiltins.h/d' \ + -e '/gtkplacessidebar.h/d' \ + -e '/gtkintl.h/d' \ + -e '/gtkbox.h/d' \ + -e '/#error/d' \ + -e 's/gtk\/libgtk/gnome\/nautilus\/gtk/g' \ + > "${_dest}" +} + +update_file "${URL}/gtkplacesview.c" "nautilusgtkplacesview.c" +update_file "${URL}/gtkplacesviewprivate.h" "nautilusgtkplacesviewprivate.h" +update_file "${URLUI}/gtkplacesview.ui" "nautilusgtkplacesview.ui" + +# Since comments are not allowed inside the sed line, this is what it will do +# by order: +# type substitution +# use the correct prefixes for type definition +# add external localization library after the always there config.h +# and remove the gtk internal P_ and I_ localization, we don't actually +# want localization of this in nautilus +# include gtk.h library after the always there config.h +# and remove all the other types that get included by the general gtk.h +# remove the error when including gtk.h +# load nautilus resources, not gtk resources +update_file () { + _source="$1" + _dest="$2" + + curl "${_source}" | sed \ + -e 's/gtkplacesviewrow/nautilusgtkplacesviewrow/g' \ + -e 's/gtk_places_view_row/nautilus_gtk_places_view_row/g' \ + -e 's/GtkPlacesViewRow/NautilusGtkPlacesViewRow/g' \ + -e 's/GTK_PLACES_VIEW_ROW/NAUTILUS_GTK_PLACES_VIEW_ROW/g' \ + -e 's/GTK_TYPE_PLACES_VIEW_ROW/NAUTILUS_TYPE_GTK_PLACES_VIEW_ROW/g' \ + -e 's/GTK_IS_PLACES_VIEW_ROW/NAUTILUS_IS_GTK_PLACES_VIEW_ROW/g' \ + -e 's/G_DECLARE_FINAL_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, GTK, PLACES_VIEW_ROW, GtkListBoxRow/ G_DECLARE_FINAL_TYPE (NautilusGtkPlacesViewRow, nautilus_gtk_places_view_row, NAUTILUS, GTK_PLACES_VIEW_ROW, GtkListBoxRow/g' \ + -e '/"config.h"/a #include <glib\/gi18n.h>' \ + -e "s/P_(\(.*\))/\1/" \ + -e "s/I_(\(.*\))/\1/" \ + -e '/"config.h"/a #include <gtk\/gtk.h>' \ + -e '/gtksizegroup.h/d' \ + -e '/gtkwidget.h/d' \ + -e '/gtklistbox.h/d' \ + -e '/#error /d' \ + -e 's/gtk\/libgtk/gnome\/nautilus\/gtk/g' \ + > "${_dest}" +} + +update_file "${URL}/gtkplacesviewrow.c" "nautilusgtkplacesviewrow.c" +update_file "${URL}/gtkplacesviewrowprivate.h" "nautilusgtkplacesviewrowprivate.h" +update_file "${URLUI}/gtkplacesviewrow.ui" "nautilusgtkplacesviewrow.ui" |