Python gi.repository.GObject.Object() Examples
The following are 16
code examples of gi.repository.GObject.Object().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.GObject
, or try the search function
.
Example #1
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def gobject_get_value(gobject, gtype=None): """ Retrieve the value of a GObject widget. Only objects with corresponding entries present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by this function. :param gobject: The object to retrieve the value for. :type gobject: :py:class:`GObject.Object` :param str gtype: An explicit type to treat *gobject* as. :return: The value of *gobject*. :rtype: str """ gtype = (gtype or gobject.__class__.__name__) gtype = gtype.lower() if isinstance(GOBJECT_PROPERTY_MAP[gtype], (list, tuple)): try: value = GOBJECT_PROPERTY_MAP[gtype][1](gobject) except AttributeError: return None else: value = gobject.get_property(GOBJECT_PROPERTY_MAP[gtype]) return value
Example #2
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def gobject_set_value(gobject, value, gtype=None): """ Set the value of a GObject widget. Only objects with corresponding entries present in the :py:data:`.GOBJECT_PROPERTY_MAP` can be processed by this function. :param gobject: The object to set the value for. :type gobject: :py:class:`GObject.Object` :param value: The value to set for the object. :param str gtype: An explicit type to treat *gobject* as. """ gtype = (gtype or gobject.__class__.__name__) gtype = gtype.lower() if gtype not in GOBJECT_PROPERTY_MAP: raise ValueError('unsupported gtype: ' + gtype) if isinstance(GOBJECT_PROPERTY_MAP[gtype], (list, tuple)): GOBJECT_PROPERTY_MAP[gtype][0](gobject, value) else: gobject.set_property(GOBJECT_PROPERTY_MAP[gtype], value)
Example #3
Source File: builder.py From pympress with GNU General Public License v2.0 | 6 votes |
def signal_connector(self, builder, object, signal_name, handler_name, connect_object, flags, *user_data): """ Callback for signal connection. Implements the `~Gtk.BuilderConnectFunc` function interface. Args: builder (:class:`~pympress.builder.Builder`): The builder, unused object (:class:`~GObject.Object`): The object (usually a wiget) that has a signal to be connected signal_name (`str`): The name of the signal handler_name (`str`): The name of the function to be connected to the signal connect_object (:class:`~GObject.Object`): unused flags (:class:`~GObject.ConnectFlags`): unused user_data (`tuple`): supplementary positional arguments to be passed to the handler """ try: handler = self.get_callback_handler(handler_name) object.connect(signal_name, handler, *user_data) except Exception: logger.critical('Impossible to connect signal {} from object {} to handler {}' .format(signal_name, object, handler_name), exc_info = True)
Example #4
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def gobject_signal_blocked(gobject, signal_name): """ This is a context manager that can be used with the 'with' statement to execute a block of code while *signal_name* is blocked. :param gobject: The object to block the signal on. :type gobject: :py:class:`GObject.Object` :param str signal_name: The name of the signal to block. """ signal_id = GObject.signal_lookup(signal_name, gobject.__class__) handler_id = GObject.signal_handler_find(gobject, GObject.SignalMatchType.ID, signal_id, 0, None, 0, 0) GObject.signal_handler_block(gobject, handler_id) yield GObject.signal_handler_unblock(gobject, handler_id)
Example #5
Source File: gui_utilities.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def gtk_builder_get(self, gobject_id, parent_name=None): """ Find the child GObject with name *gobject_id* from the GTK builder. :param str gobject_id: The object name to look for. :param str parent_name: The name of the parent object in the builder data file. :return: The GObject as found by the GTK builder. :rtype: :py:class:`GObject.Object` """ parent_name = parent_name or self.dependencies.name gtkbuilder_id = "{0}.{1}".format(parent_name, gobject_id) self.logger.debug('loading GTK builder object with id: ' + gtkbuilder_id) return self.gtk_builder.get_object(gtkbuilder_id)
Example #6
Source File: budgiesysmonitor.py From indicator-sysmonitor with GNU General Public License v3.0 | 5 votes |
def __init__(self): """ Initialisation is important. """ GObject.Object.__init__(self)
Example #7
Source File: alttoolbar_preferences.py From alternative-toolbar with GNU General Public License v3.0 | 5 votes |
def __init__(self): """ Initialises the preferences, getting an instance of the settings saved by Gio. """ GObject.Object.__init__(self) self.gs = GSetting() self.plugin_settings = self.gs.get_setting(self.gs.Path.PLUGIN)
Example #8
Source File: alternative-toolbar.py From alternative-toolbar with GNU General Public License v3.0 | 5 votes |
def __init__(self): """ Initialises the plugin object. """ GObject.Object.__init__(self) self.appshell = None self.sh_psc = self.sh_op = self.sh_pc = None
Example #9
Source File: alttoolbar_repeat.py From alternative-toolbar with GNU General Public License v3.0 | 5 votes |
def __init__(self, shell, toggle_button): """ :param shell: the plugin object :param toggle_button: button that controls the repeat functions """ GObject.Object.__init__(self) # use this to start the repeat-one-song capability (if True) self.repeat_song = False self.toggle_button = toggle_button self.song_changed = self.SONG_CHANGED_MANUAL player = shell.props.shell_player # EOS signal means that the song changed because the song is over. # ie. the user did not manually change the song. # https://developer.gnome.org/rhythmbox/unstable/RBPlayer.html#RBPlayer-eos player.props.player.connect('eos', self.on_gst_player_eos) player.connect('playing-song-changed', self.on_song_change) # This hack is no longer needed when the above signal handlers # work. For more details, refer to the comments above the # definition of method on_elapsed_change. # player.connect('elapsed-changed', self.on_elapsed_change) try: popover = Gtk.Popover.new(toggle_button) except AttributeError: # use our custom Popover equivalent for Gtk+3.10 folks popover = CustomPopover(toggle_button) else: popover.set_modal(False) finally: repeat = RepeatPopContainer(popover, toggle_button) popover.add(repeat) toggle_button.connect('toggled', self._on_toggle, popover, repeat) repeat.connect('repeat-type-changed', self._on_repeat_type_changed) self._on_repeat_type_changed(repeat, repeat.get_repeat_type())
Example #10
Source File: intelligent_text_completion.py From gedit-intelligent-text-completion with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): GObject.Object.__init__(self) self._instances = {}
Example #11
Source File: intelligent_text_completion.py From gedit-intelligent-text-completion with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): GObject.Object.__init__(self) self._instances = {}
Example #12
Source File: gedi.py From gedi with GNU General Public License v3.0 | 5 votes |
def __init__(self): GObject.Object.__init__(self) self.completion_provider = None
Example #13
Source File: gedi.py From gedi with GNU General Public License v3.0 | 5 votes |
def __init__(self): GObject.Object.__init__(self)
Example #14
Source File: builder.py From pympress with GNU General Public License v2.0 | 5 votes |
def __translate_widget_strings(a_widget): """ Calls gettext on all strings we can find in a_widgets. Args: a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget """ for str_prop in (prop.name for prop in a_widget.props if prop.value_type == GObject.TYPE_STRING): try: str_val = getattr(a_widget.props, str_prop) if str_val: setattr(a_widget.props, str_prop, _(str_val)) except TypeError: # Thrown when a string property is not readable pass
Example #15
Source File: builder.py From pympress with GNU General Public License v2.0 | 5 votes |
def __recursive_translate_widgets(a_widget): """ Calls gettext on all strings we can find in widgets, and recursively on its children. Args: a_widget (:class:`~GObject.Object`): an object built by the builder, usually a widget """ Builder.__translate_widget_strings(a_widget) if issubclass(type(a_widget), Gtk.Container): # NB: Parent-loop in widgets would cause infinite loop here, but that's absurd (right?) # NB2: maybe forall instead of foreach if we miss some strings? a_widget.foreach(Builder.__recursive_translate_widgets) if issubclass(type(a_widget), Gtk.MenuItem) and a_widget.get_submenu() is not None: Builder.__recursive_translate_widgets(a_widget.get_submenu())
Example #16
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 4 votes |
def __init__(self): GObject.Object.__init__(self) if dbus.SessionBus().request_name('es.atareao.MyWeatherIndicator') !=\ dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: print("application already running") exit(0) # self.weather_updater = 0 self.widgets_updater = 0 self.internet_updater = 0 self.internet_connection = False self.menus = [] self.indicators = [] self.notifications = [] self.widgets = [] self.weatherservices = [] self.weathers = [] self.current_conditions = [] self.preferences = [] self.last_update_time = 0 # Iniciate variables for i in range(INDICATORS): self.menus.append(None) self.indicators.append(None) self.notifications.append(None) self.widgets.append(None) self.weatherservices.append(None) self.weathers.append(None) self.current_conditions.append(None) self.preferences.append(None) # status = appindicator.IndicatorCategory.APPLICATION_STATUS self.notifications[0] = Notify.Notification.new('', '', None) self.indicators[0] = appindicator.Indicator.new( 'My-Weather-Indicator', 'My-Weather-Indicator', status) self.notifications[1] = Notify.Notification.new('', '', None) self.indicators[1] = appindicator.Indicator.new( 'My-Weather-Indicator2', 'My-Weather-Indicator', status) for i in range(INDICATORS): self.create_menu(i) for i in range(INDICATORS): self.widgets[i] = None self.load_preferences()