From 79764c7d4f07326ea2bd74ec1c1dbdcb5f31720a Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 21 Apr 2006 15:53:26 -0400 Subject: [PATCH] Add a method to show/hide close buttons on the tab --- browser/browser.py | 8 ++++++++ shell/example-activity/example-activity.py | 7 +++++++ shell/src/shell.py | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/browser/browser.py b/browser/browser.py index 7e310579..9da67960 100755 --- a/browser/browser.py +++ b/browser/browser.py @@ -61,6 +61,13 @@ class Activity(dbus.service.Object): def activity_get_gtk_plug(self): return self.__plug + def activity_set_can_close(self, can_close): + self.__activity_object.set_can_close(can_close) + + @dbus.service.method("com.redhat.Sugar.Activity", \ + in_signature="", \ + out_signature="") + def activity_set_tab_text(self, text): self.__activity_object.set_tab_text(text) @@ -273,6 +280,7 @@ class BrowserActivity(Activity): self.uri = uri def activity_on_connected_to_shell(self): + self.activity_set_can_close(True) self.activity_set_tab_text("Web Page") vbox = gtk.VBox() diff --git a/shell/example-activity/example-activity.py b/shell/example-activity/example-activity.py index 3f0b97e1..852f1931 100755 --- a/shell/example-activity/example-activity.py +++ b/shell/example-activity/example-activity.py @@ -63,6 +63,13 @@ class Activity(dbus.service.Object): def activity_get_gtk_plug(self): return self.__plug + def activity_set_can_close(self, can_close): + self.__activity_object.set_can_close(can_close) + + @dbus.service.method("com.redhat.Sugar.Activity", \ + in_signature="", \ + out_signature="") + def activity_set_tab_text(self, text): self.__activity_object.set_tab_text(text) diff --git a/shell/src/shell.py b/shell/src/shell.py index ffeceecb..dd5f8c95 100755 --- a/shell/src/shell.py +++ b/shell/src/shell.py @@ -63,7 +63,6 @@ class ActivityHost(dbus.service.Object): self.tab_close_button.add(close_image) self.tab_close_button.set_relief(gtk.RELIEF_NONE) self.tab_close_button.set_focus_on_click(gtk.FALSE) - self.tab_close_button.show() self.tab_close_button.connect("clicked", self.tab_close_button_clicked) label_hbox.pack_start(self.tab_label) @@ -98,6 +97,15 @@ class ActivityHost(dbus.service.Object): self.__peer_service_name, self.__peer_object_name), \ "com.redhat.Sugar.Activity") + @dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \ + in_signature="b", \ + out_signature="") + def set_can_close(self, can_close): + if can_close: + self.tab_close_button.show() + else: + self.tab_close_button.hide() + @dbus.service.method("com.redhat.Sugar.Shell.ActivityHost", \ in_signature="s", \ out_signature="")