[latexila/gnome-3: 1/3] GNOME 3: migration to GTK+ 3, GtkSourceView 3, etc



commit b439e989c2a5d941fd3812fb9673de2cd269f942
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Wed Sep 28 00:08:03 2011 +0200

    GNOME 3: migration to GTK+ 3, GtkSourceView 3, etc
    
    It compiles, but it's highly unstable (I got a segfault in less than 10
    seconds of testing).
    
    Unique is completely disabled, it will be replaced by using
    GtkApplication.
    
    GtkSpell is also disabled. I'll test the development version of
    GtkSpell, and it will be reactivated when GtkSpell 3 will be released.

 CMakeLists.txt              |   18 +++---
 src/CMakeLists.txt          |    8 +-
 src/application.vala        |   84 +++++++++++++-------------
 src/build_tool_dialog.vala  |    1 -
 src/clean_build_files.vala  |    2 -
 src/completion.vala         |    2 +-
 src/custom_statusbar.vala   |    1 -
 src/dialogs.vala            |    2 -
 src/document.vala           |   10 ++--
 src/document_view.vala      |   24 ++++----
 src/main.vala               |  139 +++++++++++++++++++++----------------------
 src/main_window.vala        |    6 +-
 src/preferences_dialog.vala |    1 -
 src/symbols.vala            |    2 +-
 src/templates.vala          |    6 +-
 src/utils.vala              |    4 +-
 16 files changed, 149 insertions(+), 161 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 796edfb..688df67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,13 +47,13 @@ if (BUILD_VALA)
 endif ()
 
 find_package (PkgConfig)
-pkg_check_modules (GTK REQUIRED "gtk+-2.0 >= 2.16")
-pkg_check_modules (GTKSOURCEVIEW REQUIRED "gtksourceview-2.0 >= 2.10")
-pkg_check_modules (GTKSPELL REQUIRED "gtkspell-2.0")
+pkg_check_modules (GTK REQUIRED "gtk+-3.0")
+pkg_check_modules (GTKSOURCEVIEW REQUIRED "gtksourceview-3.0")
+#pkg_check_modules (GTKSPELL REQUIRED "gtkspell-2.0")
 pkg_check_modules (GEE REQUIRED "gee-1.0")
 pkg_check_modules (GIO REQUIRED "gio-2.0 >= 2.28")
-pkg_check_modules (UNIQUE REQUIRED "unique-1.0")
-pkg_check_modules (GDK-X11 REQUIRED "gdk-x11-2.0")
+#pkg_check_modules (UNIQUE REQUIRED "unique-1.0")
+pkg_check_modules (GDK-X11 REQUIRED "gdk-x11-3.0")
 pkg_check_modules (X11 REQUIRED "x11")
 
 if (WITH_GNOME)
@@ -70,10 +70,10 @@ add_definitions (-include config.h)
 add_definitions (
 	${GTK_CFLAGS}
 	${GTKSOURCEVIEW_CFLAGS}
-	${GTKSPELL_CFLAGS}
+# 	${GTKSPELL_CFLAGS}
 	${GEE_CFLAGS}
 	${GIO_CFLAGS}
-	${UNIQUE_CFLAGS}
+#	${UNIQUE_CFLAGS}
 	${GDK-X11_CFLAGS}
 	${X11_CFLAGS}
 )
@@ -81,10 +81,10 @@ add_definitions (
 link_libraries (
 	${GTK_LIBRARIES}
 	${GTKSOURCEVIEW_LIBRARIES}
-	${GTKSPELL_LIBRARIES}
+# 	${GTKSPELL_LIBRARIES}
 	${GEE_LIBRARIES}
 	${GIO_LIBRARIES}
-	${UNIQUE_LIBRARIES}
+#	${UNIQUE_LIBRARIES}
 	${GDK-X11_LIBRARIES}
 	${X11_LIBRARIES}
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 801ca17..c61a5e1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,11 +5,11 @@ vala_precompile (
 	VALA_C
 		${vala_sources}
 	PACKAGES
-		gtk+-2.0
-		gtksourceview-2.0
+		gtk+-3.0
+		gtksourceview-3.0
 		gee-1.0
-		unique-1.0
-		gdk-x11-2.0
+#		unique-1.0
+		gdk-x11-3.0
 		x11
 		posix
 
diff --git a/src/application.vala b/src/application.vala
index cda1ba5..2e889ae 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -200,48 +200,48 @@ public class Application : GLib.Object
         return res;
     }
 
-    public Unique.Response message (Unique.App sender, int command,
-                                    Unique.MessageData data, uint time)
-    {
-        if (command == NEW_WINDOW)
-        {
-            create_window ();
-            return Unique.Response.OK;
-        }
-
-        uint workspace = data.get_workspace ();
-        Gdk.Screen screen = data.get_screen ();
-
-        // if active_window not on current workspace, try to find an other window on the
-        // current workspace.
-        if (! active_window.is_on_workspace_screen (screen, workspace))
-        {
-            bool found = false;
-            foreach (MainWindow w in windows)
-            {
-                if (w == active_window)
-                    continue;
-                if (w.is_on_workspace_screen (screen, workspace))
-                {
-                    found = true;
-                    active_window = w;
-                    break;
-                }
-            }
-
-            if (! found)
-                create_window (screen);
-        }
-
-        if (command == Unique.Command.NEW)
-            create_document ();
-
-        else if (command == Unique.Command.OPEN)
-            open_documents (data.get_uris ());
-
-        active_window.present_with_time (time);
-        return Unique.Response.OK;
-    }
+//    public Unique.Response message (Unique.App sender, int command,
+//                                    Unique.MessageData data, uint time)
+//    {
+//        if (command == NEW_WINDOW)
+//        {
+//            create_window ();
+//            return Unique.Response.OK;
+//        }
+//
+//        uint workspace = data.get_workspace ();
+//        Gdk.Screen screen = data.get_screen ();
+//
+//        // if active_window not on current workspace, try to find an other window on the
+//        // current workspace.
+//        if (! active_window.is_on_workspace_screen (screen, workspace))
+//        {
+//            bool found = false;
+//            foreach (MainWindow w in windows)
+//            {
+//                if (w == active_window)
+//                    continue;
+//                if (w.is_on_workspace_screen (screen, workspace))
+//                {
+//                    found = true;
+//                    active_window = w;
+//                    break;
+//                }
+//            }
+//
+//            if (! found)
+//                create_window (screen);
+//        }
+//
+//        if (command == Unique.Command.NEW)
+//            create_document ();
+//
+//        else if (command == Unique.Command.OPEN)
+//            open_documents (data.get_uris ());
+//
+//        active_window.present_with_time (time);
+//        return Unique.Response.OK;
+//    }
 
     public MainWindow create_window (Gdk.Screen? screen = null)
     {
diff --git a/src/build_tool_dialog.vala b/src/build_tool_dialog.vala
index cc81e47..b63623e 100644
--- a/src/build_tool_dialog.vala
+++ b/src/build_tool_dialog.vala
@@ -69,7 +69,6 @@ private class BuildToolDialog : Dialog
         add_button (Stock.CANCEL, ResponseType.CANCEL);
         add_button (Stock.OK, ResponseType.OK);
         title = _("Build Tool");
-        has_separator = false;
         destroy_with_parent = true;
         border_width = 5;
 
diff --git a/src/clean_build_files.vala b/src/clean_build_files.vala
index 1754e2b..0092bed 100644
--- a/src/clean_build_files.vala
+++ b/src/clean_build_files.vala
@@ -237,8 +237,6 @@ public class CleanBuildFiles : GLib.Object
             Stock.DELETE, ResponseType.ACCEPT,
             null);
 
-        dialog.has_separator = false;
-
         HBox hbox = new HBox (false, 12);
         hbox.border_width = 5;
         VBox content_area = dialog.get_content_area () as VBox;
diff --git a/src/completion.vala b/src/completion.vala
index 4efff94..05abea6 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -426,7 +426,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
         Application app = Application.get_default ();
         calltip_window = new SourceCompletionInfo ();
         calltip_window.set_transient_for (app.active_window);
-        calltip_window.set_sizing (800, 200, true, true);
+//        calltip_window.set_sizing (800, 200, true, true);
         calltip_window_label = new Label (null);
         calltip_window.set_widget (calltip_window_label);
     }
diff --git a/src/custom_statusbar.vala b/src/custom_statusbar.vala
index 8cb4e52..6ff8db2 100644
--- a/src/custom_statusbar.vala
+++ b/src/custom_statusbar.vala
@@ -26,7 +26,6 @@ public class CustomStatusbar : Statusbar
     public CustomStatusbar ()
     {
         cursor_position = new Statusbar ();
-        cursor_position.has_resize_grip = false;
         cursor_position.set_size_request (150, -1);
         pack_end (cursor_position, false, true, 0);
     }
diff --git a/src/dialogs.vala b/src/dialogs.vala
index d696e97..24ecb29 100644
--- a/src/dialogs.vala
+++ b/src/dialogs.vala
@@ -42,8 +42,6 @@ namespace Dialogs
             Stock.SAVE, ResponseType.ACCEPT,
             null);
 
-        dialog.has_separator = false;
-
         HBox hbox = new HBox (false, 12);
         hbox.border_width = 5;
         VBox content_area = (VBox) dialog.get_content_area ();
diff --git a/src/document.vala b/src/document.vala
index 8f30f27..0bc25e0 100644
--- a/src/document.vala
+++ b/src/document.vala
@@ -790,7 +790,7 @@ public class Document : Gtk.SourceBuffer
         bool found = false;
         while (! found)
         {
-            found = source_iter_forward_search (start, search_text, get_search_flags (),
+            found = start.forward_search (search_text, get_search_flags (),
                 out match_start, out match_end, end);
 
             if (found && search_entire_word)
@@ -815,7 +815,7 @@ public class Document : Gtk.SourceBuffer
         bool found = false;
         while (! found)
         {
-            found = source_iter_backward_search (start, search_text, get_search_flags (),
+            found = start.backward_search (search_text, get_search_flags (),
                 out match_start, out match_end, end);
 
             if (found && search_entire_word)
@@ -973,11 +973,11 @@ public class Document : Gtk.SourceBuffer
         search_cursor_moved_handler ();
     }
 
-    private SourceSearchFlags get_search_flags ()
+    private TextSearchFlags get_search_flags ()
     {
-        var flags = SourceSearchFlags.TEXT_ONLY | SourceSearchFlags.VISIBLE_ONLY;
+        var flags = TextSearchFlags.TEXT_ONLY | TextSearchFlags.VISIBLE_ONLY;
         if (! search_case_sensitive)
-            flags |= SourceSearchFlags.CASE_INSENSITIVE;
+            flags |= TextSearchFlags.CASE_INSENSITIVE;
         return flags;
     }
 
diff --git a/src/document_view.vala b/src/document_view.vala
index 6946bc5..e1d739c 100644
--- a/src/document_view.vala
+++ b/src/document_view.vala
@@ -197,22 +197,22 @@ public class DocumentView : Gtk.SourceView
     {
         disable_spell_checking ();
 
-        try
-        {
-            // Will try the best language depending on the LANG environment variable.
-            new GtkSpell.attach (this, null);
-        }
-        catch (GtkspellError e)
-        {
-            warning ("Spell error: %s", e.message);
-        }
+//        try
+//        {
+//            // Will try the best language depending on the LANG environment variable.
+//            new GtkSpell.attach (this, null);
+//        }
+//        catch (GtkspellError e)
+//        {
+//            warning ("Spell error: %s", e.message);
+//        }
     }
 
     public void disable_spell_checking ()
     {
-        GtkSpell? spell = GtkSpell.get_from_text_view (this);
-        if (spell != null)
-            spell.detach ();
+//        GtkSpell? spell = GtkSpell.get_from_text_view (this);
+//        if (spell != null)
+//            spell.detach ();
     }
 
     private bool on_backspace (Gdk.EventKey event)
diff --git a/src/main.vala b/src/main.vala
index e5460bb..ab93a77 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -93,83 +93,80 @@ int main (string[] args)
     }
 
     /* prepare commands */
-    bool command_open = false;
-    Unique.MessageData data = new Unique.MessageData ();
+//    bool command_open = false;
+//    Unique.MessageData data = new Unique.MessageData ();
+//
+//    if (remaining_args.length != 0)
+//    {
+//        command_open = true;
+//
+//        // since remaining_args.length == 0, we use a dynamic array
+//        string[] uris = {};
+//        foreach (string arg in remaining_args)
+//            // The command line argument can be absolute or relative.
+//            // With URI's, that's always absolute, so no problem.
+//            uris += File.new_for_path (arg).get_uri ();
+//
+//        data.set_uris (uris);
+//    }
+//
+//    Unique.App app = new Unique.App ("org.gnome.latexila", null);
+//    app.add_command ("new_window", Application.NEW_WINDOW);
+//
+//    if (app.is_running)
+//    {
+//        /* send commands */
+//        bool ok = true;
+//        if (option_new_window)
+//        {
+//            Unique.Response resp = app.send_message (Application.NEW_WINDOW, null);
+//            ok = resp == Unique.Response.OK;
+//        }
+//        if (ok && command_open)
+//        {
+//            Unique.Response resp = app.send_message (Unique.Command.OPEN, data);
+//            ok = resp == Unique.Response.OK;
+//        }
+//        if (ok && option_new_document)
+//        {
+//            Unique.Response resp = app.send_message (Unique.Command.NEW, null);
+//            ok = resp == Unique.Response.OK;
+//        }
+//        if (! option_new_window && ! command_open && ! option_new_document)
+//        {
+//            Unique.Response resp = app.send_message (Unique.Command.ACTIVATE, null);
+//            ok = resp == Unique.Response.OK;
+//        }
+//
+//        if (! ok)
+//            error ("Error: communication with first instance of LaTeXila failed\n");
+//        return 0;
+//    }
 
-    if (remaining_args.length != 0)
-    {
-        command_open = true;
+    /* start a new application */
+    Application latexila = Application.get_default ();
 
-        // since remaining_args.length == 0, we use a dynamic array
-        string[] uris = {};
-        foreach (string arg in remaining_args)
-            // The command line argument can be absolute or relative.
-            // With URI's, that's always absolute, so no problem.
-            uris += File.new_for_path (arg).get_uri ();
+    /* reopen files on startup */
+    GLib.Settings editor_settings =
+        new GLib.Settings ("org.gnome.latexila.preferences.editor");
+    if (editor_settings.get_boolean ("reopen-files"))
+    {
+        GLib.Settings window_settings =
+            new GLib.Settings ("org.gnome.latexila.state.window");
 
-        data.set_uris (uris);
+        string[] uris = window_settings.get_strv ("documents");
+        latexila.open_documents (uris);
     }
 
-    Unique.App app = new Unique.App ("org.gnome.latexila", null);
-    app.add_command ("new_window", Application.NEW_WINDOW);
-
-    if (app.is_running)
-    {
-        /* send commands */
-        bool ok = true;
-        if (option_new_window)
-        {
-            Unique.Response resp = app.send_message (Application.NEW_WINDOW, null);
-            ok = resp == Unique.Response.OK;
-        }
-        if (ok && command_open)
-        {
-            Unique.Response resp = app.send_message (Unique.Command.OPEN, data);
-            ok = resp == Unique.Response.OK;
-        }
-        if (ok && option_new_document)
-        {
-            Unique.Response resp = app.send_message (Unique.Command.NEW, null);
-            ok = resp == Unique.Response.OK;
-        }
-        if (! option_new_window && ! command_open && ! option_new_document)
-        {
-            Unique.Response resp = app.send_message (Unique.Command.ACTIVATE, null);
-            ok = resp == Unique.Response.OK;
-        }
-
-        if (! ok)
-            error ("Error: communication with first instance of LaTeXila failed\n");
-        return 0;
-    }
+    /* execute commands */
+    // the --new-window option have no effect in this case
+//    if (command_open)
+//        latexila.open_documents (data.get_uris ());
+    if (option_new_document)
+        latexila.create_document ();
 
-    /* start a new application */
-    else
-    {
-        Application latexila = Application.get_default ();
-
-        /* reopen files on startup */
-        GLib.Settings editor_settings =
-            new GLib.Settings ("org.gnome.latexila.preferences.editor");
-        if (editor_settings.get_boolean ("reopen-files"))
-        {
-            GLib.Settings window_settings =
-                new GLib.Settings ("org.gnome.latexila.state.window");
-
-            string[] uris = window_settings.get_strv ("documents");
-            latexila.open_documents (uris);
-        }
-
-        /* execute commands */
-        // the --new-window option have no effect in this case
-        if (command_open)
-            latexila.open_documents (data.get_uris ());
-        if (option_new_document)
-            latexila.create_document ();
-
-        app.message_received.connect (latexila.message);
-        Gtk.main ();
-    }
+//    app.message_received.connect (latexila.message);
+    Gtk.main ();
 
     return 0;
 }
diff --git a/src/main_window.vala b/src/main_window.vala
index 7485b5f..cdca74c 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -586,15 +586,15 @@ public class MainWindow : Window
         update_build_tools_menu ();
     }
 
-    private void on_menu_item_select (Item proxy)
+    private void on_menu_item_select (MenuItem proxy)
     {
-        Gtk.Action action = ((MenuItem) proxy).get_related_action ();
+        Gtk.Action action = proxy.get_related_action ();
         return_if_fail (action != null);
         if (action.tooltip != null)
             statusbar.push (tip_message_cid, action.tooltip);
     }
 
-    private void on_menu_item_deselect (Item proxy)
+    private void on_menu_item_deselect (MenuItem proxy)
     {
         statusbar.pop (tip_message_cid);
     }
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 1c18a35..bbb6231 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -30,7 +30,6 @@ public class PreferencesDialog : Dialog
     private PreferencesDialog ()
     {
         title = _("Preferences");
-        has_separator = false;
         destroy_with_parent = true;
         border_width = 5;
 
diff --git a/src/symbols.vala b/src/symbols.vala
index 6e11bf9..f76717d 100644
--- a/src/symbols.vala
+++ b/src/symbols.vala
@@ -776,7 +776,7 @@ public class Symbols : VBox
         categories_view.set_pixbuf_column (CategoryColumn.ICON);
         categories_view.set_text_column (CategoryColumn.NAME);
         categories_view.set_selection_mode (SelectionMode.SINGLE);
-        categories_view.set_orientation (Orientation.HORIZONTAL);
+        categories_view.set_item_orientation (Orientation.HORIZONTAL);
         categories_view.spacing = 5;
         categories_view.row_spacing = 0;
         categories_view.column_spacing = 0;
diff --git a/src/templates.vala b/src/templates.vala
index 77d344a..11e4163 100644
--- a/src/templates.vala
+++ b/src/templates.vala
@@ -102,8 +102,7 @@ public class Templates : GLib.Object
 
     public void show_dialog_new (MainWindow parent)
     {
-        Dialog dialog = new Dialog.with_buttons (_("New File..."), parent,
-            DialogFlags.NO_SEPARATOR,
+        Dialog dialog = new Dialog.with_buttons (_("New File..."), parent, 0,
             Stock.OK, ResponseType.ACCEPT,
             Stock.CANCEL, ResponseType.REJECT,
             null);
@@ -271,8 +270,7 @@ public class Templates : GLib.Object
 
     public void show_dialog_delete (MainWindow parent)
     {
-        Dialog dialog = new Dialog.with_buttons (_("Delete Template(s)..."), parent,
-            DialogFlags.NO_SEPARATOR,
+        Dialog dialog = new Dialog.with_buttons (_("Delete Template(s)..."), parent, 0,
             Stock.DELETE, ResponseType.ACCEPT,
             Stock.CLOSE, ResponseType.REJECT,
             null);
diff --git a/src/utils.vala b/src/utils.vala
index 52104bb..f451deb 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -364,7 +364,7 @@ namespace Utils
 
         Gdk.Window window = gtkwindow.get_window ();
         Gdk.Display display = window.get_display ();
-        unowned X.Display x_display = Gdk.x11_display_get_xdisplay (display);
+        unowned X.Display x_display = Gdk.X11Display.get_xdisplay (display);
 
         X.Atom type;
         int format;
@@ -374,7 +374,7 @@ namespace Utils
 
         Gdk.error_trap_push ();
 
-        int result = x_display.get_window_property (Gdk.x11_drawable_get_xid (window),
+        int result = x_display.get_window_property (Gdk.X11Window.get_xid (window),
             Gdk.x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
             0, long.MAX, false, X.XA_CARDINAL, out type, out format, out nitems,
             out bytes_after, out workspace);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]