def __init__(self, notebook): self.notebook = notebook self.path = None self.current_editor = None self.ui_manager = gtk.UIManager() self.action_group = gtk.ActionGroup("main") self._add_actions(self.action_group) self.ui_manager.insert_action_group(self.action_group, 0) self.ui_manager.add_ui_from_string(self.UI_STRING) self.ui_manager.ensure_update() menu = self.ui_manager.get_widget("/TopMenu") toolbar = self.ui_manager.get_widget("/ToolBar") self._create_window(menu, toolbar) # We want each toplevel to have separate modality window_group = gtk.WindowGroup() window_group.add_window(self.window) self.window.add_accel_group(self.ui_manager.get_accel_group()) self.main_vbox.show_all() self.window.connect('key-press-event', self.on_key_press_event) self.window.connect('delete-event', self.on_delete_event) self.window.connect('notify::is-active', self.on_notify_is_active)
def main(): window_group = gtk.WindowGroup() main_window = create_window('main_window') window_group.add_window(main_window) for i in range(0, 3): child_window = create_window('child window #%d' % i) child_window.set_transient_for(main_window) window_group.add_window(child_window) gtk.main()
def _launcher_ui_bootstrap(self): self._restore_window_size() self._update_toolbar_style() self.hide_app(empty=True) self._check_demo_mode() self._check_online_plugins() self._birthdays_bar = None self._check_client_birthdays() # json will restore tuples as lists. We need to convert them # to tuples or the comparison bellow won't work. actual_version = tuple(api.user_settings.get('actual-version', (0, ))) if stoq.stoq_version > actual_version: api.user_settings.set('last-version-check', None) self._display_changelog_message() # Display the changelog message only once. Most users will never # click on the "See what's new" button, and that will affect its # visual identity. api.user_settings.set('actual-version', stoq.stoq_version) self._check_information() if not stoq.stable and not api.is_developer_mode(): self._display_unstable_version_message() if not self.in_ui_test: # Initial fullscreen state for launcher must be handled # separate since the window is not realized when the state loading # is run in hide_app() the first time. window = self.get_toplevel() window.realize() self.ToggleFullscreen.set_active( self._app_settings.get('show-fullscreen', False)) self.ToggleFullscreen.notify('active') toplevel = self.get_toplevel() toplevel.connect('configure-event', self._on_toplevel__configure) toplevel.connect('delete-event', self._on_toplevel__delete_event) toplevel.add_accel_group(self.uimanager.get_accel_group()) # A GtkWindowGroup controls grabs (blocking mouse/keyboard interaction), # by default all windows are added to the same window group. # We want to avoid setting modallity on other windows # when running a dialog using gtk_dialog_run/run_dialog. window_group = gtk.WindowGroup() window_group.add_window(toplevel)
def popup(self, time=None): if not (self.widgetToAlignWith.flags() & gtk.REALIZED): return if (self.flags() & gtk.MAPPED): return if not (self.widgetToAlignWith.flags() & gtk.MAPPED): return if len(self.view.get_model()) <= 0: return self.ignore_enter = True if not self.window_group: target_toplevel = self.widgetToAlignWith.get_toplevel() if target_toplevel != None and target_toplevel.group != None: target_toplevel.group.add_window(self) self.target_group = target_toplevel.group elif target_toplevel is not None: self.window_group = gtk.WindowGroup() self.window_group.add_window(target_toplevel) self.window_group.add_window(self) else: LOGGER.warning( "CuemiacEntryPopup : No toplevel window for widgetToAlignWith!" ) return self.update_position() gtk.Window.show_all( self) # We issue warnings on the native methods, so bypass that # For grabbing to work we need the view realized if not (self.flags() & gtk.REALIZED): self.realize() # Grab pointer self.grab_add() gtk.gdk.pointer_grab( self.window, True, gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK, None, None, gtk.get_current_event_time()) gtk.gdk.keyboard_grab(self.window, True, gtk.get_current_event_time()) first = self.view.get_model().get_iter_first() if first != None: self.view.get_selection().select_iter(first)
def __init__(self): super(type(self), self).__init__() debug(DEBUG_WINDOW) self._active_tab = None self._num_tabs = 0 self._removing_tabs = False self._state = WINDOW_STATE_NORMAL self._dispose_has_run = False self._fullscreen_controls = None self._fullscreen_animation_timeout_id = 0 #TODO #self._message_bus = MessageBus() self._window_group = gtk.WindowGroup() self._window_group.add_window(self) main_box = gtk.VBox(False, 0) self.add(main_box) main_box.show() # Add menu bar and toolbar bar self.create_menu_bar_and_toolbar(main_box) # Add status bar self.create_statusbar(main_box) # Add the main area debug_message(DEBUG_WINDOW, "Add main area") self._hpaned = gtk.HPaned() main_box.pack_start(self._hpaned, True, True, 0) self._vpaned = gtk.VPaned() self._hpaned.pack2(self._vpaned, True, False) debug_message(DEBUG_WINDOW, "Create taluka notebook") self._notebook = Notebook() self.add_notebook(self._notebook) # side and bottom panels self.create_side_panel() self.create_bottom_panel() # panes' state must be restored after panels have been mapped, # since the bottom pane position depends on the size of the vpaned. self._side_panel_size = prefs_manager_get_side_panel_size() self._bottom_panel_size = prefs_manager_get_bottom_panel_size() self._hpaned.connect_after("map", self.hpaned_restore_position) self._vpaned.connect_after("map", self.vpaned_restore_position) self._hpaned.show() self._vpaned.show() # Drag and drop support, set targets to None because we add the # default uri_targets below self.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, (), gtk.gdk.ACTION_COPY) # Add uri targets tl = self.drag_dest_get_target_list() if tl == None: tl = () self.drag_dest_set_target_list(tl) tl += (TARGET_URI_LIST, ) # connect instead of override, so that we can # share the cb code with the view TODO # self.connect("drag_data_received", drag_data_received_cb) # we can get the clipboard only after the widget # is realized TODO # self.connect("realize", window_realized) # self.connect("unrealize", window_unrealized) # Check if the window is active for fullscreen TODO # self.connect("notify::is-active", check_window_is_active) debug_message(DEBUG_WINDOW, "Update plugins ui") # plugins_engine_get_default().activate_plugins(self) TODO # set visibility of panes. # This needs to be done after plugins activatation TODO # self.init_panels_visibility() # self.update_sensitivity_according_to_open_tabs() TODO debug_message(DEBUG_WINDOW, "END") # self._action_group = gtk.ActionGroup("ExamplePyPluginActions") # self._action_group.add_actions( # [ # ("File", None, "File", None, None, None), # ("FileNew", gtk.STOCK_NEW, None, None, None, commands._file_new), # ("FileOpen", gtk.STOCK_OPEN, None, None, None, commands._file_open), # ("FileSave", gtk.STOCK_SAVE, None, None, None, commands._file_save), # ("FileSaveAs", gtk.STOCK_SAVE_AS, None, "<shift><control>S", # "Save the current file with a different name", commands._file_save_as), # ("FileClose", gtk.STOCK_CLOSE, None, None, None, commands._file_close), # ("FileQuit", gtk.STOCK_QUIT, None, None, None, commands._file_quit), # ("Edit", None, "Edit", None, None, None), # ("EditUndo", gtk.STOCK_UNDO, None, "<control>Z", None, commands._edit_undo), # ("EditRedo", gtk.STOCK_REDO, None, "<shift><control>Z", None, commands._edit_redo), # ("EditCut", gtk.STOCK_CUT, None, None, None, commands._edit_cut), # ("EditCopy", gtk.STOCK_COPY, None, None, None, commands._edit_copy), # ("EditPaste", gtk.STOCK_PASTE, None, None, None, commands._edit_paste), # ("EditSelectAll", gtk.STOCK_SELECT_ALL, None, None, None, commands._edit_select_all) # ], # self # ) # # self._ui_manager = gtk.UIManager() # self._ui_manager.add_ui_from_file(os.path.join(reloc.DATADIR, 'taluka/taluka-ui.xml')) # self._ui_manager.insert_action_group(self._action_group, -1) # # vbox = gtk.VBox() # # self._menubar = self._ui_manager.get_widget("/MenuBar") # vbox.pack_start(self._menubar, expand=False) # # self._toolbar = self._ui_manager.get_widget("/ToolBar") # assert self._toolbar != None # vbox.pack_start(self._toolbar, expand=False) # # hpaned = gtk.HPaned() # # self._side_panel = Panel() # hpaned.pack1(self._side_panel, False, False) # # vpaned = gtk.VPaned() # self._notebook = Notebook() # vpaned.pack1(self._notebook, True, False) # # self._bottom_panel = Panel() # vpaned.pack2(self._bottom_panel, False, False) # # hpaned.pack2(vpaned, True, False) # # vbox.add(hpaned) # # self.add(vbox) # # self.connect("delete_event", self.on_delete_event) # self.connect("destroy", self.on_destroy) # self.show_all() # # # static gboolean is_first = True; # # GtkWidget *main_box; # # GtkTargetList *tl; # debug(DEBUG_WINDOW) # # window->priv = GEDIT_WINDOW_GET_PRIVATE (window); # # self._active_tab = None # # # self._num_tabs = 0; # # self._removing_tabs = FALSE; # self._state = WINDOW_STATE_NORMAL; # # self._destroy_has_run = FALSE; # self._window_group = gtk.WindowGroup() # self._window_group.add_window(self) # # main_box = gtk_vbox_new (FALSE, 0); # # gtk_container_add (GTK_CONTAINER (window), main_box); # # gtk_widget_show (main_box); # # /* Add menu bar and toolbar bar */ # # create_menu_bar_and_toolbar (window, main_box); # # /* Add status bar */ # # create_statusbar (window, main_box); # # /* Add the main area */ # # gedit_debug_message (DEBUG_WINDOW, "Add main area"); # # self._hpaned = gtk_hpaned_new (); # # gtk_box_pack_start (GTK_BOX (main_box), # # self._hpaned, # # True, # # True, # # 0); # # self._vpaned = gtk_vpaned_new (); # # gtk_paned_pack2 (GTK_PANED (self._hpaned), # # self._vpaned, # # True, # # FALSE); # # # # gedit_debug_message (DEBUG_WINDOW, "Create gedit notebook"); # # self._notebook = gedit_notebook_new (); # # gtk_paned_pack1 (GTK_PANED (self._vpaned), # # self._notebook, # # True, # # True); # # gtk_widget_show (self._notebook); # # /* side and bottom panels */ # # create_side_panel (window); # # create_bottom_panel (window); # # /* restore paned positions as soon as we know the panes allocation. # # * This needs to be done only for the first window, the successive # # * windows are created by cloning the first one */ # # if (is_first) # # { # # is_first = FALSE; # # self._side_panel_size = gedit_prefs_manager_get_side_panel_size (); # # self._bottom_panel_size = gedit_prefs_manager_get_bottom_panel_size (); # # g_signal_connect_after (self._hpaned, # # "map", # # G_CALLBACK (hpaned_restore_position), # # window); # # g_signal_connect_after (self._vpaned, # # "map", # # G_CALLBACK (vpaned_restore_position), # # window); # # } # # gtk_widget_show (self._hpaned); # # gtk_widget_show (self._vpaned); # # /* Drag and drop support, set targets to NULL because we add the # # default uri_targets below */ # # gtk_drag_dest_set (GTK_WIDGET (window), # # GTK_DEST_DEFAULT_MOTION | # # GTK_DEST_DEFAULT_HIGHLIGHT | # # GTK_DEST_DEFAULT_DROP, # # NULL, # # 0, # # GDK_ACTION_COPY); # # /* Add uri targets */ # # tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window)); # # # # if (tl == NULL) # # { # # tl = gtk_target_list_new (NULL, 0); # # gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl); # # gtk_target_list_unref (tl); # # } # # # # gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST); # # Connect signals # self._notebook.connect("switch_page", notebook_switch_page, self) # # # g_signal_connect (self._notebook, # # "tab_added", # # G_CALLBACK (notebook_tab_added), # # window); # # g_signal_connect (self._notebook, # # "tab_removed", # # G_CALLBACK (notebook_tab_removed), # # window); # # g_signal_connect (self._notebook, # # "tabs_reordered", # # G_CALLBACK (notebook_tabs_reordered), # # window); # # g_signal_connect (self._notebook, # # "tab_detached", # # G_CALLBACK (notebook_tab_detached), # # window); # # g_signal_connect (self._notebook, # # "tab_close_request", # # G_CALLBACK (notebook_tab_close_request), # # window); # # g_signal_connect (self._notebook, # # "button-press-event", # # G_CALLBACK (notebook_button_press_event), # # window); # # g_signal_connect (self._notebook, # # "popup-menu", # # G_CALLBACK (notebook_popup_menu), # # window); # # /* connect instead of override, so that we can # # * share the cb code with the view */ # # g_signal_connect (window, # # "drag_data_received", # # G_CALLBACK (drag_data_received_cb), # # None) # # /* we can get the clipboard only after the widget # # * is realized */ # # g_signal_connect (window, # # "realize", # # G_CALLBACK (window_realized), # # None) # # g_signal_connect (window, # # "unrealize", # # G_CALLBACK (window_unrealized), # # None) # # gedit_debug_message (DEBUG_WINDOW, "Update plugins ui"); # # gedit_plugins_engine_update_plugins_ui (gedit_plugins_engine_get_default (), # # window, True); # # /* set visibility of panes. # # * This needs to be done after plugins activatation */ # # init_panels_visibility (window); # # gedit_debug_message (DEBUG_WINDOW, "END"); # self.create_tab(True) self.show( ) # FIXME: Remove this file and use something like gedit-session.c instead.