static void
ide_highlight_engine__bind_buffer_cb (IdeHighlightEngine *self,
                                      IdeBuffer          *buffer,
                                      EggSignalGroup     *group)
{
    GtkTextBuffer *text_buffer = (GtkTextBuffer *)buffer;
    GtkTextIter begin;
    GtkTextIter end;

    IDE_ENTRY;

    g_assert (IDE_IS_HIGHLIGHT_ENGINE (self));
    g_assert (IDE_IS_BUFFER (buffer));
    g_assert (EGG_IS_SIGNAL_GROUP (group));

    ide_set_weak_pointer (&self->buffer, buffer);

    g_object_set_qdata (G_OBJECT (buffer), gEngineQuark, self);

    gtk_text_buffer_get_bounds (text_buffer, &begin, &end);

    self->invalid_begin = gtk_text_buffer_create_mark (text_buffer, NULL, &begin, TRUE);
    self->invalid_end = gtk_text_buffer_create_mark (text_buffer, NULL, &end, FALSE);

    ide_highlight_engine_reload (self);

    IDE_EXIT;
}
static void
ide_xml_highlighter_real_set_engine (IdeHighlighter     *highlighter,
                                     IdeHighlightEngine *engine)
{
  IdeXmlHighlighter *self = (IdeXmlHighlighter *)highlighter;
  IdeBuffer *buffer = NULL;

  g_return_if_fail (IDE_IS_XML_HIGHLIGHTER (self));
  g_return_if_fail (IDE_IS_HIGHLIGHT_ENGINE (engine));

  if (ide_set_weak_pointer (&self->engine, engine))
    {
      buffer = ide_highlight_engine_get_buffer (engine);
      /*
       * TODO: technically we should connect/disconnect when the
       *       highlighter changes. but in practice, it is set only
       *       once.
       */
      g_signal_connect_object (engine,
                               "notify::buffer",
                               G_CALLBACK (ide_xml_highlighter_on_buffer_set),
                               self,
                               G_CONNECT_SWAPPED);
    }

  ide_xml_highlighter_set_buffer (self, buffer);
}
static void
ide_file_settings_set_file (IdeFileSettings *self,
                            IdeFile         *file)
{
  IdeFileSettingsPrivate *priv = ide_file_settings_get_instance_private (self);

  g_return_if_fail (IDE_IS_FILE_SETTINGS (self));
  g_return_if_fail (IDE_IS_FILE (file));

  if (ide_set_weak_pointer (&priv->file, file))
    g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FILE]);
}
示例#4
0
static void
ide_editor_spell_widget_set_view (IdeEditorSpellWidget *self,
                                  IdeSourceView        *view)
{
  g_return_if_fail (IDE_IS_EDITOR_SPELL_WIDGET (self));
  g_return_if_fail (IDE_IS_SOURCE_VIEW (view));

  ide_set_weak_pointer (&self->view, view);
  if (GSPELL_IS_NAVIGATOR (self->navigator))
    g_clear_object (&self->navigator);

  self->navigator = ide_editor_spell_navigator_new (GTK_TEXT_VIEW (view));
}
static void
ide_xml_highlighter_bind_buffer_cb (IdeXmlHighlighter  *self,
                                    IdeBuffer          *buffer,
                                    EggSignalGroup     *group)
{
  GtkTextIter begin;

  g_assert (IDE_IS_XML_HIGHLIGHTER (self));
  g_assert (IDE_IS_BUFFER (buffer));
  g_assert (EGG_IS_SIGNAL_GROUP (group));

  ide_set_weak_pointer (&self->buffer, GTK_TEXT_BUFFER (buffer));

  gtk_text_buffer_get_start_iter (self->buffer, &begin);
  self->iter_mark = gtk_text_buffer_create_mark (self->buffer, NULL, &begin, TRUE);
}
static void
ide_git_buffer_change_monitor_set_buffer (IdeBufferChangeMonitor *monitor,
                                          IdeBuffer              *buffer)
{
  IdeGitBufferChangeMonitor *self = (IdeGitBufferChangeMonitor *)monitor;
  IdeContext *context;
  IdeVcs *vcs;

  g_return_if_fail (IDE_IS_GIT_BUFFER_CHANGE_MONITOR (self));
  g_return_if_fail (IDE_IS_BUFFER (buffer));
  g_return_if_fail (!self->buffer);

  ide_set_weak_pointer (&self->buffer, buffer);

  context = ide_object_get_context (IDE_OBJECT (self));
  vcs = ide_context_get_vcs (context);

  egg_signal_group_set_target (self->signal_group, buffer);
  egg_signal_group_set_target (self->vcs_signal_group, vcs);
}
示例#7
0
static void
gb_view_stack_context_handler (GtkWidget  *widget,
                               IdeContext *context)
{
  IdeBackForwardList *back_forward;
  GbViewStack *self = (GbViewStack *)widget;

  g_assert (GTK_IS_WIDGET (widget));
  g_assert (!context || IDE_IS_CONTEXT (context));

  if (context)
    {
      GList *children;
      GList *iter;

      ide_set_weak_pointer (&self->context, context);

      back_forward = ide_context_get_back_forward_list (context);

      g_clear_object (&self->back_forward_list);
      self->back_forward_list = ide_back_forward_list_branch (back_forward);

      g_signal_connect_object (self->back_forward_list,
                               "navigate-to",
                               G_CALLBACK (navigate_to_cb),
                               self,
                               G_CONNECT_SWAPPED);

      g_object_bind_property (self->back_forward_list, "can-go-backward",
                              self->go_backward, "sensitive",
                              G_BINDING_SYNC_CREATE);
      g_object_bind_property (self->back_forward_list, "can-go-forward",
                              self->go_forward, "sensitive",
                              G_BINDING_SYNC_CREATE);

      children = gtk_container_get_children (GTK_CONTAINER (self->stack));
      for (iter = children; iter; iter = iter->next)
        gb_view_set_back_forward_list (iter->data, self->back_forward_list);
      g_list_free (children);
    }
}
GtkSourceCompletionProposal *
ide_ctags_completion_item_new (const IdeCtagsIndexEntry   *entry,
                               IdeCtagsCompletionProvider *provider,
                               GtkSourceCompletionContext *context)
{
  IdeCtagsCompletionItem *self;

  self= g_object_new (IDE_TYPE_CTAGS_COMPLETION_ITEM, NULL);

  /*
   * use borrowed references to avoid the massive amount of reference counting.
   * we don't need them since we know the provider will outlast us.
   */
  self->entry = entry;
  self->provider = provider;

  /*
   * There is the slight chance the context will get disposed out of
   * our control. I've seen this happen a few times now.
   */
  ide_set_weak_pointer (&self->context, context);

  return GTK_SOURCE_COMPLETION_PROPOSAL (self);
}
示例#9
0
void
gb_slider_set_position (GbSlider         *self,
                        GbSliderPosition  position)
{
  GbSliderPrivate *priv = gb_slider_get_instance_private (self);

  g_return_if_fail (GB_IS_SLIDER (self));
  g_return_if_fail (position >= GB_SLIDER_NONE);
  g_return_if_fail (position <= GB_SLIDER_LEFT);

  if (priv->position != position)
    {
      GdkFrameClock *frame_clock;
      EggAnimation *anim;
      gdouble v_value;
      gdouble h_value;

      priv->position = position;

      if (priv->h_anim)
        egg_animation_stop (priv->h_anim);
      ide_clear_weak_pointer (&priv->h_anim);

      if (priv->v_anim)
        egg_animation_stop (priv->v_anim);
      ide_clear_weak_pointer (&priv->v_anim);

      switch (position)
        {
        case GB_SLIDER_NONE:
          h_value = 0.0;
          v_value = 0.0;
          break;

        case GB_SLIDER_TOP:
          h_value = 0.0;
          v_value = 1.0;
          break;

        case GB_SLIDER_RIGHT:
          h_value = -1.0;
          v_value = 0.0;
          break;

        case GB_SLIDER_BOTTOM:
          h_value = 0.0;
          v_value = -1.0;
          break;

        case GB_SLIDER_LEFT:
          h_value = 1.0;
          v_value = 0.0;
          break;

        default:
          g_assert_not_reached ();
          break;
        }

      frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));

      anim = egg_object_animate (priv->h_adj,
                                 ANIMATION_MODE,
                                 ANIMATION_DURATION,
                                 frame_clock,
                                 "value", h_value,
                                 NULL);
      ide_set_weak_pointer (&priv->h_anim, anim);

      anim = egg_object_animate (priv->v_adj,
                                 ANIMATION_MODE,
                                 ANIMATION_DURATION,
                                 frame_clock,
                                 "value", v_value,
                                 NULL);
      ide_set_weak_pointer (&priv->v_anim, anim);

      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_POSITION]);
      gtk_widget_queue_resize (GTK_WIDGET (self));
    }
}
示例#10
0
void
gb_view_stack_set_active_view (GbViewStack *self,
                               GtkWidget   *active_view)
{
  g_return_if_fail (GB_IS_VIEW_STACK (self));
  g_return_if_fail (!active_view || GB_IS_VIEW (active_view));

  if (self->destroyed)
    return;

  if (self->active_view != active_view)
    {
      if (self->active_view)
        {
          if (self->title_binding)
            g_binding_unbind (self->title_binding);
          ide_clear_weak_pointer (&self->title_binding);
          if (self->modified_binding)
            g_binding_unbind (self->modified_binding);
          ide_clear_weak_pointer (&self->modified_binding);
          gtk_label_set_label (self->title_label, NULL);
          ide_clear_weak_pointer (&self->active_view);
          gtk_widget_hide (GTK_WIDGET (self->controls_stack));
        }

      if (active_view)
        {
          GtkWidget *controls;
          GBinding *binding;
          GActionGroup *group;

          ide_set_weak_pointer (&self->active_view, active_view);
          if (active_view != gtk_stack_get_visible_child (self->stack))
            gtk_stack_set_visible_child (self->stack, active_view);

          self->focus_history = g_list_remove (self->focus_history, active_view);
          self->focus_history = g_list_prepend (self->focus_history, active_view);

          binding = g_object_bind_property (active_view, "title",
                                            self->title_label, "label",
                                            G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
          ide_set_weak_pointer (&self->title_binding, binding);

          binding = g_object_bind_property (active_view, "modified",
                                            self->modified_label, "visible",
                                            G_BINDING_SYNC_CREATE);
          ide_set_weak_pointer (&self->modified_binding, binding);

          controls = gb_view_get_controls (GB_VIEW (active_view));
          if (controls)
            {
              gtk_stack_set_visible_child (self->controls_stack, controls);
              gtk_widget_show (GTK_WIDGET (self->controls_stack));
            }

          group = gtk_widget_get_action_group (active_view, "view");
          if (group)
            gtk_widget_insert_action_group (GTK_WIDGET (self), "view", group);

          gb_view_stack_move_top_list_row (self, GB_VIEW (active_view));
        }

      g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_ACTIVE_VIEW]);
    }
}