Ejemplo n.º 1
0
void
_gtk_text_handle_set_position (GtkTextHandle         *handle,
                               GtkTextHandlePosition  pos,
                               GdkRectangle          *rect)
{
  GtkTextHandlePrivate *priv;
  HandleWindow *handle_window;

  g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));

  priv = handle->priv;
  pos = CLAMP (pos, GTK_TEXT_HANDLE_POSITION_CURSOR,
               GTK_TEXT_HANDLE_POSITION_SELECTION_START);
  handle_window = &priv->windows[pos];

  if (priv->mode == GTK_TEXT_HANDLE_MODE_NONE ||
      (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR &&
       pos != GTK_TEXT_HANDLE_POSITION_CURSOR))
    return;

  handle_window->pointing_to = *rect;
  handle_window->has_point = TRUE;

  if (gtk_widget_is_visible (priv->parent))
    _gtk_text_handle_update (handle, pos);
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: macrat/rusk
void inSiteSearchPrev(RuskWindow *rusk)
{
	if(gtk_widget_is_visible(GTK_WIDGET(rusk->insiteSearch)))
	{
		webkit_find_controller_search_previous(webkit_web_view_get_find_controller(rusk->webview));
	}
}
Ejemplo n.º 3
0
static gboolean
window_key_press_event (GtkWidget *win, GdkEventKey *event, GsShell *shell)
{
	GsShellPrivate *priv = gs_shell_get_instance_private (shell);
	GdkKeymap *keymap;
	GdkModifierType state;
	gboolean is_rtl;
	GtkWidget *button;

	button = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
	if (!gtk_widget_is_visible (button) || !gtk_widget_is_sensitive (button))
	    	return GDK_EVENT_PROPAGATE;

	state = event->state;
	keymap = gdk_keymap_get_default ();
	gdk_keymap_add_virtual_modifiers (keymap, &state);
	state = state & gtk_accelerator_get_default_mod_mask ();
	is_rtl = gtk_widget_get_direction (button) == GTK_TEXT_DIR_RTL;

	if ((!is_rtl && state == GDK_MOD1_MASK && event->keyval == GDK_KEY_Left) ||
	    (is_rtl && state == GDK_MOD1_MASK && event->keyval == GDK_KEY_Right) ||
	    event->keyval == GDK_KEY_Back) {
		gtk_widget_activate (button);
		return GDK_EVENT_STOP;
	}

	return GDK_EVENT_PROPAGATE;
}
Ejemplo n.º 4
0
static gboolean
nimf_candidate_is_visible (NimfCandidatable *candidatable)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  return gtk_widget_is_visible (NIMF_CANDIDATE (candidatable)->window);
}
static void
show_input_sources_for_locale (GtkWidget   *chooser,
                               LocaleInfo  *info)
{
  CcInputChooserPrivate *priv = GET_PRIVATE (chooser);

  set_fixed_size (chooser);

  remove_all_children (GTK_CONTAINER (priv->list));

  if (!info->back_row)
    {
      info->back_row = g_object_ref_sink (back_row_new (info->name));
      g_object_set_data (G_OBJECT (info->back_row), "back", GINT_TO_POINTER (TRUE));
      g_object_set_data (G_OBJECT (info->back_row), "locale-info", info);
    }
  gtk_container_add (GTK_CONTAINER (priv->list), GTK_WIDGET (info->back_row));

  add_input_source_rows_for_locale (chooser, info);

  gtk_widget_show_all (priv->list);

  gtk_adjustment_set_value (priv->adjustment,
                            gtk_adjustment_get_lower (priv->adjustment));
  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->list), cc_list_box_update_header_func, NULL, NULL);
  gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->list));
  gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->list), GTK_SELECTION_SINGLE);
  gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (priv->list), FALSE);
  gtk_list_box_unselect_all (GTK_LIST_BOX (priv->list));

  if (gtk_widget_is_visible (priv->filter_entry) &&
      !gtk_widget_is_focus (priv->filter_entry))
    gtk_widget_grab_focus (priv->filter_entry);
}
Ejemplo n.º 6
0
static void
add_widget_to_closure (GHashTable     *widgets,
                       GHashTable     *groups,
                       GtkWidget      *widget,
		       GtkOrientation  orientation)
{
  GSList *tmp_groups, *tmp_widgets;
  gboolean hidden;

  if (g_hash_table_lookup (widgets, widget))
    return;

  g_hash_table_add (widgets, widget);
  hidden = !gtk_widget_is_visible (widget);

  for (tmp_groups = _gtk_widget_get_sizegroups (widget); tmp_groups; tmp_groups = tmp_groups->next)
    {
      GtkSizeGroup        *tmp_group = tmp_groups->data;
      GtkSizeGroupPrivate *tmp_priv  = tmp_group->priv;

      if (g_hash_table_lookup (groups, tmp_group))
        continue;

      if (tmp_priv->ignore_hidden && hidden)
        continue;

      if (!(tmp_priv->mode & (1 << orientation)))
        continue;

      g_hash_table_add (groups, tmp_group);

      for (tmp_widgets = tmp_priv->widgets; tmp_widgets; tmp_widgets = tmp_widgets->next)
        add_widget_to_closure (widgets, groups, tmp_widgets->data, orientation);
    }
}
static void
show_filter_widgets (GtkWidget *chooser)
{
  CcInputChooserPrivate *priv = GET_PRIVATE (chooser);
  LocaleInfo *info;
  GHashTableIter iter;

  remove_all_children (GTK_CONTAINER (priv->list));

  g_hash_table_iter_init (&iter, priv->locales);
  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &info))
    add_input_source_widgets_for_locale (chooser, info);

  gtk_widget_show_all (priv->list);

  gtk_adjustment_set_value (priv->adjustment,
                            gtk_adjustment_get_lower (priv->adjustment));
  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->list),
                                update_header_func_filter, NULL, NULL);
  gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->list), GTK_SELECTION_SINGLE);
  gtk_list_box_set_placeholder (GTK_LIST_BOX (priv->list), priv->no_results);

  if (gtk_widget_is_visible (priv->filter_entry))
    gtk_widget_grab_focus (priv->filter_entry);
}
Ejemplo n.º 8
0
static void
update_label_visibility (GstyleColorWidget *self)
{
  const gchar *color_name;
  g_autofree gchar *fallback_name = NULL;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));

  if (self->color == NULL)
    {
      if (gtk_widget_is_visible (GTK_WIDGET (self->label)))
        gtk_widget_hide (GTK_WIDGET (self->label));

      return;
    }

  if (self->is_name_visible)
    {
      if (self->filter_func != NULL && GSTYLE_IS_COLOR (self->filtered_color))
        color_name = gstyle_color_get_name (self->filtered_color);
      else
        color_name = gstyle_color_get_name (self->color);

      if (color_name != NULL)
        {
          gtk_label_set_text (self->label, color_name);
          if (!gtk_widget_is_visible (GTK_WIDGET (self->label)))
            gtk_widget_show (GTK_WIDGET (self->label));

          return;
        }
    }

  if (self->is_fallback_name_visible)
    {
      if (self->filter_func != NULL && GSTYLE_IS_COLOR (self->filtered_color))
        fallback_name = gstyle_color_to_string (self->filtered_color, self->fallback_name_kind);
      else
        fallback_name = gstyle_color_to_string (self->color, self->fallback_name_kind);

      gtk_label_set_text (self->label, fallback_name);
      if (!gtk_widget_is_visible (GTK_WIDGET (self->label)))
        gtk_widget_show (GTK_WIDGET (self->label));
    }
  else
    gtk_widget_hide (GTK_WIDGET (self->label));
}
Ejemplo n.º 9
0
static void
GyahtzeeActivateGame (GApplication *app, gpointer user_data)
{
  if (!gtk_widget_is_visible (window)) {
    gtk_widget_show (window);
    GyahtzeeNewGame ();
  }
}
static void
hd_status_area_box_size_allocate (GtkWidget     *widget,
                                  GtkAllocation *allocation)
{
  HDStatusAreaBoxPrivate *priv;
  guint border_width;
  GtkAllocation child_allocation = {0, 0, 0, 0};
  guint visible_children = 0;
  GList *c;

  priv = HD_STATUS_AREA_BOX (widget)->priv;

  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

  /* chain up */
  GTK_WIDGET_CLASS (hd_status_area_box_parent_class)->size_allocate (widget,
                                                                     allocation);

  child_allocation.height = ITEM_HEIGHT;

  /* Place the first eight visible children */
  for (c = priv->children; c && visible_children < priv->max_visible_children; c = c->next)
    {
      HDStatusAreaBoxChild *info = c->data;
      GtkRequisition child_requisition;

      /* ignore hidden widgets */
      if (!gtk_widget_is_visible (info->widget))
        continue;

      /* there are some widgets which need a size request */
      gtk_widget_get_preferred_size (info->widget, &child_requisition, NULL);

      child_allocation.x = allocation->x +
                           border_width +
                           PADDING_LEFT +
                           (visible_children / 2) * (ITEM_WIDTH + SPACING);
      child_allocation.y = allocation->y +
                           border_width +
                           (visible_children % 2 * (ITEM_HEIGHT + SPACING));

      child_allocation.width = ITEM_WIDTH;
      child_allocation.height = ITEM_HEIGHT;

      gtk_widget_size_allocate (info->widget, &child_allocation);
      gtk_widget_set_child_visible (info->widget, TRUE);

      visible_children++;
    }

  /* Hide the other children */
  for (; c; c = c->next)
    {
      HDStatusAreaBoxChild *info = c->data;

      gtk_widget_set_child_visible (info->widget, FALSE);
    }
}
Ejemplo n.º 11
0
static void
call_prepare_print (GtkPrintOperation *op,
                    PortalData        *portal)
{
  GtkPrintOperationPrivate *priv = op->priv;
  GVariant *settings;
  GVariant *setup;
  GVariantBuilder opt_builder;
  GVariant *options;
  char *parent_window_str = NULL;

  g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
  options = g_variant_builder_end (&opt_builder);

  if (priv->print_settings)
    settings = gtk_print_settings_to_gvariant (priv->print_settings);
  else
    {
      GVariantBuilder builder;
      g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
      settings = g_variant_builder_end (&builder);
    }

  if (priv->default_page_setup)
    setup = gtk_page_setup_to_gvariant (priv->default_page_setup);
  else
    {
      GtkPageSetup *page_setup = gtk_page_setup_new ();
      setup = gtk_page_setup_to_gvariant (page_setup);
      g_object_unref (page_setup);
    }

  if (portal->parent != NULL && gtk_widget_is_visible (GTK_WIDGET (portal->parent)))
    {
      GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (portal->parent));
#ifdef GDK_WINDOWING_X11
      if (GDK_IS_X11_WINDOW (window))
        parent_window_str = g_strdup_printf ("x11:%x", (guint32)gdk_x11_window_get_xid (window));
#endif
    }

  g_dbus_proxy_call (portal->proxy,
                     "PreparePrint",
                     g_variant_new ("(ss@a{sv}@a{sv}@a{sv})",
                                    parent_window_str ? parent_window_str : "",
                                    _("Print"), /* title */
                                    settings,
                                    setup,
                                    options),
                     G_DBUS_CALL_FLAGS_NONE,
                     -1,
                     NULL,
                     prepare_print_called,
                     portal);

  g_free (parent_window_str);
}
Ejemplo n.º 12
0
static void
set_visible_child (GdStack *stack,
		   GdStackChildInfo *child_info)
{
  GdStackPrivate *priv = stack->priv;
  GdStackChildInfo *info;
  GtkWidget *widget = GTK_WIDGET (stack);
  GList *l;

  /* If none, pick first visible */
  if (child_info == NULL)
    {
      for (l = priv->children; l != NULL; l = l->next)
	{
          info = l->data;
	  if (gtk_widget_get_visible (info->widget))
	    {
	      child_info = info;
	      break;
	    }
	}
    }

  if (child_info == priv->visible_child)
    return;

  if (priv->last_visible_child)
    gtk_widget_set_child_visible (priv->last_visible_child->widget, FALSE);
  priv->last_visible_child = NULL;

  if (priv->last_visible_surface != NULL)
    cairo_surface_destroy (priv->last_visible_surface);
  priv->last_visible_surface = NULL;

  if (priv->visible_child && priv->visible_child->widget)
    {
      if (gtk_widget_is_visible (widget))
        priv->last_visible_child = priv->visible_child;
      else
        gtk_widget_set_child_visible (priv->visible_child->widget, FALSE);
    }

  priv->visible_child = child_info;

  if (child_info)
    gtk_widget_set_child_visible (child_info->widget, TRUE);

  gtk_widget_queue_resize (GTK_WIDGET (stack));
  gtk_widget_queue_draw (GTK_WIDGET (stack));

  g_object_notify (G_OBJECT (stack), "visible-child");
  g_object_notify (G_OBJECT (stack), "visible-child-name");

  gd_stack_start_transition (stack);
}
Ejemplo n.º 13
0
static void
on_allocation_changed (ClutterActor          *actor,
                       ClutterActorBox       *box,
                       ClutterAllocationFlags flags,
                       CalibArea             *area)
{
  if (!gtk_widget_is_visible (area->window))
    return;

  resize_display (area);
}
Ejemplo n.º 14
0
static gboolean on_ref_mapped(GtkWidget *widget, GdkEvent  *event,
               gpointer   user_data)
{
    g_debug("%s", __func__);
    if (!back_pixmap) {
        g_assert(gtk_widget_is_visible(ref));
        GdkWindow* gdkwin = gtk_widget_get_window(ref);
        back_pixmap = XCompositeNameWindowPixmap(display, GDK_WINDOW_XID(gdkwin));
        glx_pm = glXCreatePixmap(display, bestFbc, back_pixmap, pixmap_attribs);
    }
    return FALSE;
}
static void
hd_status_area_box_size_request (GtkWidget      *widget,
                                 GtkRequisition *requisition)
{
  HDStatusAreaBoxPrivate *priv;
  guint border_width;
  GList *c;
  guint visible_children = 0;

  priv = HD_STATUS_AREA_BOX (widget)->priv;

  if (is_portrait_mode (widget))
    priv->max_visible_children = MAX_VISIBLE_CHILDREN_PORTRAIT;
  else
    priv->max_visible_children = MAX_VISIBLE_CHILDREN_LANDSCAPE;

  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

  /* calculate number of visible children */
  for (c = priv->children; c; c = c->next)
    {
      HDStatusAreaBoxChild *info = c->data;
      GtkRequisition child_requisition;

      if (!gtk_widget_is_visible (info->widget))
        continue;

      /* there are some widgets which need a size request */
      gtk_widget_get_preferred_size (info->widget, &child_requisition, NULL);

      visible_children++;
    }

  visible_children = MIN (priv->max_visible_children, visible_children);

  if (visible_children == 0)
    {
      requisition->width = 0;
      requisition->height = 0;
    }
  else
    {
      /* width is maximum width of both rows */
      requisition->width =  2 * border_width +
                            PADDING_LEFT +
                            ((visible_children + 1) / 2) * ITEM_WIDTH +
                            (visible_children - 1 / 2) * SPACING;
      /* height is two rows */
      requisition->height = 2 * border_width +
                            2 * ITEM_HEIGHT +
                            SPACING;
    }
}
static void
show_locale_rows (GtkWidget *chooser)
{
  CcInputChooserPrivate *priv = GET_PRIVATE (chooser);
  GHashTable *initial = NULL;
  LocaleInfo *info;
  GHashTableIter iter;

  remove_all_children (GTK_CONTAINER (priv->list));

  if (!priv->showing_extra)
    initial = cc_common_language_get_initial_languages ();

  g_hash_table_iter_init (&iter, priv->locales);
  while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &info))
    {
      if (!info->default_input_source_row &&
          !g_hash_table_size (info->layout_rows_by_id) &&
          !g_hash_table_size (info->engine_rows_by_id))
        continue;

      if (!info->locale_row)
        {
          info->locale_row = g_object_ref_sink (locale_row_new (info->name));
          g_object_set_data (G_OBJECT (info->locale_row), "locale-info", info);

          if (!priv->showing_extra &&
              !g_hash_table_contains (initial, info->id) &&
              !is_current_locale (info->id))
            g_object_set_data (G_OBJECT (info->locale_row), "is-extra", GINT_TO_POINTER (TRUE));
        }
      gtk_container_add (GTK_CONTAINER (priv->list), GTK_WIDGET (info->locale_row));
    }

  gtk_container_add (GTK_CONTAINER (priv->list), GTK_WIDGET (priv->more_row));

  gtk_widget_show_all (priv->list);

  gtk_adjustment_set_value (priv->adjustment,
                            gtk_adjustment_get_lower (priv->adjustment));
  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->list), cc_list_box_update_header_func, NULL, NULL);
  gtk_list_box_invalidate_filter (GTK_LIST_BOX (priv->list));
  gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->list), GTK_SELECTION_NONE);
  gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (priv->list), TRUE);

  if (gtk_widget_is_visible (priv->filter_entry) &&
      !gtk_widget_is_focus (priv->filter_entry))
    gtk_widget_grab_focus (priv->filter_entry);

  if (!priv->showing_extra)
    g_hash_table_destroy (initial);
}
static void union_with_clip (GtkWidget *widget,
                 gpointer   clip)
{
    GtkAllocation widget_clip;

    if (!gtk_widget_is_visible (widget) ||
            !gtk_widget_get_child_visible (widget))
        return;

    gtk_widget_get_clip (widget, &widget_clip);

    gdk_rectangle_union (&widget_clip, clip, clip);
}
Ejemplo n.º 18
0
Archivo: main.c Proyecto: macrat/rusk
void addressbarToggle(RuskWindow *rusk)
{
	if(!gtk_widget_is_visible(GTK_WIDGET(rusk->addressbar)))
	{
		gtk_entry_set_text(rusk->addressbar, webkit_web_view_get_uri(rusk->webview));
		gtk_widget_set_visible(GTK_WIDGET(rusk->addressbar), TRUE);
		gtk_window_set_focus(rusk->window, GTK_WIDGET(rusk->addressbar));
	}else
	{
		gtk_widget_set_visible(GTK_WIDGET(rusk->addressbar), FALSE);
		gtk_window_set_focus(rusk->window, GTK_WIDGET(rusk->webview));
	}
}
void
hd_status_area_box_reorder_child (HDStatusAreaBox *box,
                                  GtkWidget       *child,
                                  guint            position)
{
  HDStatusAreaBoxPrivate *priv;
  GList *c;

  g_return_if_fail (HD_IS_STATUS_AREA_BOX (box));
  g_return_if_fail (GTK_IS_WIDGET (child));
  g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (box));

  priv = box->priv;

  for (c = priv->children; c; c = c->next)
    {
      HDStatusAreaBoxChild *info = c->data;

      if (info->widget == child)
        {
          if (info->priority != position)
            {
              info->priority = position;

              /* Reorder children list */
              priv->children = g_list_delete_link (priv->children, c);
              priv->children = g_list_insert_sorted (priv->children,
                                                     info,
                                                     hd_status_area_box_cmp_priority);
              
              if (gtk_widget_is_visible (child) && gtk_widget_is_visible (GTK_WIDGET(box)))
                gtk_widget_queue_resize (child);
            }

          break;
        }
    }
}
Ejemplo n.º 20
0
static gboolean
window_button_press_event (GtkWidget *win, GdkEventButton *event, GsShell *shell)
{
	GsShellPrivate *priv = gs_shell_get_instance_private (shell);
	GtkWidget *button;

	/* Mouse hardware back button is 8 */
	if (event->button != 8)
		return GDK_EVENT_PROPAGATE;

	button = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_back"));
	if (!gtk_widget_is_visible (button) || !gtk_widget_is_sensitive (button))
		return GDK_EVENT_PROPAGATE;

	gtk_widget_activate (button);
	return GDK_EVENT_STOP;
}
Ejemplo n.º 21
0
Archivo: popover.c Proyecto: GNOME/gtk
static void
entry_size_allocate_cb (GtkEntry      *entry,
                        GtkAllocation *allocation,
                        gpointer       user_data)
{
    GtkEntryIconPosition popover_pos;
    GtkPopover *popover = user_data;
    cairo_rectangle_int_t rect;

    if (gtk_widget_is_visible (GTK_WIDGET (popover)))
    {
        popover_pos =
            GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry),
                              "popover-icon-pos"));
        gtk_entry_get_icon_area (entry, popover_pos, &rect);
        gtk_popover_set_pointing_to (GTK_POPOVER (popover), &rect);
    }
}
Ejemplo n.º 22
0
Archivo: main.c Proyecto: macrat/rusk
void inSiteSearchToggle(RuskWindow *rusk)
{
	if(!gtk_widget_is_visible(GTK_WIDGET(rusk->insiteSearch)))
	{
		gtk_widget_set_visible(GTK_WIDGET(rusk->insiteSearch), TRUE);
		gtk_window_set_focus(rusk->window, GTK_WIDGET(rusk->insiteSearch));

		WebKitFindController *finder = webkit_web_view_get_find_controller(rusk->webview);
		runInSiteSearch(rusk, webkit_find_controller_get_search_text(finder), TRUE);

		webkit_find_controller_search_previous(finder);
	}else
	{
		webkit_find_controller_search_finish(webkit_web_view_get_find_controller(rusk->webview));
		gtk_widget_set_visible(GTK_WIDGET(rusk->insiteSearch), FALSE);
		gtk_window_set_focus(rusk->window, GTK_WIDGET(rusk->webview));
	}
}
Ejemplo n.º 23
0
void
_gtk_text_handle_set_visible (GtkTextHandle         *handle,
                              GtkTextHandlePosition  pos,
                              gboolean               visible)
{
  GtkTextHandlePrivate *priv;

  g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));

  priv = handle->priv;
  pos = CLAMP (pos, GTK_TEXT_HANDLE_POSITION_CURSOR,
               GTK_TEXT_HANDLE_POSITION_SELECTION_START);

  priv->windows[pos].user_visible = visible;

  if (gtk_widget_is_visible (priv->parent))
    _gtk_text_handle_update (handle, pos);
}
Ejemplo n.º 24
0
static void
gstyle_slidein_unmap (GtkWidget *widget)
{
  GstyleSlidein *self = (GstyleSlidein *)widget;

  g_assert (GSTYLE_IS_SLIDEIN (self));

  if (self->overlay_child != NULL &&
      self->overlay_window != NULL &&
      gtk_widget_is_visible (self->overlay_child))
    {
      gdk_window_hide (self->overlay_window );
      g_signal_handlers_disconnect_by_func (self->overlay_child,
                                            event_window_button_press_event_cb,
                                            self);
    }

  GTK_WIDGET_CLASS (gstyle_slidein_parent_class)->unmap (widget);
}
static void
hd_status_area_box_remove (GtkContainer *container,
                           GtkWidget    *child)
{
  HDStatusAreaBoxPrivate *priv;
  GList *c;

  g_return_if_fail (HD_IS_STATUS_AREA_BOX (container));
  g_return_if_fail (GTK_IS_WIDGET (child));
  g_return_if_fail (gtk_widget_get_parent (child) == (GtkWidget *)container);

  priv = HD_STATUS_AREA_BOX (container)->priv;

  /* search for child in children and remove it */
  for (c = priv->children; c; c = c->next)
    {
      HDStatusAreaBoxChild *info = c->data;

      if (info->widget == child)
        {
          gboolean visible;

          visible = gtk_widget_is_visible (child);

          gtk_widget_unparent (child);

          priv->children = g_list_delete_link (priv->children, c);
          g_slice_free (HDStatusAreaBoxChild, info);

          /* resize container if child was visible */
          if (visible)
            gtk_widget_queue_resize (GTK_WIDGET (container));

          break;
        }
    }
}
Ejemplo n.º 26
0
static gboolean
gnucash_register_enter_scrollbar (GtkWidget *widget,
                                  GdkEvent *event, gpointer user_data)
{
    GnucashRegister *reg = user_data;
    GnucashSheet *sheet = GNUCASH_SHEET(reg->sheet);
    GtkWidget *vscrollbar = sheet->vscrollbar;
    GtkWidget *hscrollbar = sheet->hscrollbar;

    // There seems to be a problem with the scrollbar slider not being
    // updated as the mouse moves possibly related to the following bug
    // https://bugzilla.gnome.org/show_bug.cgi?id=765410
    // If they are hidden and shown it seems to fix it.

    gtk_widget_hide (GTK_WIDGET(vscrollbar));
    gtk_widget_show (GTK_WIDGET(vscrollbar));

    if (gtk_widget_is_visible (hscrollbar))
    {
        gtk_widget_hide (GTK_WIDGET(hscrollbar));
        gtk_widget_show (GTK_WIDGET(hscrollbar));
    }
    return FALSE;
}
Ejemplo n.º 27
0
gboolean
gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
{
  FilechooserPortalData *data;
  GtkWindow *transient_for;
  GDBusConnection *connection;
  char *parent_window_str;
  GDBusMessage *message;
  GVariantBuilder opt_builder;
  GtkFileChooserAction action;
  gboolean multiple;
  const char *method_name;

  if (!gtk_should_use_portal ())
    return FALSE;

  connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
  if (connection == NULL)
    return FALSE;

  action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (self));
  multiple = gtk_file_chooser_get_select_multiple (GTK_FILE_CHOOSER (self));

  if (action == GTK_FILE_CHOOSER_ACTION_OPEN)
    method_name = "OpenFile";
  else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
    method_name = "SaveFile";
  else
    {
      g_warning ("GTK_FILE_CHOOSER_ACTION_%s is not supported by GtkFileChooserNativePortal", action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ? "SELECT_FOLDER" : "CREATE_FOLDER");
      return FALSE;
    }

  data = g_new0 (FilechooserPortalData, 1);
  data->self = g_object_ref (self);
  data->connection = connection;

  message = g_dbus_message_new_method_call ("org.freedesktop.portal.Desktop",
                                            "/org/freedesktop/portal/desktop",
                                            "org.freedesktop.portal.FileChooser",
                                            method_name);

  parent_window_str = NULL;
  transient_for = gtk_native_dialog_get_transient_for (GTK_NATIVE_DIALOG (self));
  if (transient_for != NULL && gtk_widget_is_visible (GTK_WIDGET (transient_for)))
    {
      GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (transient_for));
#ifdef GDK_WINDOWING_X11
      if (GDK_IS_X11_WINDOW(window))
        parent_window_str = g_strdup_printf ("x11:%x", (guint32)gdk_x11_window_get_xid (window));
#endif
    }

  if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
    data->modal = TRUE;

  if (data->modal && transient_for != NULL)
    {
      data->grab_widget = gtk_invisible_new_for_screen (gtk_widget_get_screen (GTK_WIDGET (transient_for)));
      gtk_grab_add (GTK_WIDGET (data->grab_widget));
    }

  g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
  g_variant_builder_add (&opt_builder, "{sv}", "multiple",
                         g_variant_new_boolean (multiple));
  if (self->accept_label)
    g_variant_builder_add (&opt_builder, "{sv}", "accept_label",
                           g_variant_new_string (self->accept_label));
  if (self->cancel_label)
    g_variant_builder_add (&opt_builder, "{sv}", "cancel_label",
                           g_variant_new_string (self->cancel_label));
  g_variant_builder_add (&opt_builder, "{sv}", "modal",
                         g_variant_new_boolean (data->modal));
  g_variant_builder_add (&opt_builder, "{sv}", "filters", get_filters (GTK_FILE_CHOOSER (self)));
  if (GTK_FILE_CHOOSER_NATIVE (self)->current_name)
    g_variant_builder_add (&opt_builder, "{sv}", "current_name",
                           g_variant_new_string (GTK_FILE_CHOOSER_NATIVE (self)->current_name));
  if (GTK_FILE_CHOOSER_NATIVE (self)->current_folder)
    {
      gchar *path;

      path = g_file_get_path (GTK_FILE_CHOOSER_NATIVE (self)->current_folder);
      g_variant_builder_add (&opt_builder, "{sv}", "current_folder",
                             g_variant_new_bytestring (path));
      g_free (path);
    }
  if (GTK_FILE_CHOOSER_NATIVE (self)->current_file)
    {
      gchar *path;

      path = g_file_get_path (GTK_FILE_CHOOSER_NATIVE (self)->current_file);
      g_variant_builder_add (&opt_builder, "{sv}", "current_file",
                             g_variant_new_bytestring (path));
      g_free (path);
    }

  if (GTK_FILE_CHOOSER_NATIVE (self)->choices)
    g_variant_builder_add (&opt_builder, "{sv}", "choices",
                           serialize_choices (GTK_FILE_CHOOSER_NATIVE (self)));

  g_dbus_message_set_body (message,
                           g_variant_new ("(ss@a{sv})",
                                          parent_window_str ? parent_window_str : "",
                                          gtk_native_dialog_get_title (GTK_NATIVE_DIALOG (self)),
                                          g_variant_builder_end (&opt_builder)));
  g_free (parent_window_str);

  g_dbus_connection_send_message_with_reply (data->connection,
                                             message,
                                             G_DBUS_SEND_MESSAGE_FLAGS_NONE,
                                             G_MAXINT,
                                             NULL,
                                             NULL,
                                             open_file_msg_cb,
                                             data);

  g_object_unref (message);

  self->mode_data = data;
  return TRUE;
}