Пример #1
0
static void
gb_terminal_set_needs_attention (GbTerminalView  *self,
                                 gboolean         needs_attention,
                                 GtkPositionType  position)
{
  GtkWidget *parent;

  g_assert (GB_IS_TERMINAL_VIEW (self));

  parent = gtk_widget_get_parent (GTK_WIDGET (self));

  if (GTK_IS_STACK (parent) &&
      !gtk_widget_in_destruction (GTK_WIDGET (self)) &&
      !gtk_widget_in_destruction (parent))
    {
      if (position == GTK_POS_TOP &&
          !gtk_widget_in_destruction (GTK_WIDGET (self->terminal_top)))
        {
          self->top_has_needs_attention = TRUE;
        }
      else if (position == GTK_POS_BOTTOM &&
               self->terminal_bottom != NULL &&
               !gtk_widget_in_destruction (GTK_WIDGET (self->terminal_bottom)))
        {
          self->bottom_has_needs_attention = TRUE;
        }

      gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
                               "needs-attention",
                               !!(self->top_has_needs_attention || self->bottom_has_needs_attention) &&
                               needs_attention,
                               NULL);
    }
}
Пример #2
0
/**
 * gtk_stack_switcher_set_stack:
 * @switcher: a #GtkStackSwitcher
 * @stack: (allow-none): a #GtkStack
 *
 * Sets the stack to control.
 *
 * Since: 3.10
 */
void
gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
                              GtkStack         *stack)
{
  GtkStackSwitcherPrivate *priv;

  g_return_if_fail (GTK_IS_STACK_SWITCHER (switcher));
  if (stack)
    g_return_if_fail (GTK_IS_STACK (stack));

  priv = switcher->priv;

  if (priv->stack == stack)
    return;

  if (priv->stack)
    {
      disconnect_stack_signals (switcher);
      clear_switcher (switcher);
      g_clear_object (&priv->stack);
    }

  if (stack)
    {
      priv->stack = g_object_ref (stack);
      populate_switcher (switcher);
      connect_stack_signals (switcher);
    }

  gtk_widget_queue_resize (GTK_WIDGET (switcher));

  g_object_notify (G_OBJECT (switcher), "stack");
}
Пример #3
0
static void
ide_workbench_notify_visible_child (IdeWorkbench *self,
                                    GParamSpec   *pspec,
                                    GtkStack     *stack)
{
  IdePerspective *perspective;

  g_assert (IDE_IS_WORKBENCH (self));
  g_assert (GTK_IS_STACK (stack));

  perspective = IDE_PERSPECTIVE (gtk_stack_get_visible_child (stack));

  if (perspective != NULL)
    {
      GActionGroup *actions;
      gchar *id;

      id = ide_perspective_get_id (perspective);
      gtk_stack_set_visible_child_name (self->titlebar_stack, id);

      actions = ide_perspective_get_actions (perspective);
      gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions);

      g_clear_object (&actions);
      g_free (id);
    }
}
Пример #4
0
void
pnl_tab_strip_set_stack (PnlTabStrip *self,
                         GtkStack    *stack)
{
  PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self);

  g_return_if_fail (PNL_IS_TAB_STRIP (self));
  g_return_if_fail (!stack || GTK_IS_STACK (stack));

  if (stack != priv->stack)
    {
      if (priv->stack != NULL)
        {
          g_signal_handlers_disconnect_by_func (priv->stack,
                                                G_CALLBACK (pnl_tab_strip_stack_notify_visible_child),
                                                self);

          g_signal_handlers_disconnect_by_func (priv->stack,
                                                G_CALLBACK (pnl_tab_strip_stack_add),
                                                self);

          g_signal_handlers_disconnect_by_func (priv->stack,
                                                G_CALLBACK (pnl_tab_strip_stack_remove),
                                                self);

          gtk_container_foreach (GTK_CONTAINER (self), (GtkCallback)gtk_widget_destroy, NULL);

          g_clear_object (&priv->stack);
        }

      if (stack != NULL)
        {
          priv->stack = g_object_ref (stack);

          g_signal_connect_object (priv->stack,
                                   "notify::visible-child",
                                   G_CALLBACK (pnl_tab_strip_stack_notify_visible_child),
                                   self,
                                   G_CONNECT_SWAPPED);

          g_signal_connect_object (priv->stack,
                                   "add",
                                   G_CALLBACK (pnl_tab_strip_stack_add),
                                   self,
                                   G_CONNECT_SWAPPED);

          g_signal_connect_object (priv->stack,
                                   "remove",
                                   G_CALLBACK (pnl_tab_strip_stack_remove),
                                   self,
                                   G_CONNECT_SWAPPED);

          gtk_container_foreach (GTK_CONTAINER (priv->stack),
                                 pnl_tab_strip_cold_plug,
                                 self);
        }
    }
}
Пример #5
0
static void
ide_frame_notify_visible_child (IdeFrame   *self,
                                GParamSpec *pspec,
                                GtkStack   *stack)
{
  IdeFramePrivate *priv = ide_frame_get_instance_private (self);
  GtkWidget *visible_child;

  g_assert (IDE_IS_FRAME (self));
  g_assert (GTK_IS_STACK (stack));

  if (gtk_widget_in_destruction (GTK_WIDGET (self)))
    return;

  if ((visible_child = gtk_stack_get_visible_child (priv->stack)))
    {
      if (gtk_widget_in_destruction (visible_child))
        visible_child = NULL;
    }

  /*
   * Mux/Proxy actions to our level so that they also be activated
   * from the header bar without any weirdness by the View.
   */
  dzl_gtk_widget_mux_action_groups (GTK_WIDGET (self), visible_child,
                                    "IDE_FRAME_MUXED_ACTION");

  /* Update our bindings targets */
  dzl_binding_group_set_source (priv->bindings, visible_child);
  dzl_signal_group_set_target (priv->signals, visible_child);

  /* Show either the empty state, failed state, or actual page */
  if (visible_child != NULL &&
      ide_page_get_failed (IDE_PAGE (visible_child)))
    gtk_stack_set_visible_child (priv->top_stack, GTK_WIDGET (priv->failed_state));
  else if (visible_child != NULL)
    gtk_stack_set_visible_child (priv->top_stack, GTK_WIDGET (priv->stack));
  else
    gtk_stack_set_visible_child (priv->top_stack, GTK_WIDGET (priv->empty_placeholder));

  /* Allow the header to update settings */
  _ide_frame_header_update (priv->header, IDE_PAGE (visible_child));

  /* Ensure action state is up to date */
  _ide_frame_update_actions (self);

  if (priv->addins != NULL)
    peas_extension_set_foreach (priv->addins,
                                ide_frame_notify_addin_of_page,
                                visible_child);

  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_VISIBLE_CHILD]);
  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_HAS_VIEW]);
}
Пример #6
0
static void
gb_view_stack__notify_visible_child (GbViewStack *self,
                                     GParamSpec  *pspec,
                                     GtkStack    *stack)
{
  GtkWidget *visible_child;

  g_assert (GB_IS_VIEW_STACK (self));
  g_assert (GTK_IS_STACK (stack));

  visible_child = gtk_stack_get_visible_child (stack);

  gb_view_stack_set_active_view (self, visible_child);
}
Пример #7
0
static void
pnl_tab_strip_stack_add (PnlTabStrip *self,
                         GtkWidget   *widget,
                         GtkStack    *stack)
{
  PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self);
  GVariant *target;
  PnlTab *tab;
  gint position = 0;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_WIDGET (widget));
  g_assert (GTK_IS_STACK (stack));

  gtk_container_child_get (GTK_CONTAINER (stack), widget,
                           "position", &position,
                           NULL);

  target = g_variant_new_int32 (position);

  tab = g_object_new (PNL_TYPE_TAB,
                      "action-name", "tab-strip.tab",
                      "action-target", target,
                      "edge", priv->edge,
                      "widget", widget,
                      NULL);

  g_object_set_data (G_OBJECT (widget), "PNL_TAB", tab);

  g_signal_connect_object (widget,
                           "child-notify::position",
                           G_CALLBACK (pnl_tab_strip_child_position_changed),
                           self,
                           G_CONNECT_SWAPPED);

  g_signal_connect_object (widget,
                           "child-notify::title",
                           G_CALLBACK (pnl_tab_strip_child_title_changed),
                           self,
                           G_CONNECT_SWAPPED);

  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (tab));

  g_object_bind_property (widget, "visible", tab, "visible", G_BINDING_SYNC_CREATE);

  pnl_tab_strip_child_title_changed (self, NULL, widget);
  pnl_tab_strip_stack_notify_visible_child (self, NULL, stack);
}
Пример #8
0
static void
pnl_tab_strip_stack_remove (PnlTabStrip *self,
                            GtkWidget   *widget,
                            GtkStack    *stack)
{
  PnlTab *tab;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_WIDGET (widget));
  g_assert (GTK_IS_STACK (stack));

  tab = g_object_get_data (G_OBJECT (widget), "PNL_TAB");

  if (PNL_IS_TAB (tab))
    gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (tab));
}
Пример #9
0
static void
pnl_tab_strip_stack_notify_visible_child (PnlTabStrip *self,
                                          GParamSpec  *pspec,
                                          GtkStack    *stack)
{
  GtkWidget *visible;

  g_assert (PNL_IS_TAB_STRIP (self));
  g_assert (GTK_IS_STACK (stack));

  visible = gtk_stack_get_visible_child (stack);

  if (visible != NULL)
    {
      PnlTab *tab = g_object_get_data (G_OBJECT (visible), "PNL_TAB");

      if (PNL_IS_TAB (tab))
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tab), TRUE);
    }
}
Пример #10
0
static void
ide_workbench_show_parents (GtkWidget *widget)
{
  GtkWidget *parent;

  g_assert (GTK_IS_WIDGET (widget));

  parent = gtk_widget_get_parent (widget);

  if (IDE_IS_LAYOUT_PANE (widget))
    pnl_dock_revealer_set_reveal_child (PNL_DOCK_REVEALER (widget), TRUE);

  if (IDE_IS_PERSPECTIVE (widget))
    ide_workbench_set_visible_perspective (ide_widget_get_workbench (widget),
                                           IDE_PERSPECTIVE (widget));

  if (GTK_IS_STACK (parent))
    gtk_stack_set_visible_child (GTK_STACK (parent), widget);

  if (parent != NULL)
    ide_workbench_show_parents (parent);
}
Пример #11
0
static void
gbp_terminal_page_set_needs_attention (IdeTerminalPage *self,
                                       gboolean         needs_attention)
{
  GtkWidget *parent;

  g_assert (IDE_IS_TERMINAL_PAGE (self));

  parent = gtk_widget_get_parent (GTK_WIDGET (self));

  if (GTK_IS_STACK (parent) &&
      !gtk_widget_in_destruction (GTK_WIDGET (self)) &&
      !gtk_widget_in_destruction (parent))
    {
      if (!gtk_widget_in_destruction (GTK_WIDGET (self->terminal_top)))
        self->needs_attention = !!needs_attention;

      gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
                               "needs-attention", needs_attention,
                               NULL);
    }
}
static void
debug_manager_notify_debugger (IdeDebuggerEditorAddin *self,
                               GParamSpec             *pspec,
                               IdeDebugManager        *debug_manager)
{
  IdeDebugger *debugger;
  IdeWorkspace *workspace;

  g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self));
  g_assert (IDE_IS_DEBUG_MANAGER (debug_manager));

  if (!gtk_widget_get_visible (GTK_WIDGET (self->panel)))
    {
      GtkWidget *stack = gtk_widget_get_parent (GTK_WIDGET (self->panel));

      gtk_widget_show (GTK_WIDGET (self->panel));

      if (GTK_IS_STACK (stack))
        gtk_stack_set_visible_child (GTK_STACK (stack), GTK_WIDGET (self->panel));
    }

  debugger = ide_debug_manager_get_debugger (debug_manager);

  if ((workspace = ide_widget_get_workspace (GTK_WIDGET (self->editor))))
    gtk_widget_insert_action_group (GTK_WIDGET (workspace),
                                    "debugger",
                                    G_ACTION_GROUP (debugger));

  ide_debugger_breakpoints_view_set_debugger (self->breakpoints_view, debugger);
  ide_debugger_locals_view_set_debugger (self->locals_view, debugger);
  ide_debugger_libraries_view_set_debugger (self->libraries_view, debugger);
  ide_debugger_registers_view_set_debugger (self->registers_view, debugger);
  ide_debugger_threads_view_set_debugger (self->threads_view, debugger);

  dzl_signal_group_set_target (self->debugger_signals, debugger);
}