static void
gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
{
    GtkWidget *image;

    GTK_WIDGET_SET_FLAGS (grip, GTK_NO_WINDOW);
    
    grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
    grip->_priv->icon_pixbuf_valid = FALSE;
    grip->_priv->icon_pixbuf = NULL;
    grip->_priv->title_layout = NULL;

    gtk_widget_push_composite_child ();
    grip->_priv->close_button = gtk_button_new ();
    gtk_widget_pop_composite_child ();
    
    GTK_WIDGET_UNSET_FLAGS (grip->_priv->close_button, GTK_CAN_FOCUS);
    gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip));
    gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
    gtk_widget_show (grip->_priv->close_button);

    image = gtk_image_new_from_stock (GDL_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image);
    gtk_widget_show (image);

    g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked",
                      G_CALLBACK (gdl_dock_item_grip_close_clicked), grip);

    gtk_widget_push_composite_child ();
    grip->_priv->iconify_button = gtk_button_new ();
    gtk_widget_pop_composite_child ();
    
    GTK_WIDGET_UNSET_FLAGS (grip->_priv->iconify_button, GTK_CAN_FOCUS);
    gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip));
    gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
    gtk_widget_show (grip->_priv->iconify_button);

    image = gtk_image_new_from_stock (GDL_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image);
    gtk_widget_show (image);

    g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked",
                      G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip);

    grip->_priv->tooltips = gtk_tooltips_new ();
    g_object_ref (grip->_priv->tooltips);
    gtk_object_sink (GTK_OBJECT (grip->_priv->tooltips));
    gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->iconify_button,
                          _("Iconify"), _("Iconify this dock"));
    gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->close_button,
                          _("Close"), _("Close this dock"));
}
Exemplo n.º 2
0
static GObject *
hildon_home_window_constructor (GType                  gtype,
                                guint                  n_params,
                                GObjectConstructParam *params)
{
  GObject *retval;
  HildonHomeWindow *window;
  HildonHomeWindowPrivate *priv;
  GtkWidget *widget;

  retval =
      G_OBJECT_CLASS (hildon_home_window_parent_class)->constructor (gtype,
                                                                     n_params,
                                                                     params);
  widget = GTK_WIDGET (retval);
  window = HILDON_HOME_WINDOW (retval);
  priv = window->priv;

  gtk_widget_push_composite_child ();

  priv->titlebar = hildon_home_titlebar_new ();
  g_object_ref (priv->titlebar);
  gtk_object_sink (GTK_OBJECT (priv->titlebar));
  gtk_widget_set_parent (priv->titlebar, widget);
  gtk_widget_show (priv->titlebar);

  gtk_widget_pop_composite_child ();

  return retval;
}
Exemplo n.º 3
0
static GObject *
gimp_message_box_constructor (GType                  type,
                              guint                  n_params,
                              GObjectConstructParam *params)
{
  GObject        *object;
  GimpMessageBox *box;

  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);

  box = GIMP_MESSAGE_BOX (object);

  if (box->stock_id)
    {
      gtk_widget_push_composite_child ();
      box->image = gtk_image_new_from_stock (box->stock_id,
                                             GTK_ICON_SIZE_DIALOG);
      gtk_widget_pop_composite_child ();

      gtk_misc_set_alignment (GTK_MISC (box->image), 0.0, 0.0);
      gtk_widget_set_parent (box->image, GTK_WIDGET (box));
      gtk_widget_show (box->image);
    }

  return object;
}
Exemplo n.º 4
0
static GtkWidget *
gnm_font_button_create_inside (GnmFontButton *font_button)
{
  GtkWidget *widget;

  gtk_widget_push_composite_child ();

  widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  font_button->priv->font_label = gtk_label_new (_("Font"));

  gtk_label_set_justify (GTK_LABEL (font_button->priv->font_label), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start (GTK_BOX (widget), font_button->priv->font_label, TRUE, TRUE, 5);

  if (font_button->priv->show_size)
    {
      gtk_box_pack_start (GTK_BOX (widget), gtk_separator_new (GTK_ORIENTATION_VERTICAL), FALSE, FALSE, 0);
      font_button->priv->size_label = gtk_label_new ("14");
      gtk_box_pack_start (GTK_BOX (widget), font_button->priv->size_label, FALSE, FALSE, 5);
    }

  gtk_widget_show_all (widget);

  gtk_widget_pop_composite_child ();

  return widget;
}
Exemplo n.º 5
0
static void
hildon_home_window_set_property (GObject      *gobject,
                                 guint         prop_id,
                                 const GValue *value,
                                 GParamSpec   *pspec)
{
  HildonHomeWindowPrivate      *priv = HILDON_HOME_WINDOW_GET_PRIVATE (gobject);
  switch (prop_id)
    {
      case PROP_MENU:
          hildon_home_window_set_menu (HILDON_HOME_WINDOW (gobject),
                                       GTK_MENU (g_value_get_object (value)));
          break;
      case PROP_WORK_AREA:
          hildon_home_window_set_work_area (HILDON_HOME_WINDOW (gobject),
                                            (GdkRectangle *)
                                              g_value_get_pointer (value));
          break;
      case PROP_TITLE:
          g_object_set (priv->titlebar,
                        "title", g_value_get_string (value),
                        NULL);
          break;
      case PROP_TITLEBAR:
            {
              GtkWidget *titlebar = GTK_WIDGET (g_value_get_object (value));

              if (GTK_IS_WIDGET (titlebar))
                {
                  if (priv->titlebar)
                    g_object_unref (priv->titlebar);

                  priv->titlebar = titlebar;

                  gtk_widget_push_composite_child ();

                  g_object_ref (priv->titlebar);
                  gtk_object_sink (GTK_OBJECT (priv->titlebar));
                  gtk_widget_set_parent (priv->titlebar,
                                         GTK_WIDGET (gobject));
                  gtk_widget_show (priv->titlebar);

                  gtk_widget_pop_composite_child ();
                }
            }
          break;

      default:
          G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
          break;
    }
}
Exemplo n.º 6
0
static void
aw_window_add_tree_view (GtkContainer *container,
                         GtkWidget    *child)
{
    GtkWidget     *alignment, *pa;
    GSList        *filters, *items;
    HildonAppMenu *menu;

    gtk_widget_push_composite_child ();

    alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
    gtk_container_add (container, alignment);

    pa = hildon_pannable_area_new ();
    gtk_container_add (GTK_CONTAINER (alignment), pa);

    g_object_set (pa,
                  "hscrollbar-policy", GTK_POLICY_NEVER,
                  "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
                  "mov-mode", HILDON_MOVEMENT_MODE_VERT, NULL);

    g_signal_connect
    (hildon_pannable_area_get_vadjustment (HILDON_PANNABLE_AREA (pa)),
     "changed", G_CALLBACK (aw_window_vadjustment_changed_cb),
     alignment);

    gtk_widget_pop_composite_child ();

    gtk_container_add (GTK_CONTAINER (pa), child);

    filters = aw_tree_view_get_filters (AW_TREE_VIEW (child));
    items = aw_tree_view_get_menu_items (AW_TREE_VIEW (child));

    if (filters || items)
    {
        menu = HILDON_APP_MENU (hildon_app_menu_new ());

        while (filters)
        {
            hildon_app_menu_add_filter (menu, filters->data);
            filters = filters->next;
        }

        while (items)
        {
            hildon_app_menu_append (menu, items->data);
            items = items->next;
        }

        hildon_window_set_app_menu (HILDON_WINDOW (container), menu);
    }
}
Exemplo n.º 7
0
static void
gimp_message_box_constructed (GObject *object)
{
  GimpMessageBox *box = GIMP_MESSAGE_BOX (object);

  G_OBJECT_CLASS (parent_class)->constructed (object);

  if (box->stock_id)
    {
      gtk_widget_push_composite_child ();
      box->image = gtk_image_new_from_stock (box->stock_id,
                                             GTK_ICON_SIZE_DIALOG);
      gtk_widget_pop_composite_child ();

      gtk_misc_set_alignment (GTK_MISC (box->image), 0.0, 0.0);
      gtk_widget_set_parent (box->image, GTK_WIDGET (box));
      gtk_widget_show (box->image);
    }
}
Exemplo n.º 8
0
static void
gtk_notification_init (GtkNotification *notification)
{
  GtkWidget *close_button_image;
  GtkStyleContext *context;
  GtkNotificationPrivate *priv;

  context = gtk_widget_get_style_context (GTK_WIDGET (notification));
  gtk_style_context_add_class (context, "app-notification");


  gtk_widget_set_halign (GTK_WIDGET (notification), GTK_ALIGN_CENTER);
  gtk_widget_set_valign (GTK_WIDGET (notification), GTK_ALIGN_START);

  gtk_widget_set_has_window (GTK_WIDGET (notification), TRUE);

  gtk_widget_push_composite_child ();

  priv = notification->priv =
    G_TYPE_INSTANCE_GET_PRIVATE (notification,
                                 GTK_TYPE_NOTIFICATION,
                                 GtkNotificationPrivate);

  priv->animate_y = 0;
  priv->close_button = gtk_button_new ();
  gtk_widget_set_parent (priv->close_button, GTK_WIDGET (notification));
  gtk_widget_show (priv->close_button);
  g_object_set (priv->close_button,
                "relief", GTK_RELIEF_NONE,
                "focus-on-click", FALSE,
                NULL);
  g_signal_connect (priv->close_button,
                    "clicked",
                    G_CALLBACK (gtk_notification_close_button_clicked_cb),
                    notification);
  close_button_image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (notification->priv->close_button), close_button_image);

  gtk_widget_pop_composite_child ();

  priv->timeout_source_id = 0;
}
static void
hildon_color_button_init                        (HildonColorButton *cb)
{
    GtkWidget *align;
    GtkWidget *drawing_area;
    HildonColorButtonPrivate *priv = HILDON_COLOR_BUTTON_GET_PRIVATE (cb);

    priv->dialog = NULL;
    priv->gc = NULL;
    priv->popped = FALSE;

    gtk_widget_push_composite_child ();

    /* create widgets and pixbuf */
    align = gtk_alignment_new (0.5, 0.5, 0, 0); /* composite widget */

    drawing_area = gtk_drawing_area_new (); /* composite widget */

    /* setting minimum sizes */
    gtk_widget_set_size_request (GTK_WIDGET (cb), COLOR_BUTTON_WIDTH,
            COLOR_BUTTON_HEIGHT);

    gtk_widget_set_size_request (GTK_WIDGET(drawing_area),
                                 HILDON_ICON_PIXEL_SIZE_FINGER,
                                 HILDON_ICON_PIXEL_SIZE_FINGER);

    /* Connect the callback function for exposure event */
    g_signal_connect (drawing_area, "expose-event",
            G_CALLBACK (hildon_color_field_expose_event), cb);

    /* Connect to callback function for key press event */
    g_signal_connect (G_OBJECT(cb), "key-press-event",
            G_CALLBACK(hildon_color_button_key_pressed), cb);

    /* packing */
    gtk_container_add (GTK_CONTAINER (align), drawing_area);
    gtk_container_add (GTK_CONTAINER (cb), align);

    gtk_widget_show_all (align);

    gtk_widget_pop_composite_child ();
}
Exemplo n.º 10
0
static void
thunar_chooser_button_init (ThunarChooserButton *chooser_button)
{
  GtkWidget *separator;
  GtkWidget *arrow;
  GtkWidget *hbox;

  /* grab a reference on the mime database */
  chooser_button->database = thunar_vfs_mime_database_get_default ();

  gtk_widget_push_composite_child ();

  chooser_button->button = gtk_button_new ();
  g_signal_connect_swapped (G_OBJECT (chooser_button->button), "pressed", G_CALLBACK (thunar_chooser_button_pressed), chooser_button);
  gtk_box_pack_start (GTK_BOX (chooser_button), chooser_button->button, TRUE, TRUE, 0);
  gtk_widget_show (chooser_button->button);

  hbox = gtk_hbox_new (FALSE, 4);
  gtk_container_add (GTK_CONTAINER (chooser_button->button), hbox);
  gtk_widget_show (hbox);

  chooser_button->image = gtk_image_new ();
  gtk_box_pack_start (GTK_BOX (hbox), chooser_button->image, FALSE, FALSE, 0);
  gtk_widget_show (chooser_button->image);

  chooser_button->label = g_object_new (GTK_TYPE_LABEL, "xalign", 0.0f, "yalign", 0.0f, NULL);
  gtk_box_pack_start (GTK_BOX (hbox), chooser_button->label, TRUE, TRUE, 0);
  gtk_widget_show (chooser_button->label);

  separator = g_object_new (GTK_TYPE_VSEPARATOR, "height-request", 16, NULL);
  gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
  gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);
  gtk_widget_show (arrow);

  gtk_widget_pop_composite_child ();
}
Exemplo n.º 11
0
static void 
hildon_caption_init                             (HildonCaption *caption)
{
    HildonCaptionPrivate *priv = NULL;

    /* Initialize startup state */
    priv = HILDON_CAPTION_GET_PRIVATE (caption);

    priv->status = HILDON_CAPTION_OPTIONAL;
    priv->icon = NULL;
    priv->group = NULL;
    priv->is_focused = FALSE;
    priv->text = NULL;

    priv->separator = g_strdup(_("ecdg_ti_caption_separator"));

    gtk_widget_push_composite_child();

    /* Create caption text */
    priv->caption_area = gtk_hbox_new (FALSE, HILDON_CAPTION_SPACING); 
    priv->label = gtk_label_new (NULL);
    priv->icon_align = gtk_alignment_new (0.5f, 0.5f, 0.0f, 0.0f);
    priv->icon_position = HILDON_CAPTION_POSITION_RIGHT;

    /* We want to receive button presses for child widget activation */
    gtk_event_box_set_above_child (GTK_EVENT_BOX (caption), FALSE);
    gtk_widget_add_events (GTK_WIDGET (caption), GDK_BUTTON_PRESS_MASK);

    /* Pack text label caption layout */
    gtk_box_pack_end (GTK_BOX (priv->caption_area), priv->icon_align, FALSE, FALSE, 0);
    gtk_box_pack_end (GTK_BOX (priv->caption_area), priv->label, FALSE, FALSE, 0);
    gtk_widget_set_parent (priv->caption_area, GTK_WIDGET (caption));

    gtk_widget_pop_composite_child ();

    hildon_caption_set_child_expand (caption, TRUE);

    gtk_widget_show_all (priv->caption_area);
}
Exemplo n.º 12
0
static void
uni_scroll_win_set_view (UniScrollWin * window, UniImageView * view)
{
    // Setup the scrollbars
    GtkAdjustment *hadj;
    hadj = (GtkAdjustment *) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);

    GtkAdjustment *vadj;
    vadj = (GtkAdjustment *) g_object_new (GTK_TYPE_ADJUSTMENT, NULL);

    window->hscroll = gtk_hscrollbar_new (hadj);
    window->vscroll = gtk_vscrollbar_new (vadj);

    // We want to be notified when the adjustments change.
    g_signal_connect (hadj, "changed",
                      G_CALLBACK (uni_scroll_win_adjustment_changed), window);
    g_signal_connect (vadj, "changed",
                      G_CALLBACK (uni_scroll_win_adjustment_changed), window);

    // Output the adjustments to the widget.
    gtk_widget_set_scroll_adjustments (GTK_WIDGET (view), hadj, vadj);

    // Add the widgets to the table.
    gtk_widget_push_composite_child ();
    gtk_table_attach (GTK_TABLE (window), GTK_WIDGET (view), 0, 1, 0, 1,
                      GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
    gtk_table_attach (GTK_TABLE (window), window->vscroll, 1, 2, 0, 1,
                      GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
    gtk_table_attach (GTK_TABLE (window), window->hscroll, 0, 1, 1, 2,
                      GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
    gtk_table_attach (GTK_TABLE (window), window->nav_box, 1, 2, 1, 2,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    gtk_widget_pop_composite_child ();

    // Create the UniNav popup.
    window->nav = uni_nav_new (view);
}
Exemplo n.º 13
0
static void
dma_data_view_create_widget (DmaDataView *view)
{
	GtkAdjustment *adj;
	GtkWidget* wid;
	PangoFontDescription *font_desc;

	wid = GTK_WIDGET (view);

	gtk_widget_set_has_window (wid, FALSE);
	gtk_widget_set_can_focus (wid, TRUE);
	gtk_widget_set_redraw_on_allocate (wid, FALSE); 	
	
	view->char_by_byte = 2;
	view->bytes_by_line = 16;
	view->line_by_page = 16;
	
	view->hadjustment = NULL;
	view->vadjustment = NULL;
	
	view->shadow_type = GTK_SHADOW_IN;

	view->goto_window = NULL;
	view->goto_entry = NULL;
	
	font_desc = pango_font_description_from_string ("Monospace 10");
	
	view->buffer_range = GTK_ADJUSTMENT (gtk_adjustment_new (0,
											 dma_data_buffer_get_lower (view->buffer),
											 dma_data_buffer_get_upper (view->buffer)
											 ,1,4,4));
	g_signal_connect (view->buffer_range, "value_changed",
                        G_CALLBACK (dma_data_view_value_changed), view);
	
	gtk_widget_push_composite_child ();
	
	wid = gtk_vscrollbar_new (view->buffer_range);
	g_object_ref (wid);
	view->range = wid;
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	adj = view->view_range;
	gtk_widget_show (wid);

	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->ascii = wid;
	view->ascii_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);
	
	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->data = wid;
	view->data_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);

	wid = dma_chunk_view_new ();
	g_object_ref (wid);
	gtk_widget_modify_font (wid, font_desc);
	gtk_widget_set_parent (wid, GTK_WIDGET (view));
	gtk_widget_set_size_request (wid, -1, 0);
	gtk_widget_show (wid);
	gtk_text_view_set_editable (GTK_TEXT_VIEW (wid), FALSE);
	view->address = wid;
	view->adr_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (wid));
	dma_chunk_view_set_scroll_adjustment (DMA_CHUNK_VIEW (wid), view->buffer_range);
	g_signal_connect (wid, "populate_popup",
                        G_CALLBACK (dma_data_view_populate_popup), view);
	
	gtk_widget_pop_composite_child ();
	pango_font_description_free (font_desc);
}
Exemplo n.º 14
0
static void
bluetooth_chooser_init(BluetoothChooser *self)
{
	BluetoothChooserPrivate *priv = BLUETOOTH_CHOOSER_GET_PRIVATE(self);

	GtkWidget *vbox;
	GtkWidget *hbox;

	gtk_widget_push_composite_child ();

	g_object_set (G_OBJECT (self), "orientation", GTK_ORIENTATION_VERTICAL, NULL);

	priv->client = bluetooth_client_new ();

	/* Setup the widget itself */
	gtk_box_set_spacing (GTK_BOX(self), 18);
	gtk_container_set_border_width (GTK_CONTAINER(self), 0);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_show (vbox);
	gtk_box_pack_start (GTK_BOX (self), vbox, TRUE, TRUE, 0);

	/* The treeview label */
	priv->search_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
	gtk_widget_set_name (priv->search_hbox, "search_hbox");
	if (priv->show_searching)
		gtk_widget_show (priv->search_hbox);
	gtk_box_pack_end (GTK_BOX (vbox), priv->search_hbox, FALSE, TRUE, 0);
	gtk_widget_set_no_show_all (priv->search_hbox, TRUE);

	/* Setup the adapter disco mode callback for the search button */
	priv->adapter_model = bluetooth_client_get_adapter_model (priv->client);
	g_signal_connect (priv->adapter_model, "row-changed",
			  G_CALLBACK (adapter_model_row_changed), self);

	/* The searching label */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_name (hbox, "searching label hbox");
	priv->spinner = gtk_spinner_new ();
	gtk_container_add (GTK_CONTAINER (hbox), priv->spinner);
	gtk_widget_show (priv->spinner);
	priv->search_label = gtk_label_new (_("Searching for devices…"));
	gtk_container_add (GTK_CONTAINER (hbox), priv->search_label);
	gtk_widget_show (priv->search_label);
	gtk_widget_show (hbox);

	if (priv->show_searching) {
		gboolean discovering;

		g_object_get (G_OBJECT (priv->client), "default-adapter-discovering", &discovering, NULL);
		set_search_label (self, discovering);
	}

	gtk_box_pack_start (GTK_BOX (priv->search_hbox), hbox, FALSE, TRUE, 0);

	/* The treeview */
	priv->scrolled_window = create_treeview (self);
	gtk_widget_show_all (priv->scrolled_window);
	gtk_box_pack_start (GTK_BOX (vbox), priv->scrolled_window, TRUE, TRUE, 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_SHADOW_IN);

	/* The filters */
	priv->device_type_filter_model = GTK_TREE_MODEL (gtk_list_store_new (DEVICE_TYPE_FILTER_NUM_COLS,
						         G_TYPE_STRING, G_TYPE_INT));
	priv->filters_vbox = bluetooth_filter_widget_new ();
	gtk_widget_show (priv->filters_vbox);
	gtk_box_pack_start (GTK_BOX (self), priv->filters_vbox, FALSE, TRUE, 0);
	gtk_widget_set_no_show_all (priv->filters_vbox, TRUE);

	/* if filters are not visible hide the vbox */
	if (!priv->show_device_type && !priv->show_device_category)
		gtk_widget_hide (priv->filters_vbox);

	priv->default_adapter_changed_id = g_signal_connect (priv->client, "notify::default-adapter",
							     G_CALLBACK (default_adapter_changed), self);

	g_signal_connect(self, "notify::device-type-filter",
			 G_CALLBACK(filter_type_changed_cb), NULL);
	g_signal_connect(self, "notify::device-category-filter",
			 G_CALLBACK(filter_category_changed_cb), NULL);

	gtk_widget_pop_composite_child ();
}
Exemplo n.º 15
0
static GObject *
gdict_speller_constructor (GType                  type,
			   guint                  n_params,
			   GObjectConstructParam *params)
{
  GObject *object;
  GdictSpeller *speller;
  GdictSpellerPrivate *priv;
  GtkWidget *sw;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkWidget *hbox;

  object = G_OBJECT_CLASS (gdict_speller_parent_class)->constructor (type,
  						                     n_params,
								     params);
  speller = GDICT_SPELLER (object);
  priv = speller->priv;

  gtk_widget_push_composite_child ();

  sw = gtk_scrolled_window_new (NULL, NULL);
#if GTK_CHECK_VERSION (3, 0, 0)
  gtk_widget_set_vexpand (sw, TRUE);
#endif
  gtk_widget_set_composite_name (sw, "gdict-speller-scrolled-window");
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
  				  GTK_POLICY_AUTOMATIC,
  				  GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
  				       GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (speller), sw, TRUE, TRUE, 0);
  gtk_widget_show (sw);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("matches",
		  				     renderer,
						     "text", MATCH_COLUMN_WORD,
						     NULL);

  priv->treeview = gtk_tree_view_new ();
  gtk_widget_set_composite_name (priv->treeview, "gdict-speller-treeview");
  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
		           GTK_TREE_MODEL (priv->store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
  g_signal_connect (priv->treeview, "row-activated",
		    G_CALLBACK (row_activated_cb), speller);
  gtk_container_add (GTK_CONTAINER (sw), priv->treeview);
  gtk_widget_show (priv->treeview);

#if GTK_CHECK_VERSION (3, 0, 0)
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
#else
  hbox = gtk_hbox_new (FALSE, 0);
#endif

  priv->clear_button = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (priv->clear_button),
                        gtk_image_new_from_icon_name ("edit-clear",
                                                      GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect (priv->clear_button, "clicked",
		    G_CALLBACK (clear_button_clicked_cb),
		    speller);
  gtk_box_pack_start (GTK_BOX (hbox), priv->clear_button, FALSE, FALSE, 0);
  gtk_widget_show (priv->clear_button);
  gtk_widget_set_tooltip_text (priv->clear_button,
                               _("Clear the list of similar words"));

  gtk_box_pack_end (GTK_BOX (speller), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  gtk_widget_pop_composite_child ();

  return object;
}
Exemplo n.º 16
0
static void
bluetooth_filter_widget_init(BluetoothFilterWidget *self)
{
	BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(self);
	guint i;

	GtkWidget *label;
	GtkWidget *alignment;
	GtkWidget *table;
	GtkCellRenderer *renderer;

	gtk_widget_push_composite_child ();

	g_object_set (G_OBJECT (self), "orientation", GTK_ORIENTATION_VERTICAL, NULL);

	gtk_box_set_homogeneous (GTK_BOX (self), FALSE);
	gtk_box_set_spacing (GTK_BOX (self), 6);

	priv->title = gtk_label_new ("");
	/* This is the title of the filter section of the Bluetooth device chooser.
	 * It used to say Show Only Bluetooth Devices With... */
	bluetooth_filter_widget_set_title (self, _("Show:"));
	gtk_widget_show (priv->title);
	gtk_box_pack_start (GTK_BOX (self), priv->title, TRUE, TRUE, 0);
	gtk_misc_set_alignment (GTK_MISC (priv->title), 0, 0.5);

	alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
	gtk_widget_show (alignment);
	gtk_box_pack_start (GTK_BOX (self), alignment, TRUE, TRUE, 0);

	table = gtk_grid_new ();
	gtk_widget_show (table);
	gtk_container_add (GTK_CONTAINER (alignment), table);
	gtk_grid_set_row_spacing (GTK_GRID (table), 6);
	gtk_grid_set_column_spacing (GTK_GRID (table), 12);

	/* The device category filter */
	label = gtk_label_new_with_mnemonic (_("Device _category:"));
	gtk_widget_set_no_show_all (label, TRUE);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	priv->device_category_label = label;

	priv->device_category = gtk_combo_box_text_new ();
	gtk_widget_set_no_show_all (priv->device_category, TRUE);
	gtk_widget_show (priv->device_category);
	gtk_grid_attach (GTK_GRID (table), priv->device_category, 1, 0, 1, 1);
	gtk_widget_set_tooltip_text (priv->device_category, _("Select the device category to filter"));
	for (i = 0; i < BLUETOOTH_CATEGORY_NUM_CATEGORIES; i++) {
		gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->device_category),
					        _(bluetooth_device_category_to_string (i)));
	}
	g_signal_connect (G_OBJECT (priv->device_category), "changed",
			  G_CALLBACK (filter_category_changed_cb), self);
	gtk_combo_box_set_active (GTK_COMBO_BOX (priv->device_category), priv->device_category_filter);
	if (priv->show_device_category) {
		gtk_widget_show (priv->device_category_label);
		gtk_widget_show (priv->device_category);
	}

	/* The device type filter */
	label = gtk_label_new_with_mnemonic (_("Device _type:"));
	gtk_widget_set_no_show_all (label, TRUE);
	gtk_widget_show (label);
	gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);
	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
	priv->device_type_label = label;

	priv->device_type_filter_model = GTK_TREE_MODEL (gtk_list_store_new (DEVICE_TYPE_FILTER_NUM_COLS,
									     G_TYPE_STRING, G_TYPE_INT));
	priv->device_type = gtk_combo_box_new_with_model (priv->device_type_filter_model);
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->device_type), renderer, TRUE);
	gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->device_type), renderer, "text", DEVICE_TYPE_FILTER_COL_NAME);

	gtk_widget_set_no_show_all (priv->device_type, TRUE);
	gtk_widget_show (priv->device_type);
	gtk_grid_attach (GTK_GRID (table), priv->device_type, 1, 1, 1, 1);
	gtk_widget_set_tooltip_text (priv->device_type, _("Select the device type to filter"));
	gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->device_type_filter_model), NULL, G_MAXUINT32,
					   DEVICE_TYPE_FILTER_COL_NAME, _(bluetooth_type_to_filter_string (BLUETOOTH_TYPE_ANY)),
					   DEVICE_TYPE_FILTER_COL_MASK, BLUETOOTH_TYPE_ANY,
					   -1);
	gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->device_type_filter_model), NULL, G_MAXUINT32,
					   DEVICE_TYPE_FILTER_COL_NAME, _("Input devices (mice, keyboards, etc.)"),
					   DEVICE_TYPE_FILTER_COL_MASK, BLUETOOTH_TYPE_INPUT,
					   -1);
	gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->device_type_filter_model), NULL, G_MAXUINT32,
					   DEVICE_TYPE_FILTER_COL_NAME, _("Headphones, headsets and other audio devices"),
					   DEVICE_TYPE_FILTER_COL_MASK, BLUETOOTH_TYPE_AUDIO,
					   -1);
	/* The types match the types used in bluetooth-client.h */
	for (i = 1; i < _BLUETOOTH_TYPE_NUM_TYPES; i++) {
		int mask = 1 << i;
		if (mask & BLUETOOTH_TYPE_INPUT || mask & BLUETOOTH_TYPE_AUDIO)
			continue;
		gtk_list_store_insert_with_values (GTK_LIST_STORE (priv->device_type_filter_model), NULL, G_MAXUINT32,
						   DEVICE_TYPE_FILTER_COL_NAME, _(bluetooth_type_to_filter_string (mask)),
						   DEVICE_TYPE_FILTER_COL_MASK, mask,
						   -1);
	}
	g_signal_connect (G_OBJECT (priv->device_type), "changed",
			  G_CALLBACK(filter_type_changed_cb), self);
	set_combobox_from_filter (self);
	if (priv->show_device_type) {
		gtk_widget_show (priv->device_type_label);
		gtk_widget_show (priv->device_type);
	}

	/* The services filter */
	priv->device_service_filter = NULL;

	gtk_widget_pop_composite_child ();
}
Exemplo n.º 17
0
static void
mate_color_button_init (MateColorButton *color_button)
{
  GtkWidget *alignment;
  GtkWidget *frame;
  PangoLayout *layout;
  PangoRectangle rect;

  _mate_desktop_init_i18n ();

  /* Create the widgets */
  color_button->priv = MATE_COLOR_BUTTON_GET_PRIVATE (color_button);

  gtk_widget_push_composite_child ();

  alignment = gtk_alignment_new (0.5, 0.5, 0.5, 1.0);
  gtk_container_set_border_width (GTK_CONTAINER (alignment), 1);
  gtk_container_add (GTK_CONTAINER (color_button), alignment);
  gtk_widget_show (alignment);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
  gtk_container_add (GTK_CONTAINER (alignment), frame);
  gtk_widget_show (frame);

  /* Just some widget we can hook to expose-event on */
  color_button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);

  layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
  pango_layout_get_pixel_extents (layout, NULL, &rect);
  g_object_unref (layout);

  gtk_widget_set_size_request (color_button->priv->draw_area, rect.width - 2, rect.height - 2);
#if GTK_CHECK_VERSION (3, 0, 0)
  g_signal_connect (color_button->priv->draw_area, "draw",
                    G_CALLBACK (draw), color_button);
#else
  g_signal_connect (color_button->priv->draw_area, "expose-event",
                    G_CALLBACK (expose_event), color_button);
#endif
  gtk_container_add (GTK_CONTAINER (frame), color_button->priv->draw_area);
  gtk_widget_show (color_button->priv->draw_area);

  color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */

  /* Start with opaque black, alpha disabled */

  color_button->priv->color.red = 0;
  color_button->priv->color.green = 0;
  color_button->priv->color.blue = 0;
  color_button->priv->alpha = 65535;
  color_button->priv->use_alpha = FALSE;

  gtk_drag_dest_set (GTK_WIDGET (color_button),
                     GTK_DEST_DEFAULT_MOTION |
                     GTK_DEST_DEFAULT_HIGHLIGHT |
                     GTK_DEST_DEFAULT_DROP,
                     drop_types, 1, GDK_ACTION_COPY);
  gtk_drag_source_set (GTK_WIDGET(color_button),
                       GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
                       drop_types, 1,
                       GDK_ACTION_COPY);
  g_signal_connect (color_button, "drag-begin",
		    G_CALLBACK (mate_color_button_drag_begin), color_button);
  g_signal_connect (color_button, "drag-data-received",
                    G_CALLBACK (mate_color_button_drag_data_received), color_button);
  g_signal_connect (color_button, "drag-data-get",
                    G_CALLBACK (mate_color_button_drag_data_get), color_button);

  gtk_widget_pop_composite_child ();
}
Exemplo n.º 18
0
static VALUE
rg_s_push_composite_child(VALUE self)
{
    gtk_widget_push_composite_child();
    return self;
}
static void
hildon_time_picker_init                         (HildonTimePicker *picker)
{
    HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
    gint widget_group_table_column_pos[WIDGET_GROUP_COUNT];
    GtkDialog *dialog = GTK_DIALOG (picker);
    GtkTable *table = NULL;
    GtkWidget *maintocenter, *colon_label;
    const struct tm *local = NULL;
    time_t stamp;
    gint i = 0;

    g_assert (priv);

    widget_group_table_column_pos[WIDGET_GROUP_HOURS] = 1;
    widget_group_table_column_pos[WIDGET_GROUP_10_MINUTES] = 3;
    widget_group_table_column_pos[WIDGET_GROUP_1_MINUTES] = 4;
    widget_group_table_column_pos[WIDGET_GROUP_AMPM] = 5;

    /* Get AM/PM strings from locale. If they're set, the time is wanted
       in 12 hour mode. */
    priv->am_symbol = g_strdup (nl_langinfo (AM_STR));
    priv->pm_symbol = g_strdup (nl_langinfo (PM_STR));

    priv->show_ampm = priv->am_symbol[0] != '\0';
    if (priv->show_ampm)
    {
        /* Check if AM/PM should be before or after time.
           %p is the AM/PM string, so we assume that if the format string
           begins with %p it's in the beginning, and in any other case it's
           in the end (although that's not necessarily the case). */
        if (strncmp (nl_langinfo (T_FMT_AMPM), "%p", 2) == 0)
        {
            /* Before time. Update column position. */
            priv->ampm_left = TRUE;
            widget_group_table_column_pos[WIDGET_GROUP_AMPM] = 0;
        }
    }

    gtk_widget_push_composite_child ();

    /* Pack all our internal widgets into a table */
    table = GTK_TABLE (gtk_table_new (3, 6, FALSE));

    /* Put everything centered into window */
    maintocenter = gtk_alignment_new (0.5, 0, 0, 0);

    /* Create our internal widgets */
    for (i = 0; i < WIDGET_GROUP_COUNT; i++)
    {
        HildonTimePickerWidgetGroup *group = &priv->widgets[i];
        gint table_column = widget_group_table_column_pos[i];

        /* Create frame and attach to table. With AM/PM label we're attaching
           it later. */
        group->frame = gtk_frame_new (NULL);
        if (i != WIDGET_GROUP_AMPM)
        {
            gtk_table_attach (table, group->frame, table_column, table_column + 1,
                    1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0);


        }
        /* FIXME: is it needed to force it to 0 here? */
        gtk_container_set_border_width (GTK_CONTAINER(group->frame), 0);

        /* Create eventbox inside frame */
        group->eventbox = gtk_event_box_new ();
        gtk_container_add (GTK_CONTAINER (group->frame), group->eventbox);

        g_object_set (group->eventbox, "can-focus", TRUE, NULL);
        gtk_widget_set_events (group->eventbox,
                GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_PRESS_MASK);

        /* Connect signals to eventbox */
        g_signal_connect (group->eventbox, "key-release-event",
                G_CALLBACK (hildon_time_picker_event_box_key_release),
                picker);
        g_signal_connect (group->eventbox, "key-press-event",
                G_CALLBACK (hildon_time_picker_event_box_key_press),
                picker);
        g_signal_connect (group->eventbox, "focus-in-event",
                G_CALLBACK (hildon_time_picker_event_box_focus_in),
                picker);
        g_signal_connect (group->eventbox, "focus-out-event",
                G_CALLBACK (hildon_time_picker_event_box_focus_out),
                picker);
        g_signal_connect (group->eventbox, "button-press-event",
                G_CALLBACK (hildon_time_picker_event_box_button_press),
                picker);

        /* Create label inside eventbox */
        group->label = GTK_LABEL (gtk_label_new (NULL));
        g_signal_connect (group->frame, "size-request",
                G_CALLBACK (frame_size_request),
                NULL);
        gtk_misc_set_alignment (GTK_MISC (group->label), 0.5, 0.5);
        gtk_container_add (GTK_CONTAINER (group->eventbox), GTK_WIDGET (group->label));

        if (i != WIDGET_GROUP_AMPM)
        {
            gint button;

            /* Add some padding to hour and minute labels, and make them bigger */
            gtk_misc_set_padding(GTK_MISC (group->label),
                    HILDON_TIME_PICKER_LABEL_X_PADDING,
                    HILDON_TIME_PICKER_LABEL_Y_PADDING);

            gtk_widget_set_name (GTK_WIDGET(group->label), "osso-LargeFont");

            /* Create up and down buttons for hours and mins */
            for (button = 0; button < BUTTON_COUNT; button++)
            {
                gint table_row = button == BUTTON_UP ? 0 : 2;

                group->buttons[button] = gtk_button_new ();
                gtk_table_attach (table, group->buttons[button],
                        table_column, table_column + 1,
                        table_row, table_row + 1,
                        GTK_SHRINK, GTK_SHRINK, 0, 0);
                g_object_set (group->buttons[button], "can-focus", FALSE, NULL);

                /* Connect signals */
                g_signal_connect(group->buttons[button], "button-press-event",
                        G_CALLBACK (hildon_time_picker_arrow_press), picker);
                g_signal_connect(group->buttons[button], "button-release-event",
                        G_CALLBACK (hildon_time_picker_arrow_release), picker);
            }

            gtk_widget_set_name (group->buttons[BUTTON_UP],
                    "hildon-time-picker-up");
            gtk_widget_set_name (group->buttons[BUTTON_DOWN],
                    "hildon-time-picker-down");
        }
    }

    /* Label between hour and minutes */
    colon_label = gtk_label_new (NULL);
    hildon_time_editor_get_time_separators (GTK_LABEL(colon_label), NULL);

    gtk_table_attach (table, colon_label, 2, 3, 1, 2,
            GTK_SHRINK, GTK_SHRINK, 6, 0); /* FIXME: magic */
    gtk_widget_set_name (colon_label, "osso-LargeFont" );

    priv->minutes = 0;
    priv->mul = 0;
    priv->start_key_repeat = FALSE;
    priv->timer_id = 0;
    priv->button_press = FALSE;

    gtk_table_set_row_spacing (table, 0, 6);
    gtk_table_set_row_spacing (table, 1, 6);

    if (priv->show_ampm)
    {
        gint table_column = widget_group_table_column_pos[WIDGET_GROUP_AMPM];
        GtkWidget *ampmtotop = NULL;

        /* Show the AM/PM label centered vertically */
        ampmtotop = gtk_alignment_new (0, 0.5, 0, 0);
        gtk_table_attach (table, ampmtotop, table_column, table_column + 1,
                1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
        gtk_container_add (GTK_CONTAINER (ampmtotop),
                priv->widgets[WIDGET_GROUP_AMPM].frame);

        if (table_column != 0)
            gtk_table_set_col_spacing (table, table_column - 1, 9);

        /* Connect AM/PM signal handlers */
        g_signal_connect (priv->widgets[WIDGET_GROUP_AMPM].eventbox,
                "button-release-event",
                G_CALLBACK(hildon_time_picker_ampm_release), picker);
    }

    gtk_widget_pop_composite_child ();

    /* This dialog isn't modal */
    gtk_window_set_modal (GTK_WINDOW (dialog), FALSE);
    /* And final dialog packing */
    gtk_dialog_set_has_separator (dialog, FALSE);
    gtk_dialog_add_button (dialog, _("wdgt_bd_done"),
            GTK_RESPONSE_OK);

    gtk_container_add (GTK_CONTAINER (maintocenter), GTK_WIDGET(table));
    gtk_box_pack_start (GTK_BOX (dialog->vbox), maintocenter, TRUE, FALSE, 0);

    /* Set default time to current time */
    stamp = time (NULL);
    local = localtime (&stamp);
    hildon_time_picker_set_time (picker, local->tm_hour, local->tm_min);

    gtk_widget_show_all (maintocenter);
}
Exemplo n.º 20
0
static GObject *
gdict_source_dialog_constructor (GType                  type,
				 guint                  n_construct_properties,
				 GObjectConstructParam *construct_params)
{
  GObject *object;
  GdictSourceDialog *dialog;
  GtkWidget *vbox;
  GError *error = NULL;

  object = G_OBJECT_CLASS (gdict_source_dialog_parent_class)->constructor (type,
									   n_construct_properties,
									   construct_params);
  dialog = GDICT_SOURCE_DIALOG (object);

  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2);
  
  gtk_widget_push_composite_child ();

  /* get the UI from the GtkBuilder file */
  dialog->builder = gtk_builder_new ();
  gtk_builder_add_from_file (dialog->builder, GDICT_SOURCE_UI, &error);

  if (error) {
    g_critical ("Unable to load the user interface definition file: %s",
                error->message);
    g_error_free (error);
    g_assert_not_reached ();
  }
  
  /* the main widget */
  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                     GTK_WIDGET (gtk_builder_get_object (dialog->builder, "source_root")));

  /* the transport combo changes the UI by changing the visible widgets
   * bound to the transport's own options.
   */
  dialog->transport_combo = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "transport_combo"));
  g_signal_connect (dialog->transport_combo, "changed",
  		    G_CALLBACK (transport_combo_changed_cb),
  		    dialog);

  /* the help button is always visible */
  dialog->help_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
  					       GTK_STOCK_HELP,
					       GTK_RESPONSE_HELP);
  
  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "db-vbox"));
  dialog->db_chooser = gdict_database_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->db_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->db_chooser);

  vbox = GTK_WIDGET (gtk_builder_get_object (dialog->builder, "strat-vbox"));
  dialog->strat_chooser = gdict_strategy_chooser_new ();
  gtk_box_pack_start (GTK_BOX (vbox), dialog->strat_chooser, TRUE, TRUE, 0);
  gtk_widget_show (dialog->strat_chooser);

  /* the UI changes depending on the action that the source dialog
   * should perform
   */
  switch (dialog->action)
    {
    case GDICT_SOURCE_DIALOG_VIEW:
      /* disable every editable widget */
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "name_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "description_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "hostname_entry")), FALSE);
      gtk_editable_set_editable (GTK_EDITABLE (gtk_builder_get_object (dialog->builder, "port_entry")), FALSE);
      
      gtk_widget_set_sensitive (dialog->transport_combo, FALSE);

      /* we just allow closing the dialog */
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CLOSE,
      						     GTK_RESPONSE_CLOSE);
      break;
    case GDICT_SOURCE_DIALOG_CREATE:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->add_button    = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_ADD,
      						     GTK_RESPONSE_ACCEPT);
      /* the "add" button sensitivity is controlled by the transport_combo
       * since it's the only setting that makes a source usable.
       */
      gtk_widget_set_sensitive (dialog->add_button, FALSE);
      break;
    case GDICT_SOURCE_DIALOG_EDIT:
      dialog->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
      						     GTK_STOCK_CANCEL,
      						     GTK_RESPONSE_CANCEL);
      dialog->close_button  = gtk_dialog_add_button (GTK_DIALOG (dialog),
		      	 			     GTK_STOCK_CLOSE,
						     GTK_RESPONSE_CLOSE);
      break;
    default:
      g_assert_not_reached ();
      break;
    }
  
  /* this will take care of updating the contents of the dialog
   * based on the action
   */
  update_dialog_ui (dialog);
  
  gtk_widget_pop_composite_child ();
  
  return object;
}
static GObject *
gdict_source_chooser_constructor (GType                  gtype,
                                  guint                  n_params,
                                  GObjectConstructParam *params)
{
  GdictSourceChooser *chooser;
  GdictSourceChooserPrivate *priv;
  GObjectClass *parent_class;
  GObject *retval;
  GtkWidget *sw;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkWidget *hbox;

  parent_class = G_OBJECT_CLASS (gdict_source_chooser_parent_class);
  retval = parent_class->constructor (gtype, n_params, params);

  chooser = GDICT_SOURCE_CHOOSER (retval);
  priv = chooser->priv;

  gtk_widget_push_composite_child ();

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_composite_name (sw, "gdict-source-chooser-scrolled-window");
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                       GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (chooser), sw, TRUE, TRUE, 0);
  gtk_widget_show (sw);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("sources",
                                                     renderer,
                                                     "text", SOURCE_DESCRIPTION,
                                                     "weight", SOURCE_CURRENT,
                                                     NULL);
  priv->treeview = gtk_tree_view_new ();
  gtk_widget_set_composite_name (priv->treeview, "gdict-source-chooser-treeview");
  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
                           GTK_TREE_MODEL (priv->store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
  g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview)),
                    "changed", G_CALLBACK (selection_changed_cb),
                    chooser);
  g_signal_connect (priv->treeview,
                    "row-activated", G_CALLBACK (row_activated_cb),
                    chooser);
  gtk_container_add (GTK_CONTAINER (sw), priv->treeview);
  gtk_widget_show (priv->treeview);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  priv->buttons_box = hbox;

  priv->refresh_button = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (priv->refresh_button),
                        gtk_image_new_from_stock (GTK_STOCK_REFRESH,
                                                  GTK_ICON_SIZE_BUTTON));
  g_signal_connect (priv->refresh_button,
                    "clicked", G_CALLBACK (refresh_button_clicked_cb),
                    chooser);
  gtk_box_pack_start (GTK_BOX (hbox), priv->refresh_button, FALSE, FALSE, 0);
  gtk_widget_show (priv->refresh_button);
  gtk_widget_set_tooltip_text (priv->refresh_button,
                               _("Reload the list of available sources"));

  gtk_box_pack_end (GTK_BOX (chooser), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  gtk_widget_pop_composite_child ();

  return retval;
}
Exemplo n.º 22
0
static void
gtk_color_editor_init (GtkColorEditor *editor)
{
  GtkWidget *grid;
  GtkWidget *slider;
  GtkWidget *entry;
  GtkWidget *swatch;
  GtkAdjustment *h_adj, *s_adj, *v_adj, *a_adj;
  AtkObject *atk_obj;
  GdkRGBA transparent = { 0, 0, 0, 0 };

  editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor,
                                              GTK_TYPE_COLOR_EDITOR,
                                              GtkColorEditorPrivate);
  editor->priv->use_alpha = TRUE;

  editor->priv->h_adj = h_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);
  editor->priv->s_adj = s_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);
  editor->priv->v_adj = v_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);
  editor->priv->a_adj = a_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);

  g_object_ref_sink (h_adj);
  g_object_ref_sink (s_adj);
  g_object_ref_sink (v_adj);
  g_object_ref_sink (a_adj);

  g_signal_connect_swapped (h_adj, "value-changed", G_CALLBACK (hsv_changed), editor);
  g_signal_connect_swapped (s_adj, "value-changed", G_CALLBACK (hsv_changed), editor);
  g_signal_connect_swapped (v_adj, "value-changed", G_CALLBACK (hsv_changed), editor);
  g_signal_connect_swapped (a_adj, "value-changed", G_CALLBACK (hsv_changed), editor);

  gtk_widget_push_composite_child ();

  /* Construct the main UI */
  editor->priv->swatch = swatch = gtk_color_swatch_new ();
  gtk_color_swatch_set_selectable (GTK_COLOR_SWATCH (editor->priv->swatch), FALSE);
  gtk_widget_set_events (swatch, gtk_widget_get_events (swatch)
                                 & ~(GDK_BUTTON_PRESS_MASK
                                     | GDK_BUTTON_RELEASE_MASK
                                     | GDK_KEY_PRESS_MASK
                                     | GDK_KEY_RELEASE_MASK));
  gtk_widget_set_can_focus (swatch, FALSE);

  editor->priv->entry = entry = gtk_entry_new ();
  atk_obj = gtk_widget_get_accessible (entry);
  atk_object_set_role (atk_obj, ATK_ROLE_ENTRY);
  atk_object_set_name (atk_obj, _("Color Name"));
  g_signal_connect (entry, "activate", G_CALLBACK (entry_apply), editor);
  g_signal_connect (entry, "notify::text", G_CALLBACK (entry_text_changed), editor);
  g_signal_connect (entry, "focus-out-event", G_CALLBACK (entry_focus_out), editor);

  editor->priv->h_slider = slider = gtk_color_scale_new (h_adj, GTK_COLOR_SCALE_HUE);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (slider), GTK_ORIENTATION_VERTICAL);
  if (gtk_widget_get_direction (slider) == GTK_TEXT_DIR_RTL)
    gtk_style_context_add_class (gtk_widget_get_style_context (slider),
                                 GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
  else
    gtk_style_context_add_class (gtk_widget_get_style_context (slider),
                                 GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);

  editor->priv->sv_plane = gtk_color_plane_new (h_adj, s_adj, v_adj);
  gtk_widget_set_size_request (editor->priv->sv_plane, 300, 300);

  editor->priv->a_slider = slider = gtk_color_scale_new (a_adj, GTK_COLOR_SCALE_ALPHA);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (slider), GTK_ORIENTATION_HORIZONTAL);
  gtk_style_context_add_class (gtk_widget_get_style_context (slider),
                               GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);

  editor->priv->grid = grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);

  gtk_grid_attach (GTK_GRID (grid), editor->priv->swatch,   1, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->entry,    2, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->h_slider, 0, 1, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->sv_plane, 1, 1, 2, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->a_slider, 1, 2, 2, 1);

  /* This extra margin is necessary so we have room to the sides
   * to place the popups as desired
   */
  gtk_widget_set_margin_left (grid, 30);
  gtk_widget_set_margin_right (grid, 30);

  editor->priv->overlay = gtk_overlay_new ();
  gtk_widget_override_background_color (editor->priv->overlay, 0, &transparent);
  gtk_container_add (GTK_CONTAINER (editor->priv->overlay), grid);

  /* Construct the sv popup */
  editor->priv->s_entry = entry = gtk_spin_button_new (scaled_adjustment (s_adj, 100), 1, 0);
  atk_obj = gtk_widget_get_accessible (entry);
  atk_object_set_name (atk_obj, C_("Color channel", "Saturation"));
  atk_object_set_role (atk_obj, ATK_ROLE_ENTRY);
  g_signal_connect (entry, "key-press-event", G_CALLBACK (popup_key_press), editor);

  editor->priv->v_entry = entry = gtk_spin_button_new (scaled_adjustment (v_adj, 100), 1, 0);
  atk_obj = gtk_widget_get_accessible (entry);
  atk_object_set_name (atk_obj, C_("Color channel", "Value"));
  atk_object_set_role (atk_obj, ATK_ROLE_ENTRY);
  g_signal_connect (entry, "key-press-event", G_CALLBACK (popup_key_press), editor);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);

  gtk_grid_attach (GTK_GRID (grid), gtk_label_new (C_("Color channel", "S")), 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->s_entry, 1, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), gtk_label_new (C_("Color channel", "V")), 0, 1, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->v_entry, 1, 1, 1, 1);

  editor->priv->sv_popup = create_popup (editor, editor->priv->sv_plane, grid);

  /* Construct the h popup */
  editor->priv->h_entry = entry = gtk_spin_button_new (scaled_adjustment (h_adj, 100), 1, 0);
  atk_obj = gtk_widget_get_accessible (entry);
  atk_object_set_name (atk_obj, C_("Color channel", "Hue"));
  atk_object_set_role (atk_obj, ATK_ROLE_ENTRY);
  g_signal_connect (entry, "key-press-event", G_CALLBACK (popup_key_press), editor);

  grid = gtk_grid_new ();
  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);

  gtk_grid_attach (GTK_GRID (grid), gtk_label_new (C_("Color channel", "H")), 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->h_entry, 1, 0, 1, 1);

  editor->priv->h_popup = create_popup (editor, editor->priv->h_slider, grid);

  /* Construct the a popup */
  editor->priv->a_entry = entry = gtk_spin_button_new (scaled_adjustment (a_adj, 100), 1, 0);
  atk_obj = gtk_widget_get_accessible (entry);
  atk_object_set_name (atk_obj, C_("Color channel", "Alpha"));
  atk_object_set_role (atk_obj, ATK_ROLE_ENTRY);
  g_signal_connect (entry, "key-press-event", G_CALLBACK (popup_key_press), editor);

  grid = gtk_grid_new ();
  gtk_grid_set_column_spacing (GTK_GRID (grid), 6);

  gtk_grid_attach (GTK_GRID (grid), gtk_label_new (C_("Color channel", "A")), 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), editor->priv->a_entry, 1, 0, 1, 1);

  editor->priv->a_popup = create_popup (editor, editor->priv->a_slider, grid);

  /* Hook up popup positioning */
  g_signal_connect (editor->priv->overlay, "get-child-position", G_CALLBACK (get_child_position), editor);
  g_signal_connect (editor, "notify::visible", G_CALLBACK (dismiss_current_popup), NULL);

  gtk_widget_show_all (editor->priv->overlay);
  gtk_container_add (GTK_CONTAINER (editor), editor->priv->overlay);

  gtk_widget_pop_composite_child ();
}
Exemplo n.º 23
0
static void gtk_assert_dialog_init(GtkAssertDialog* dlg)
{
    GtkWidget *continuebtn;

    {
        GtkWidget *vbox, *hbox, *image;

        /* start the main vbox */
        gtk_widget_push_composite_child ();
        vbox = gtk_vbox_new (FALSE, 8);
        gtk_container_set_border_width (GTK_CONTAINER(vbox), 8);
        gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))), vbox, true, true, 5);


        /* add the icon+message hbox */
        hbox = gtk_hbox_new (FALSE, 0);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

        /* icon */
        image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
        gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 12);

        {
            GtkWidget *vbox2, *info;

            /* message */
            vbox2 = gtk_vbox_new (FALSE, 0);
            gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
            info = gtk_label_new ("An assertion failed!");
            gtk_box_pack_start (GTK_BOX(vbox2), info, TRUE, TRUE, 8);

            /* assert message */
            dlg->message = gtk_label_new (NULL);
            gtk_label_set_selectable (GTK_LABEL (dlg->message), TRUE);
            gtk_label_set_line_wrap (GTK_LABEL (dlg->message), TRUE);
            gtk_label_set_justify (GTK_LABEL (dlg->message), GTK_JUSTIFY_LEFT);
            gtk_widget_set_size_request (GTK_WIDGET(dlg->message), 450, -1);

            gtk_box_pack_end (GTK_BOX(vbox2), GTK_WIDGET(dlg->message), TRUE, TRUE, 8);
        }

        /* add the expander */
        dlg->expander = gtk_expander_new_with_mnemonic ("Back_trace:");
        gtk_box_pack_start (GTK_BOX(vbox), dlg->expander, TRUE, TRUE, 0);
        g_signal_connect (GTK_EXPANDER(dlg->expander), "activate",
                            G_CALLBACK(gtk_assert_dialog_expander_callback), dlg);
    }

    {
        GtkWidget *hbox, *vbox, *button, *sw;

        /* create expander's vbox */
        vbox = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER (dlg->expander), vbox);

        /* add a scrollable window under the expander */
        sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start (GTK_BOX(vbox), sw, TRUE, TRUE, 8);

        /* add the treeview to the scrollable window */
        dlg->treeview = gtk_assert_dialog_create_backtrace_list_model ();
        gtk_widget_set_size_request (GTK_WIDGET(dlg->treeview), -1, 180);
        gtk_container_add (GTK_CONTAINER (sw), dlg->treeview);

        /* create button's hbox */
        hbox = gtk_hbutton_box_new ();
        gtk_box_pack_end (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        gtk_button_box_set_layout (GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);

        /* add the buttons */
        button = gtk_assert_dialog_add_button_to (GTK_BOX(hbox), "Save to _file",
                                                GTK_STOCK_SAVE);
        g_signal_connect (button, "clicked",
                            G_CALLBACK(gtk_assert_dialog_save_backtrace_callback), dlg);

        button = gtk_assert_dialog_add_button_to (GTK_BOX(hbox), "Copy to clip_board",
                                                  GTK_STOCK_COPY);
        g_signal_connect (button, "clicked", G_CALLBACK(gtk_assert_dialog_copy_callback), dlg);
    }

    /* add the checkbutton */
    dlg->shownexttime = gtk_check_button_new_with_mnemonic("Show this _dialog the next time");
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dlg->shownexttime), TRUE);
    gtk_box_pack_end(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(dlg))), dlg->shownexttime, false, true, 8);

    /* add the stop button */
    gtk_assert_dialog_add_button (dlg, "_Stop", GTK_STOCK_QUIT, GTK_ASSERT_DIALOG_STOP);

    /* add the continue button */
    continuebtn = gtk_assert_dialog_add_button (dlg, "_Continue", GTK_STOCK_YES, GTK_ASSERT_DIALOG_CONTINUE);
    gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_ASSERT_DIALOG_CONTINUE);
    g_signal_connect (continuebtn, "clicked", G_CALLBACK(gtk_assert_dialog_continue_callback), dlg);

    /* complete creation */
    dlg->callback = NULL;
    dlg->userdata = NULL;

    /* the resizable property of this window is modified by the expander:
       when it's collapsed, the window must be non-resizable! */
    gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
    gtk_widget_pop_composite_child ();
    gtk_widget_show_all (GTK_WIDGET(dlg));
}
Exemplo n.º 24
0
/*
 *	initialization/finalization:
 */
static GObject *
_gtk_user_list_dialog_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params)
{
	GObject *object;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *frame;
	GtkWidget *align;
	GtkWidget *scrolled;
	GtkUserListDialogPrivate *priv;

	object = G_OBJECT_CLASS(gtk_user_list_dialog_parent_class)->constructor(type, n_construct_properties, construct_params);

	gtk_widget_push_composite_child();

	priv = GTK_USER_LIST_DIALOG(object)->priv;

	/* create main box */
	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(gtk_deletable_dialog_get_content_area(GTK_DELETABLE_DIALOG(object))), hbox);

	/* create frame */
	frame = gtk_frame_new(NULL);
	gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 2);

	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_add(GTK_CONTAINER(frame), vbox);

	hbox = gtk_hbox_new(FALSE, 5);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 2);

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 2);

	/* dialog message */
	align = gtk_alignment_new(0, 0, 0, 0);
	gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, TRUE, 10);

	priv->label_message = gtk_label_new("");
	gtk_container_add(GTK_CONTAINER(align), priv->label_message);

	/* create tree */
	scrolled = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);

	priv->tree = _gtk_user_list_dialog_create_tree(GTK_WIDGET(object));
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), priv->tree);

	/* label */
	priv->label_count = gtk_label_new(NULL);
	gtk_box_pack_start(GTK_BOX(vbox), priv->label_count, FALSE, TRUE, 2);

	/* show widgets */
	gtk_widget_show_all(gtk_deletable_dialog_get_content_area(GTK_DELETABLE_DIALOG(object)));
	gtk_widget_set_visible(priv->label_message, FALSE);

	gtk_widget_push_composite_child();

	return object;
}