Пример #1
0
static void
update_popover_direction (GtkMenuButton *menu_button)
{
  GtkMenuButtonPrivate *priv = menu_button->priv;

  if (!priv->popover)
    return;

  switch (priv->arrow_type)
    {
    case GTK_ARROW_UP:
      gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_TOP);
      break;
    case GTK_ARROW_DOWN:
    case GTK_ARROW_NONE:
      gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_BOTTOM);
      break;
    case GTK_ARROW_LEFT:
      gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_LEFT);
      break;
    case GTK_ARROW_RIGHT:
      gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_RIGHT);
      break;
    }
}
Пример #2
0
static gboolean
navigator_button_release_cb (GcalYearView   *year_view,
                             GdkEventButton *event,
                             GtkWidget      *widget)
{
  GcalYearViewPrivate *priv = year_view->priv;
  gint day, month;

  if (!priv->button_pressed)
    return FALSE;

  if (!calculate_day_month_for_coord (year_view, event->x, event->y, &day, &month))
    goto fail;

  priv->button_pressed = FALSE;
  priv->selected_data->end_day = day;
  priv->selected_data->end_month = month;

  /* update date and notify */
  priv->date->day = day;
  priv->date->month = month + 1;
  g_object_notify (G_OBJECT (year_view), "active-date");

  gtk_widget_queue_draw (widget);

  if (priv->popover_mode)
    {
      GdkRectangle rect;
      GtkWidget *box;

      /* sizing */
      box = gtk_bin_get_child (GTK_BIN (priv->popover));
      gtk_widget_set_size_request (box, 200, priv->navigator_grid->box_side * 2 * 7);

      /* FIXME: improve rect */
      rect.x = event->x;
      rect.y = event->y;
      rect.width = rect.height = 1;
      gtk_popover_set_pointing_to (GTK_POPOVER (priv->popover), &rect);

      /* FIXME: do no show over selected days */
      gtk_popover_set_position (GTK_POPOVER (priv->popover), GTK_POS_RIGHT);
      gtk_widget_show (priv->popover);
    }

  update_sidebar (year_view);
  return TRUE;

fail:
  priv->button_pressed = FALSE;
  reset_sidebar (year_view);
  return TRUE;
}
Пример #3
0
static GtkWidget *
create_popover (GtkWidget       *parent,
                GtkWidget       *child,
                GtkPositionType  pos)
{
    GtkWidget *popover;

    popover = gtk_popover_new (parent);
    gtk_popover_set_position (GTK_POPOVER (popover), pos);
    gtk_container_add (GTK_CONTAINER (popover), child);
    g_object_set (child, "margin", 6, NULL);
    gtk_widget_show (child);

    return popover;
}
Пример #4
0
static GtkWidget *
create_popover (GtkWidget       *parent,
                GtkWidget       *child,
                GtkPositionType  pos)
{
  GtkWidget *popover;

  popover = gtk_popover_new (parent);
  gtk_popover_set_position (GTK_POPOVER (popover), pos);
  gtk_container_add (GTK_CONTAINER (popover), child);
  gtk_container_set_border_width (GTK_CONTAINER (popover), 6);
  gtk_widget_show (child);

  return popover;
}
Пример #5
0
static GtkWidget*
get_popup (EogZoomEntry *zoom_entry)
{
	GdkRectangle rect;

	if (zoom_entry->priv->popup)
		return zoom_entry->priv->popup;

	zoom_entry->priv->popup = gtk_popover_new_from_model (GTK_WIDGET (zoom_entry),
	                                                       G_MENU_MODEL (zoom_entry->priv->menu));
	g_signal_connect (zoom_entry->priv->popup, "closed",
	                  G_CALLBACK (popup_menu_closed),
	                  zoom_entry);
	gtk_entry_get_icon_area (GTK_ENTRY (zoom_entry->priv->value_entry),
	                         GTK_ENTRY_ICON_SECONDARY, &rect);
	gtk_popover_set_relative_to (GTK_POPOVER (zoom_entry->priv->popup),
	                             zoom_entry->priv->value_entry);
	gtk_popover_set_pointing_to (GTK_POPOVER (zoom_entry->priv->popup), &rect);
	gtk_popover_set_position (GTK_POPOVER (zoom_entry->priv->popup), GTK_POS_BOTTOM);
	gtk_widget_set_size_request (zoom_entry->priv->popup, 150, -1);

	return zoom_entry->priv->popup;
}
Пример #6
0
static void
popover_button_clicked_cb (GtkButton *button, gpointer user_data)
{
    GtkWidget *tb;
    GtkWidget *box;
    GtkWidget *radio1;
    GtkWidget *radio2;
    GtkWidget *radio3;
    GtkPassedClockSourceData *pdata;
    GSList *list; 
    config_t config;   
    
    box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);    
    radio1 = gtk_radio_button_new_with_label (NULL, "Cycle");
    radio2 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "Hpet");
    radio3 = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio1), "System");
    list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));
    
    pdata = user_data;

    if (pdata -> popover == NULL)
    {
        pdata -> popover = gtk_popover_new (GTK_WIDGET (button));

        while (list)
        {
            tb = list -> data;

            if (g_strcmp0 (gtk_button_get_label (GTK_BUTTON (tb)),
                get_clocksource (config)) == 0)
            {
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tb), TRUE);
            }

            list = list -> next;
        }
    
        gtk_box_pack_start (GTK_BOX (box), radio1, FALSE, FALSE, 2);
        gtk_box_pack_start (GTK_BOX (box), radio2, FALSE, FALSE, 2);
        gtk_box_pack_start (GTK_BOX (box), radio3, FALSE, FALSE, 2);
        gtk_container_add (GTK_CONTAINER (pdata -> popover), box);
    }
    else
    {
        g_print ("Not NULL\n");
    }
    
    list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio1));

    gtk_popover_set_position (GTK_POPOVER (pdata -> popover), GTK_POS_RIGHT);
 
    g_signal_connect (radio1,
                      "notify::active",
                      G_CALLBACK (notify_button_toggled_cb),
                      pdata);

    g_signal_connect (radio2,
                      "notify::active",
                      G_CALLBACK (notify_button_toggled_cb),
                      pdata);

    g_signal_connect (radio3,
                      "notify::active",
                      G_CALLBACK (notify_button_toggled_cb),
                      pdata);
   
    gtk_widget_show_all (pdata -> popover);   
}