From 0f7abf96a76c3072433f635ea465aeaae1b782b4 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 23 Feb 2009 14:42:00 -0500 Subject: [PATCH] Port to Clutter-0.9 tools/build/gnome-shell.modules: Point at master branch of Clutter (0.9) and make gobject-introspection a dep of Clutter. configure.ac src/Makefile.am: Use Clutter-0.9 js/ui/button.js js/ui/genericDisplay.js js/ui/overlay.js js/ui/panel.js js/ui/runDialog.js js/ui/workspaces.js src/shell-status-menu.c: Use ClutterText instead of ClutterLabel and ClutterEntry js/ui/workspaces.js js/ui/genericDisplay.js: Use ClutterClone instead of ClutterCloneTexture src/shell-global.[ch]: Add Shell.get_event_key_symbol() to workaround unaccessibility of clutter_key_event_symbol() to use. js/runDialog.js js/overlay.js: Use Shell.get_event_key_symbol() as appropriate. --- configure.ac | 4 +-- js/ui/button.js | 4 +-- js/ui/genericDisplay.js | 30 ++++++++-------- js/ui/overlay.js | 62 +++++++++++++++++---------------- js/ui/panel.js | 4 +-- js/ui/runDialog.js | 23 ++++++------ js/ui/workspaces.js | 22 ++++++------ src/Makefile.am | 11 +++--- src/shell-global.c | 9 +++++ src/shell-global.h | 2 ++ src/shell-status-menu.c | 19 +++++----- tools/build/gnome-shell.modules | 16 +++------ 12 files changed, 106 insertions(+), 100 deletions(-) diff --git a/configure.ac b/configure.ac index 6737f24e8..247492cdb 100644 --- a/configure.ac +++ b/configure.ac @@ -19,8 +19,8 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The prefix for our gettext translation domains.]) PKG_CHECK_MODULES(MUTTER_PLUGIN, gtk+-2.0 dbus-glib-1 metacity-plugins gjs-gi-1.0) -PKG_CHECK_MODULES(TIDY, clutter-0.8) -PKG_CHECK_MODULES(BIG, clutter-cairo-0.8 gtk+-2.0 librsvg-2.0) +PKG_CHECK_MODULES(TIDY, clutter-0.9) +PKG_CHECK_MODULES(BIG, clutter-0.9 gtk+-2.0 librsvg-2.0) PKG_CHECK_MODULES(GDMUSER, dbus-glib-1 gtk+-2.0) PKG_CHECK_MODULES(TRAY, gtk+-2.0) PKG_CHECK_MODULES(TASKPANEL, libwnck-1.0 dbus-glib-1) diff --git a/js/ui/button.js b/js/ui/button.js index fd18ee7f6..7bbf2c05f 100644 --- a/js/ui/button.js +++ b/js/ui/button.js @@ -46,8 +46,8 @@ Button.prototype = { y_align: Big.BoxAlignment.CENTER }); if (typeof widgetOrText == 'string') { - this._widget = new Clutter.Label({ font_name: "Sans Bold 16px", - text: widgetOrText }); + this._widget = new Clutter.Text({ font_name: "Sans Bold 16px", + text: widgetOrText }); } else { this._widget = widgetOrText; } diff --git a/js/ui/genericDisplay.js b/js/ui/genericDisplay.js index f2c52b1ab..56541be2b 100644 --- a/js/ui/genericDisplay.js +++ b/js/ui/genericDisplay.js @@ -65,7 +65,7 @@ GenericDisplayItem.prototype = { //// Draggable interface //// getDragActor: function(stageX, stageY) { // FIXME: assumes this._icon is a Clutter.Texture - let icon = new Clutter.CloneTexture({ parent_texture: this._icon }); + let icon = new Clutter.Clone({ source: this._icon }); [icon.width, icon.height] = this._icon.get_transformed_size(); // If the user dragged from the icon itself, then position @@ -137,21 +137,21 @@ GenericDisplayItem.prototype = { this.actor.add_actor(this._icon); let text_width = this._availableWidth - (ITEM_DISPLAY_ICON_SIZE + 4); - this._name = new Clutter.Label({ color: ITEM_DISPLAY_NAME_COLOR, - font_name: "Sans 14px", - width: text_width, - ellipsize: Pango.EllipsizeMode.END, - text: nameText, - x: ITEM_DISPLAY_ICON_SIZE + 4, - y: ITEM_DISPLAY_PADDING }); + this._name = new Clutter.Text({ color: ITEM_DISPLAY_NAME_COLOR, + font_name: "Sans 14px", + width: text_width, + ellipsize: Pango.EllipsizeMode.END, + text: nameText, + x: ITEM_DISPLAY_ICON_SIZE + 4, + y: ITEM_DISPLAY_PADDING }); this.actor.add_actor(this._name); - this._description = new Clutter.Label({ color: ITEM_DISPLAY_DESCRIPTION_COLOR, - font_name: "Sans 12px", - width: text_width, - ellipsize: Pango.EllipsizeMode.END, - text: descriptionText, - x: this._name.x, - y: this._name.height + 4 }); + this._description = new Clutter.Text({ color: ITEM_DISPLAY_DESCRIPTION_COLOR, + font_name: "Sans 12px", + width: text_width, + ellipsize: Pango.EllipsizeMode.END, + text: descriptionText, + x: this._name.x, + y: this._name.height + 4 }); this.actor.add_actor(this._description); } }; diff --git a/js/ui/overlay.js b/js/ui/overlay.js index 164113ff6..62aab2825 100644 --- a/js/ui/overlay.js +++ b/js/ui/overlay.js @@ -110,14 +110,16 @@ Sideshow.prototype = { // We need to initialize the text for the entry to have the cursor displayed // in it. See http://bugzilla.openedhand.com/show_bug.cgi?id=1365 - this._searchEntry = new Clutter.Entry({ - font_name: "Sans 14px", - x: searchIconTexture.x - + searchIconTexture.width + 4, - y: searchIconTexture.y, - width: this._searchBox.width - (searchIconTexture.x), - height: searchIconTexture.height, - text: ""}); + this._searchEntry = new Clutter.Text({ font_name: "Sans 14px", + x: searchIconTexture.x + + searchIconTexture.width + 4, + y: searchIconTexture.y, + width: this._searchBox.width - (searchIconTexture.x), + height: searchIconTexture.height, + editable: true, + activatable: true, + singleLineMode: true, + text: ""}); this.actor.add_actor(this._searchEntry); this._searchQueued = false; this._searchEntry.connect('notify::text', function (se, prop) { @@ -141,15 +143,15 @@ Sideshow.prototype = { return true; }); this._searchEntry.connect('key-press-event', function (se, e) { - let code = e.get_code(); - if (code == 9) { + let symbol = Shell.get_event_key_symbol(e); + if (symbol == Clutter.Escape) { // A single escape clears the entry, two of them hides the overlay if (me._searchEntry.text == '') me.emit('activated'); else me._searchEntry.text = ''; return true; - } else if (code == 111) { + } else if (symbol == Clutter.Up) { // selectUp and selectDown wrap around in their respective displays // too, but there doesn't seem to be any flickering if we first select // something in one display, but then unset the selection, and move @@ -162,7 +164,7 @@ Sideshow.prototype = { me._appDisplay.selectLastItem(); } return true; - } else if (code == 116) { + } else if (symbol == Clutter.Down) { if (me._appDisplay.hasSelected() && !me._appDisplay.selectDown() && me._docDisplay.hasItems()) { me._appDisplay.unsetSelected(); me._docDisplay.selectFirstItem(); @@ -180,10 +182,10 @@ Sideshow.prototype = { padding_top: SIDESHOW_SECTION_PADDING_TOP, spacing: SIDESHOW_SECTION_SPACING}); - this._appsText = new Clutter.Label({ color: SIDESHOW_TEXT_COLOR, - font_name: "Sans Bold 14px", - text: "Applications", - height: LABEL_HEIGHT}); + this._appsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR, + font_name: "Sans Bold 14px", + text: "Applications", + height: LABEL_HEIGHT}); this._appsSection.append(this._appsText, Big.BoxPackFlags.EXPAND); @@ -195,11 +197,11 @@ Sideshow.prototype = { this._appsSection.append(this._appDisplay.actor, Big.BoxPackFlags.EXPAND); let moreAppsBox = new Big.Box({x_align: Big.BoxAlignment.END}); - this._moreAppsText = new Clutter.Label({ color: SIDESHOW_TEXT_COLOR, - font_name: "Sans Bold 14px", - text: "More...", - height: LABEL_HEIGHT, - reactive: true}); + this._moreAppsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR, + font_name: "Sans Bold 14px", + text: "More...", + height: LABEL_HEIGHT, + reactive: true}); moreAppsBox.append(this._moreAppsText, Big.BoxPackFlags.EXPAND); this._appsSection.append(moreAppsBox, Big.BoxPackFlags.EXPAND); @@ -212,21 +214,21 @@ Sideshow.prototype = { padding_top: SIDESHOW_SECTION_PADDING_TOP, spacing: SIDESHOW_SECTION_SPACING}); - this._docsText = new Clutter.Label({ color: SIDESHOW_TEXT_COLOR, - font_name: "Sans Bold 14px", - text: "Recent Documents", - height: LABEL_HEIGHT}); + this._docsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR, + font_name: "Sans Bold 14px", + text: "Recent Documents", + height: LABEL_HEIGHT}); this._docsSection.append(this._docsText, Big.BoxPackFlags.EXPAND); this._docDisplay = new DocDisplay.DocDisplay(this._width, this._itemDisplayHeight - this._appDisplay.actor.height, SIDESHOW_COLUMNS, SIDESHOW_PAD); this._docsSection.append(this._docDisplay.actor, Big.BoxPackFlags.EXPAND); let moreDocsBox = new Big.Box({x_align: Big.BoxAlignment.END}); - this._moreDocsText = new Clutter.Label({ color: SIDESHOW_TEXT_COLOR, - font_name: "Sans Bold 14px", - text: "More...", - height: LABEL_HEIGHT, - reactive: true}); + this._moreDocsText = new Clutter.Text({ color: SIDESHOW_TEXT_COLOR, + font_name: "Sans Bold 14px", + text: "More...", + height: LABEL_HEIGHT, + reactive: true}); moreDocsBox.append(this._moreDocsText, Big.BoxPackFlags.EXPAND); this._docsSection.append(moreDocsBox, Big.BoxPackFlags.EXPAND); diff --git a/js/ui/panel.js b/js/ui/panel.js index 3380cb692..40bf94453 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -58,8 +58,8 @@ Panel.prototype = { statusbutton.release(); }); - this._clock = new Clutter.Label({ font_name: "Sans Bold 16px", - text: "" }); + this._clock = new Clutter.Text({ font_name: "Sans Bold 16px", + text: "" }); let pad = (PANEL_HEIGHT - this._clock.height) / 2; let clockbox = new Big.Box({ padding_top: pad, padding_bottom: pad, diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index d94969e62..eafdaef34 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -50,19 +50,20 @@ RunDialog.prototype = { border_width: 0 }); boxGroup.add_actor(box); - let label = new Clutter.Label({ color: BOX_TEXT_COLOR, - font_name: '18px Sans', - text: 'Please enter a command:' }); + let label = new Clutter.Text({ color: BOX_TEXT_COLOR, + font_name: '18px Sans', + text: 'Please enter a command:' }); label.set_position(6, 6); boxGroup.add_actor(label); - this._entry = new Clutter.Entry({ color: BOX_TEXT_COLOR, - font_name: '20px Sans Bold', - reactive: true, - text: '', - entry_padding: 0, - width: BOX_WIDTH - 12, - height: BOX_HEIGHT - 12 }); + this._entry = new Clutter.Text({ color: BOX_TEXT_COLOR, + font_name: '20px Sans Bold', + editable: true, + activatable: true, + singleLineMode: true, + text: '', + width: BOX_WIDTH - 12, + height: BOX_HEIGHT - 12 }); // TODO: Implement relative positioning using Tidy. this._entry.set_position(6, 30); boxGroup.add_actor(this._entry); @@ -106,7 +107,7 @@ RunDialog.prototype = { this._group.show_all(); this._entry.connect('key-press-event', function(o, e) { - if (e.get_code() == 9) { + if (Shell.get_event_key_symbol(e) == Clutter.Escape) { me.hide(); me.emit('cancel'); return true; diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js index cf15ebee5..31ed22d6a 100644 --- a/js/ui/workspaces.js +++ b/js/ui/workspaces.js @@ -57,10 +57,10 @@ function WindowClone(realWindow) { WindowClone.prototype = { _init : function(realWindow) { - this.actor = new Clutter.CloneTexture({ parent_texture: realWindow.get_texture(), - reactive: true, - x: realWindow.x, - y: realWindow.y }); + this.actor = new Clutter.Clone({ source: realWindow.get_texture(), + reactive: true, + x: realWindow.x, + y: realWindow.y }); this.actor._delegate = this; this.realWindow = realWindow; this.metaWindow = realWindow.meta_window; @@ -166,11 +166,11 @@ WindowClone.prototype = { Shell.clutter_texture_set_from_pixbuf(iconTexture, icon); box.append(iconTexture, Big.BoxPackFlags.NONE); - let title = new Clutter.Label({ color: WINDOWCLONE_TITLE_COLOR, - font_name: "Sans 12", - text: this.metaWindow.title, - ellipsize: Pango.EllipsizeMode.END - }); + let title = new Clutter.Text({ color: WINDOWCLONE_TITLE_COLOR, + font_name: "Sans 12", + text: this.metaWindow.title, + ellipsize: Pango.EllipsizeMode.END + }); box.append(title, Big.BoxPackFlags.EXPAND); // Get and cache the expected width (just the icon), with spacing, plus title box.fullWidth = box.width; @@ -237,8 +237,8 @@ function DesktopClone(window) { DesktopClone.prototype = { _init : function(window) { if (window) { - this.actor = new Clutter.CloneTexture({ parent_texture: window.get_texture(), - reactive: true }); + this.actor = new Clutter.Clone({ source: window.get_texture(), + reactive: true }); } else { let global = Shell.Global.get(); this.actor = new Clutter.Rectangle({ color: global.stage.color, diff --git a/src/Makefile.am b/src/Makefile.am index a6cd65ad2..8e558132d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -92,8 +92,8 @@ Shell-0.1.gir: $(metacity) $(G_IR_SCANNER) Big-1.0.gir libgnome-shell.la Makefil $(G_IR_SCANNER) \ --namespace=Shell \ --nsversion=0.1 \ - --add-include-path=$(libdir)/metacity/ \ - --include=Clutter-0.8 \ + --add-include-path=$(libdir)/metacity/ \ + --include=Clutter-0.9 \ --include=Meta-2.25 \ --add-include-path=$(builddir) \ --include=Big-1.0 \ @@ -106,7 +106,7 @@ CLEANFILES += Shell-1.0.gir # The dependency on libgnome-shell.la here is because g-ir-compiler opens it # (not the fake library, since we've already done the rewriting) -Shell-0.1.typelib: libgnome-shell.la Shell-0.1.gir +Shell-0.1.typelib: libgnome-shell.la Shell-0.1.gir Big-1.0.gir LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. g-ir-compiler --includedir=$(builddir) --includedir=$(libdir)/metacity/ Shell-0.1.gir -o $@ CLEANFILES += Shell-1.0.typelib @@ -114,7 +114,7 @@ Tidy-1.0.gir: $(metacity) $(G_IR_SCANNER) libgnome-shell.la libtidy-1.0.la Makef $(G_IR_SCANNER) \ --namespace=Tidy \ --nsversion=1.0 \ - --include=Clutter-0.8 \ + --include=Clutter-0.9 \ --program=metacity \ --program-arg=--mutter-plugins=$$(pwd)/libgnome-shell.la \ $(tidy_source_h) \ @@ -132,7 +132,8 @@ Big-1.0.gir: $(metacity) $(G_IR_SCANNER) libgnome-shell.la libbig-1.0.la Makefil $(G_IR_SCANNER) \ --namespace=Big \ --nsversion=1.0 \ - --include=ClutterCairo-0.8 \ + --include=Clutter-0.9 \ + --include=GdkPixbuf-2.0 \ --program=metacity \ --program-arg=--mutter-plugins=$$(pwd)/libgnome-shell.la \ $(big_source_h) \ diff --git a/src/shell-global.c b/src/shell-global.c index fdffaa7ca..6f617eadc 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -421,6 +421,15 @@ shell_get_categories_for_desktop_file(const char *desktop_file_name) return categories_list; } +guint16 +shell_get_event_key_symbol(ClutterEvent *event) +{ + g_return_val_if_fail(event->type == CLUTTER_KEY_PRESS || + event->type == CLUTTER_KEY_RELEASE, 0); + + return event->key.keyval; +} + /** * shell_global_get: * diff --git a/src/shell-global.h b/src/shell-global.h index 8d07b47d5..b9c9c413b 100644 --- a/src/shell-global.h +++ b/src/shell-global.h @@ -38,6 +38,8 @@ GdkPixbuf *shell_get_thumbnail_for_recent_info(GtkRecentInfo *recent_info); GSList *shell_get_categories_for_desktop_file(const char *desktop_file_name); +guint16 shell_get_event_key_symbol(ClutterEvent *event); + ShellGlobal *shell_global_get (void); void shell_global_grab_dbus_service (ShellGlobal *global); diff --git a/src/shell-status-menu.c b/src/shell-status-menu.c index 6a867d5e3..ab4fb5a4d 100644 --- a/src/shell-status-menu.c +++ b/src/shell-status-menu.c @@ -50,7 +50,7 @@ struct _ShellStatusMenuPrivate { ClutterTexture *user_icon; BigBox *name_box; - ClutterLabel *name; + ClutterText *name; GtkWidget *menu; GtkWidget *account_item; @@ -110,15 +110,14 @@ reset_icon (ShellStatusMenu *status) } static void -update_label (ShellStatusMenu *status) +update_name_text (ShellStatusMenu *status) { ShellStatusMenuPrivate *priv = status->priv; char *markup; - markup = g_strdup_printf ("%s", - gdm_user_get_real_name (GDM_USER (priv->user))); - clutter_label_set_use_markup (priv->name, TRUE); - clutter_label_set_text (priv->name, markup); + markup = g_markup_printf_escaped("%s", + gdm_user_get_real_name (GDM_USER (priv->user))); + clutter_text_set_markup (priv->name, markup); g_free (markup); } @@ -135,7 +134,7 @@ user_notify_display_name_cb (GObject *object, GParamSpec *pspec, ShellStatusMenu *status) { - update_label (status); + update_name_text (status); } static void @@ -155,7 +154,7 @@ setup_current_user (ShellStatusMenu *status) name = _("Unknown"); } - update_label (status); + update_name_text (status); if (priv->user != NULL) { @@ -541,7 +540,7 @@ shell_status_menu_init (ShellStatusMenu *status) priv->name_box = BIG_BOX (big_box_new (BIG_BOX_ORIENTATION_VERTICAL)); g_object_set (G_OBJECT (priv->name_box), "y-align", BIG_BOX_ALIGNMENT_CENTER, NULL); big_box_append (BIG_BOX (status), CLUTTER_ACTOR (priv->name_box), BIG_BOX_PACK_EXPAND); - priv->name = CLUTTER_LABEL (clutter_label_new ()); + priv->name = CLUTTER_TEXT (clutter_text_new ()); big_box_append (BIG_BOX (priv->name_box), CLUTTER_ACTOR (priv->name), BIG_BOX_PACK_EXPAND); priv->manager = gdm_user_manager_ref_default (); @@ -622,4 +621,4 @@ shell_status_menu_toggle (ShellStatusMenu *status, ClutterEvent *event) gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, position_menu, status, 1, event->button.time); } -} \ No newline at end of file +} diff --git a/tools/build/gnome-shell.modules b/tools/build/gnome-shell.modules index 7c9e7919a..cda03e23b 100644 --- a/tools/build/gnome-shell.modules +++ b/tools/build/gnome-shell.modules @@ -3,11 +3,6 @@ - - - - - - @@ -39,11 +32,10 @@ - - - - - + + + +