예제 #1
0
void
ide_workbench_add_perspective (IdeWorkbench   *self,
                               IdePerspective *perspective)
{
  g_autofree gchar *accel= NULL;
  g_autofree gchar *icon_name = NULL;
  g_autofree gchar *id = NULL;
  g_autofree gchar *title = NULL;
  GtkWidget *titlebar;

  g_assert (IDE_IS_WORKBENCH (self));
  g_assert (IDE_IS_PERSPECTIVE (perspective));

  id = ide_perspective_get_id (perspective);
  title = ide_perspective_get_title (perspective);
  icon_name = ide_perspective_get_icon_name (perspective);
  titlebar = ide_perspective_get_titlebar (perspective);

  gtk_container_add_with_properties (GTK_CONTAINER (self->perspectives_stack),
                                     GTK_WIDGET (perspective),
                                     "icon-name", icon_name,
                                     "name", id,
                                     "needs-attention", FALSE,
                                     "title", title,
                                     NULL);

  if (titlebar != NULL)
    gtk_container_add_with_properties (GTK_CONTAINER (self->header_stack), titlebar,
                                       "name", id,
                                       NULL);

  if (!IDE_IS_GREETER_PERSPECTIVE (perspective))
    {
      guint position = 0;

      gtk_container_child_get (GTK_CONTAINER (self->perspectives_stack),
                               GTK_WIDGET (perspective),
                               "position", &position,
                               NULL);

      g_list_store_append (self->perspectives, perspective);
      g_list_store_sort (self->perspectives,
                         ide_workbench_compare_perspective,
                         NULL);
    }

  accel = ide_perspective_get_accelerator (perspective);

  if (accel != NULL)
    {
      const gchar *accel_map[] = { accel, NULL };
      g_autofree gchar *action_name = NULL;

      action_name = g_strdup_printf ("win.perspective('%s')", id);
      gtk_application_set_accels_for_action (GTK_APPLICATION (IDE_APPLICATION_DEFAULT),
                                             action_name, accel_map);

    }
}
예제 #2
0
static void
gb_slider_add_child (GtkBuildable *buildable,
                     GtkBuilder   *builder,
                     GObject      *child,
                     const gchar  *type)
{
  GbSliderPosition position = GB_SLIDER_NONE;

  g_assert (GTK_IS_BUILDABLE (buildable));
  g_assert (GTK_IS_BUILDER (builder));
  g_assert (G_IS_OBJECT (child));

  if (!GTK_IS_WIDGET (child))
    {
      g_warning ("Child \"%s\" must be of type GtkWidget.",
                 g_type_name (G_OBJECT_TYPE (child)));
      return;
    }

  if (ide_str_equal0 (type, "bottom"))
    position = GB_SLIDER_BOTTOM;
  else if (ide_str_equal0 (type, "top"))
    position = GB_SLIDER_TOP;
  else if (ide_str_equal0 (type, "left"))
    position = GB_SLIDER_LEFT;
  else if (ide_str_equal0 (type, "right"))
    position = GB_SLIDER_RIGHT;

  gtk_container_add_with_properties (GTK_CONTAINER (buildable), GTK_WIDGET (child),
                                     "position", position,
                                     NULL);
}
예제 #3
0
static void
gb_editor_view_set_split_view (GbView   *view,
                               gboolean  split_view)
{
  GbEditorView *self = (GbEditorView *)view;

  g_assert (GB_IS_EDITOR_VIEW (self));

  if (split_view && (self->frame2 != NULL))
    return;

  if (!split_view && (self->frame2 == NULL))
    return;

  if (split_view)
    {
      self->frame2 = g_object_new (GB_TYPE_EDITOR_FRAME,
                                   "document", self->document,
                                   "visible", TRUE,
                                   NULL);
      gtk_container_add_with_properties (GTK_CONTAINER (self->paned), GTK_WIDGET (self->frame2),
                                         "shrink", FALSE,
                                         "resize", TRUE,
                                         NULL);
      gtk_widget_grab_focus (GTK_WIDGET (self->frame2));
    }
  else
    {
      GtkWidget *copy = GTK_WIDGET (self->frame2);

      self->frame2 = NULL;
      gtk_container_remove (GTK_CONTAINER (self->paned), copy);
      gtk_widget_grab_focus (GTK_WIDGET (self->frame1));
    }
}
예제 #4
0
static void
gb_terminal_set_split_view (IdeLayoutView   *view,
                            gboolean         split_view)
{
  GbTerminalView *self = (GbTerminalView *)view;
  GtkStyleContext *style_context;

  g_assert (GB_IS_TERMINAL_VIEW (self));
  g_return_if_fail (GB_IS_TERMINAL_VIEW (self));

  if (split_view && (self->terminal_bottom != NULL))
    return;

  if (!split_view && (self->terminal_bottom == NULL))
    return;

  if (split_view)
    {
      style_context = gtk_widget_get_style_context (GTK_WIDGET (view));

      self->terminal_bottom = g_object_new (GB_TYPE_TERMINAL,
                                            "audible-bell", FALSE,
                                            "scrollback-lines", G_MAXUINT,
                                            "expand", TRUE,
                                            "visible", TRUE,
                                            NULL);
      gtk_container_add_with_properties (GTK_CONTAINER (self->bottom_container),
                                         GTK_WIDGET (self->terminal_bottom),
                                         "position", 0,
                                         NULL);
      gtk_widget_show (self->bottom_container);

      gb_terminal_view_connect_terminal (self, self->terminal_bottom);
      style_context_changed (style_context, GB_TERMINAL_VIEW (view));

      gtk_widget_grab_focus (GTK_WIDGET (self->terminal_bottom));

      if (!self->bottom_has_spawned)
        {
          self->bottom_has_spawned = TRUE;
          gb_terminal_respawn (self, self->terminal_bottom);
        }
    }
  else
    {
      gtk_container_remove (GTK_CONTAINER (self->bottom_container),
                            GTK_WIDGET (self->terminal_bottom));
      gtk_widget_hide (self->bottom_container);

      self->terminal_bottom = NULL;
      self->bottom_has_focus = FALSE;
      self->bottom_has_spawned = FALSE;
      self->bottom_has_needs_attention = FALSE;
      g_clear_object (&self->save_as_file_bottom);
      gtk_widget_grab_focus (GTK_WIDGET (self->terminal_top));
    }
}
예제 #5
0
void
ide_workbench_add_perspective (IdeWorkbench   *self,
                               IdePerspective *perspective)
{
  g_autofree gchar *icon_name = NULL;
  g_autofree gchar *id = NULL;
  g_autofree gchar *title = NULL;
  GtkStack *stack;
  GtkWidget *titlebar;

  g_assert (IDE_IS_WORKBENCH (self));
  g_assert (IDE_IS_PERSPECTIVE (perspective));

  id = ide_perspective_get_id (perspective);
  title = ide_perspective_get_title (perspective);
  icon_name = ide_perspective_get_icon_name (perspective);

  if (ide_perspective_is_early (perspective))
    stack = self->top_stack;
  else
    stack = self->perspectives_stack;

  gtk_widget_set_hexpand (GTK_WIDGET (perspective), TRUE);

  gtk_container_add_with_properties (GTK_CONTAINER (stack),
                                     GTK_WIDGET (perspective),
                                     "icon-name", icon_name,
                                     "name", id,
                                     "needs-attention", FALSE,
                                     "title", title,
                                     NULL);

  titlebar = ide_perspective_get_titlebar (perspective);
  if (titlebar == NULL)
    titlebar = g_object_new (IDE_TYPE_WORKBENCH_HEADER_BAR,
                             "visible", TRUE,
                             NULL);

  gtk_container_add_with_properties (GTK_CONTAINER (self->titlebar_stack), titlebar,
                                     "name", id,
                                     NULL);

  ide_workbench_resort_perspectives (self);
}
예제 #6
0
void
show_text(GtkWidget *window, const char *text)
{
  GtkWidget *dialog, *content_area, *view, *sw;
  GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
  dialog = gtk_dialog_new_with_buttons(PACKAGE_NAME " Help",
				       GTK_WINDOW(window),
				       flags,
				       "_Close",
				       GTK_RESPONSE_CANCEL,
				       NULL);
  content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
				      GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
				 GTK_POLICY_NEVER,
				 GTK_POLICY_AUTOMATIC);
  gtk_container_add_with_properties(GTK_CONTAINER(content_area), sw,
				    "expand", TRUE,
				    "fill", TRUE,
				    NULL);

  view = gtk_text_view_new();
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);

  gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(view)),
			   text, -1);

  gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), FALSE);
  gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);

  /* Use font metrics to set the size of the text view. */

  PangoContext *context = gtk_widget_get_pango_context(view);
  PangoFontMetrics *metrics = pango_context_get_metrics(context, NULL, NULL);
  gint char_width = pango_font_metrics_get_approximate_char_width(metrics);
  gint ascent = pango_font_metrics_get_ascent(metrics);
  gint descent = pango_font_metrics_get_descent(metrics);
  gint height = PANGO_PIXELS(ascent + descent);
  gint width = PANGO_PIXELS(char_width);

  gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 * width);
  gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 * width);
  gtk_window_set_default_size(GTK_WINDOW(dialog), 70 * width, 20 * height);

  gtk_container_add(GTK_CONTAINER(sw), view);

  gtk_widget_show_all(dialog);

  gtk_dialog_run(GTK_DIALOG(dialog));

  gtk_widget_destroy(dialog);
}
예제 #7
0
static void
ppg_prefs_dialog_add_group (GtkWidget *box,
                            GtkWidget *label,
                            GtkWidget *child)
{
	GtkWidget *align;

	align = g_object_new(GTK_TYPE_ALIGNMENT,
	                     "left-padding", 12,
	                     "visible", TRUE,
	                     NULL);
	gtk_container_add(GTK_CONTAINER(align), child);

	gtk_container_add_with_properties(GTK_CONTAINER(box), label,
	                                  "expand", FALSE,
	                                  NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(box), align,
	                                  "expand", FALSE,
	                                  NULL);
}
예제 #8
0
void
gd_stack_add_named (GdStack    *stack,
                    GtkWidget  *child,
                    const char *name)
{
  g_return_if_fail (GD_IS_STACK (stack));
  g_return_if_fail (GTK_IS_WIDGET (child));

  gtk_container_add_with_properties (GTK_CONTAINER (stack),
                                     child,
                                     "name", name,
                                     NULL);
}
예제 #9
0
/**
 * ppg_menu_tool_item_init:
 * @item: (in): A #PpgMenuToolItem.
 *
 * Initializes the newly created #PpgMenuToolItem instance.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_menu_tool_item_init (PpgMenuToolItem *item)
{
	PpgMenuToolItemPrivate *priv;
	GtkWidget *hbox;
	GtkWidget *arrow;
	GtkWidget *align;

	priv = G_TYPE_INSTANCE_GET_PRIVATE(item, PPG_TYPE_MENU_TOOL_ITEM,
	                                   PpgMenuToolItemPrivate);
	item->priv = priv;

	align = g_object_new(GTK_TYPE_ALIGNMENT,
	                     "visible", TRUE,
	                     "xalign", 0.5f,
	                     "xscale", 1.0f,
	                     "yalign", 0.5f,
	                     "yscale", 0.0f,
	                     NULL);
	gtk_container_add(GTK_CONTAINER(item), align);

	priv->button = g_object_new(GTK_TYPE_BUTTON,
	                            "visible", TRUE,
	                            NULL);
	gtk_container_add(GTK_CONTAINER(align), priv->button);
	g_signal_connect(priv->button, "clicked",
	                 G_CALLBACK(ppg_menu_tool_item_button_clicked),
	                 item);

	hbox = g_object_new(GTK_TYPE_HBOX,
	                    "spacing", 3,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add(GTK_CONTAINER(priv->button), hbox);

	priv->label = g_object_new(GTK_TYPE_LABEL,
	                           "ellipsize", PANGO_ELLIPSIZE_MIDDLE,
	                           "single-line-mode", TRUE,
	                           "visible", TRUE,
	                           "xalign", 0.0f,
	                           NULL);
	gtk_container_add(GTK_CONTAINER(hbox), priv->label);

	arrow = g_object_new(GTK_TYPE_ARROW,
	                     "arrow-type", GTK_ARROW_DOWN,
	                     "visible", TRUE,
	                     NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), arrow,
	                                  "expand", FALSE,
	                                  NULL);
}
예제 #10
0
void
ide_frame_add_with_depth (IdeFrame  *self,
                          GtkWidget *widget,
                          guint      position)
{
  IdeFramePrivate *priv = ide_frame_get_instance_private (self);

  g_return_if_fail (IDE_IS_FRAME (self));
  g_return_if_fail (GTK_IS_WIDGET (widget));

  gtk_container_add_with_properties (GTK_CONTAINER (priv->stack), widget,
                                     "position", position,
                                     NULL);
}
예제 #11
0
static void
ide_editor_view_set_split_view (IdeLayoutView   *view,
                               gboolean  split_view)
{
  IdeEditorView *self = (IdeEditorView *)view;

  g_assert (IDE_IS_EDITOR_VIEW (self));

  if (split_view && (self->frame2 != NULL))
    return;

  if (!split_view && (self->frame2 == NULL))
    return;

  if (split_view)
    {
      self->frame2 = g_object_new (IDE_TYPE_EDITOR_FRAME,
                                   "show-ruler", TRUE,
                                   "document", self->document,
                                   "visible", TRUE,
                                   NULL);
      g_signal_connect_object (self->frame2->source_view,
                               "request-documentation",
                               G_CALLBACK (ide_editor_view_request_documentation),
                               self,
                               G_CONNECT_SWAPPED);

      g_signal_connect_object (self->frame2->source_view,
                               "focus-in-event",
                               G_CALLBACK (ide_editor_view__focus_in_event),
                               self,
                               G_CONNECT_SWAPPED);

      gtk_container_add_with_properties (GTK_CONTAINER (self->paned), GTK_WIDGET (self->frame2),
                                         "shrink", FALSE,
                                         "resize", TRUE,
                                         NULL);
      gtk_widget_grab_focus (GTK_WIDGET (self->frame2));
    }
  else
    {
      GtkWidget *copy = GTK_WIDGET (self->frame2);

      self->frame2 = NULL;
      gtk_container_remove (GTK_CONTAINER (self->paned), copy);
      gtk_widget_grab_focus (GTK_WIDGET (self->frame1));
    }
}
예제 #12
0
/**
 * ppg_prefs_dialog_init:
 * @dialog: A #PpgPrefsDialog.
 *
 * Initializes the newly created #PpgPrefsDialog instance.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_prefs_dialog_init (PpgPrefsDialog *dialog) /* IN */
{
	PpgPrefsDialogPrivate *priv;
	GtkWidget *content_area;
	GtkWidget *page;

	priv = G_TYPE_INSTANCE_GET_PRIVATE(dialog, PPG_TYPE_PREFS_DIALOG,
	                                   PpgPrefsDialogPrivate);
	dialog->priv = priv;

	g_signal_connect(dialog, "delete-event",
	                 G_CALLBACK(ppg_prefs_dialog_delete_event),
	                 NULL);
	g_signal_connect(dialog, "response",
	                 G_CALLBACK(ppg_prefs_dialog_response),
	                 NULL);

	g_object_set(dialog,
	             "border-width", 6,
	             "default-height", 400,
	             "default-width", 400,
	             "has-separator", FALSE,
	             "title", _("Preferences"),
	             NULL);

	content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

	priv->notebook = g_object_new(GTK_TYPE_NOTEBOOK,
	                              "border-width", 6,
	                              "visible", TRUE,
	                              NULL);
	gtk_container_add(GTK_CONTAINER(content_area), priv->notebook);

	page = ppg_prefs_dialog_create_project_page(dialog);
	gtk_container_add_with_properties(GTK_CONTAINER(priv->notebook), page,
	                                  "position", 0,
	                                  "tab-label", _("Projects"),
	                                  NULL);

	gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE,
	                      GTK_RESPONSE_CLOSE);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
}
예제 #13
0
static void
split_toggled (GtkWidget    *button,
               GbViewSource *source)
{
    GbViewSourcePrivate *priv;

    ENTRY;

    g_return_if_fail(GTK_IS_BUTTON(button));
    g_return_if_fail(GB_IS_VIEW_SOURCE(source));

    priv = source->priv;

    if (priv->scroller2) {
        gtk_container_remove(GTK_CONTAINER(priv->vpaned), priv->scroller2);
        priv->scroller2 = NULL;
        priv->source2 = NULL;
    } else {
        GtkAllocation alloc;

        priv->scroller2 = g_object_new(gb_get_scrolled_window_gtype(),
                                       "visible", TRUE,
                                       NULL);
        gtk_container_add_with_properties(GTK_CONTAINER(priv->vpaned), priv->scroller2,
                                          "shrink", FALSE,
                                          "resize", TRUE,
                                          NULL);

        priv->source2 = gb_view_source_create_source_view(source);
        gtk_container_add(GTK_CONTAINER(priv->scroller2), priv->source2);

        gtk_widget_get_allocation(priv->vpaned, &alloc);
        g_object_set(priv->vpaned, "position", alloc.height / 2, NULL);
    }

    EXIT;
}
예제 #14
0
static GtkWidget*
ppg_prefs_dialog_create_window_page (PpgPrefsDialog *dialog)
{
	GSettings *settings;
	GtkWidget *adj;
	GtkWidget *b;
	GtkWidget *group;
	GtkWidget *hbox;
	GtkWidget *l;
	GtkWidget *vbox;

	settings = ppg_prefs_get_window_settings();

	vbox = g_object_new(GTK_TYPE_VBOX,
	                    "border-width", 12,
	                    "spacing", 6,
	                    "visible", TRUE,
	                    NULL);

	group = g_object_new(GTK_TYPE_VBOX,
	                     "spacing", 6,
	                     "visible", TRUE,
	                     NULL);

	b = g_object_new(GTK_TYPE_CHECK_BUTTON,
	                 "visible", TRUE,
	                 "label", _("Scroll on incoming data"),
	                 "tooltip-text", _("Upon receiving incoming data, the "
	                                   "visualizers will scroll to show the "
	                                   "new data."),
	                 NULL);
	g_settings_bind(settings, "horiz-autoscroll",
	                b, "active",
	                G_SETTINGS_BIND_DEFAULT);
	gtk_container_add_with_properties(GTK_CONTAINER(group), b,
	                                  "expand", FALSE,
	                                  NULL);

	hbox = g_object_new(GTK_TYPE_HBOX,
	                    "spacing", 6,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(group), hbox,
	                                  "expand", FALSE,
	                                  NULL);
	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", _("Updates per second"),
	                 "visible", TRUE,
	                 "xalign", 0.0f,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), l,
	                                  "expand", FALSE,
	                                  NULL);
	adj = g_object_new(GTK_TYPE_ADJUSTMENT,
	                   "lower", 1.0,
	                   "upper", 60.0,
	                   "step-increment", 1.0,
	                   NULL);
	b = g_object_new(GTK_TYPE_SPIN_BUTTON,
	                 "adjustment", adj,
	                 "visible", TRUE,
	                 "value", 2.0,
	                 NULL);
	g_settings_bind(settings, "redraws-per-second",
	                adj, "value",
	                G_SETTINGS_BIND_DEFAULT);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), b,
	                                  "expand", FALSE,
	                                  NULL);

	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", _("<b>Visualizers</b>"),
	                 "visible", TRUE,
	                 "use-markup", TRUE,
	                 "xalign", 0.0f,
	                 NULL);
	ppg_prefs_dialog_add_group(vbox, l, group);

	return vbox;
}
예제 #15
0
gint
main (gint argc,
      gchar ** argv)
{
  GtkWidget *window, *box, *button, *hbox, *combo;
  GtkWidget *w2, *w3;
  GtkListStore* store;
  GtkWidget *tree_view;
  GtkTreeViewColumn *column;
  GtkCellRenderer *renderer;
  GtkWidget *scrolled_win;
  int i;
  GtkTreeIter iter;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_size_request (window, 300, 300);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (window), box);

  switcher = gtk_stack_switcher_new ();
  gtk_box_pack_start (GTK_BOX (box), switcher, FALSE, FALSE, 0);

  stack = gtk_stack_new ();

  /* Make transitions longer so we can see that they work */
  gtk_stack_set_transition_duration (GTK_STACK (stack), 1500);

  gtk_widget_set_halign (stack, GTK_ALIGN_START);
  gtk_container_add (GTK_CONTAINER (box), stack);

  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));

  w1 = gtk_text_view_new ();
  gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (w1)),
			    "This is a\nTest\nBalh!", -1);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), w1,
				     "name", "1",
				     "title", "1",
				     NULL);

  w2 = gtk_button_new_with_label ("Gazoooooooooooooooonk");
  gtk_container_add (GTK_CONTAINER (stack), w2);
  gtk_container_child_set (GTK_CONTAINER (stack), w2,
			   "name", "2",
			   "title", "2",
                           "needs-attention", TRUE,
			   NULL);


  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request (scrolled_win, 100, 200);


  store = gtk_list_store_new (1, G_TYPE_STRING);

  for (i = 0; i < 40; i++)
    gtk_list_store_insert_with_values (store, &iter, i, 0,  "Testvalule", -1);

  tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));

  gtk_container_add (GTK_CONTAINER (scrolled_win), tree_view);
  w3 = scrolled_win;

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("Target", renderer,
						     "text", 0, NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);

  gtk_stack_add_titled (GTK_STACK (stack), w3, "3", "3");

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_add (GTK_CONTAINER (box), hbox);

  button = gtk_button_new_with_label ("1");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child, w1);

  button = gtk_button_new_with_label ("2");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child, w2);

  button = gtk_button_new_with_label ("3");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child, w3);

  button = gtk_button_new_with_label ("1");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "1");

  button = gtk_button_new_with_label ("2");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "2");

  button = gtk_button_new_with_label ("3");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) set_visible_child_name, (gpointer) "3");

  button = gtk_check_button_new_with_label ("homogeneous");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
				gtk_stack_get_homogeneous (GTK_STACK (stack)));
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) toggle_homogeneous, NULL);

  button = gtk_toggle_button_new_with_label ("Add icon");
  g_signal_connect (button, "toggled", (GCallback) toggle_icon_name, NULL);
  gtk_container_add (GTK_CONTAINER (hbox), button);

  combo = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "CROSSFADE");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_RIGHT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_LEFT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_UP");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_DOWN");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_LEFT_RIGHT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "SLIDE_UP_DOWN");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "OVER_UP");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "OVER_DOWN");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "OVER_LEFT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "OVER_RIGHT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "UNDER_UP");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "UNDER_DOWN");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "UNDER_LEFT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "UNDER_RIGHT");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "OVER_UP_DOWN");
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

  gtk_container_add (GTK_CONTAINER (hbox), combo);
  g_signal_connect (combo, "changed", (GCallback) toggle_transitions, NULL);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_add (GTK_CONTAINER (box), hbox);

  button = gtk_button_new_with_label ("<");
  g_signal_connect (button, "clicked", (GCallback) on_back_button_clicked, stack);
  g_signal_connect (stack, "notify::visible-child-name",
                    (GCallback)update_back_button_sensitivity, button);
  gtk_container_add (GTK_CONTAINER (hbox), button);

  button = gtk_button_new_with_label (">");
  gtk_container_add (GTK_CONTAINER (hbox), button);
  g_signal_connect (button, "clicked", (GCallback) on_forward_button_clicked, stack);
  g_signal_connect (stack, "notify::visible-child-name",
                    (GCallback)update_forward_button_sensitivity, button);


  gtk_widget_show_all (window);
  gtk_main ();

  gtk_widget_destroy (window);

  return 0;
}
static void
ide_debugger_editor_addin_add_ui (IdeDebuggerEditorAddin *self)
{
  GtkWidget *scroll_box;
  GtkWidget *box;
  GtkWidget *hpaned;
  GtkWidget *utilities;
  GtkWidget *overlay;

  g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self));
  g_assert (IDE_IS_EDITOR_SURFACE (self->editor));

#define OBSERVE_DESTROY(ptr) \
  g_signal_connect ((ptr), "destroy", G_CALLBACK (gtk_widget_destroyed), &(ptr))

  overlay = ide_editor_surface_get_overlay (self->editor);

  self->controls = g_object_new (IDE_TYPE_DEBUGGER_CONTROLS,
                                 "transition-duration", 500,
                                 "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP,
                                 "reveal-child", FALSE,
                                 "visible", TRUE,
                                 "halign", GTK_ALIGN_CENTER,
                                 "valign", GTK_ALIGN_END,
                                 NULL);
  OBSERVE_DESTROY (self->controls);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), GTK_WIDGET (self->controls));

  self->panel = g_object_new (DZL_TYPE_DOCK_WIDGET,
                              "title", _("Debugger"),
                              "icon-name", "builder-debugger-symbolic",
                              "visible", FALSE,
                              NULL);
  OBSERVE_DESTROY (self->panel);

  box = g_object_new (GTK_TYPE_NOTEBOOK,
                      "visible", TRUE,
                      NULL);
  gtk_container_add (GTK_CONTAINER (self->panel), box);

  hpaned = g_object_new (DZL_TYPE_MULTI_PANED,
                         "orientation", GTK_ORIENTATION_HORIZONTAL,
                         "visible", TRUE,
                         NULL);
  gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (hpaned),
                                     "tab-label", _("Threads"),
                                     NULL);

  self->threads_view = g_object_new (IDE_TYPE_DEBUGGER_THREADS_VIEW,
                                     "hexpand", TRUE,
                                     "visible", TRUE,
                                     NULL);
  OBSERVE_DESTROY (self->threads_view);
  g_signal_connect_swapped (self->threads_view,
                            "frame-activated",
                            G_CALLBACK (on_frame_activated),
                            self);
  gtk_container_add (GTK_CONTAINER (hpaned), GTK_WIDGET (self->threads_view));

  self->locals_view = g_object_new (IDE_TYPE_DEBUGGER_LOCALS_VIEW,
                                    "width-request", 250,
                                    "visible", TRUE,
                                    NULL);
  OBSERVE_DESTROY (self->locals_view);
  gtk_container_add (GTK_CONTAINER (hpaned), GTK_WIDGET (self->locals_view));

  self->breakpoints_view = g_object_new (IDE_TYPE_DEBUGGER_BREAKPOINTS_VIEW,
                                         "visible", TRUE,
                                         NULL);
  OBSERVE_DESTROY (self->breakpoints_view);
  gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->breakpoints_view),
                                     "tab-label", _("Breakpoints"),
                                     NULL);

  self->libraries_view = g_object_new (IDE_TYPE_DEBUGGER_LIBRARIES_VIEW,
                                       "visible", TRUE,
                                       NULL);
  OBSERVE_DESTROY (self->libraries_view);
  gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->libraries_view),
                                     "tab-label", _("Libraries"),
                                     NULL);

  self->registers_view = g_object_new (IDE_TYPE_DEBUGGER_REGISTERS_VIEW,
                                       "visible", TRUE,
                                       NULL);
  OBSERVE_DESTROY (self->registers_view);
  gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (self->registers_view),
                                     "tab-label", _("Registers"),
                                     NULL);

  scroll_box = g_object_new (GTK_TYPE_BOX,
                             "orientation", GTK_ORIENTATION_HORIZONTAL,
                             "visible", TRUE,
                             NULL);
  gtk_container_add_with_properties (GTK_CONTAINER (box), GTK_WIDGET (scroll_box),
                                     "tab-label", _("Log"),
                                     NULL);

  self->log_view = g_object_new (IDE_TYPE_TERMINAL,
                                 "hexpand", TRUE,
                                 "visible", TRUE,
                                 NULL);
  OBSERVE_DESTROY (self->log_view);
  gtk_container_add (GTK_CONTAINER (scroll_box), GTK_WIDGET (self->log_view));

  self->log_view_scroller = g_object_new (GTK_TYPE_SCROLLBAR,
                                          "adjustment", gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->log_view)),
                                          "orientation", GTK_ORIENTATION_VERTICAL,
                                          "visible", TRUE,
                                          NULL);
  gtk_container_add (GTK_CONTAINER (scroll_box), GTK_WIDGET (self->log_view_scroller));

  utilities = ide_editor_surface_get_utilities (self->editor);
  gtk_container_add (GTK_CONTAINER (utilities), GTK_WIDGET (self->panel));

#undef OBSERVE_DESTROY
}
static void
power_manager_plugin_configure (XfcePanelPlugin      *plugin,
                                PowerManagerPlugin   *power_manager_plugin)
{
  GtkWidget *dialog;
  GtkWidget *grid, *combo, *label;
  gint show_panel_label;
  XfconfChannel   *channel;
  GtkListStore *list_store;
  GtkTreeIter iter, active_iter;
  GtkCellRenderer *cell;
  gint i;
  gchar *options[] = { _("None"), _("Percentage"), _("Remaining time"), _("Percentage and remaining time") };

  channel = xfconf_channel_get (XFPM_CHANNEL);

  /* block the plugin menu */
  xfce_panel_plugin_block_menu (plugin);

  /* create the dialog */
  dialog = xfce_titled_dialog_new_with_buttons (_("Power Manager Plugin Settings"),
                                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
                                                GTK_DIALOG_DESTROY_WITH_PARENT,
                                                "gtk-help", GTK_RESPONSE_HELP,
                                                "gtk-close", GTK_RESPONSE_OK,
                                                NULL);
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
  gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-power-manager-settings");
  gtk_widget_show (dialog);

  /* Set up the main grid for all settings */
  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_widget_set_margin_start (grid, 12);
  gtk_widget_set_margin_end (grid, 12);
  gtk_widget_set_margin_top (grid, 12);
  gtk_widget_set_margin_bottom (grid, 12);
  gtk_container_add_with_properties (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
						                         grid, "expand", TRUE, "fill", TRUE, NULL);

  /* show-panel-label setting */
  label = gtk_label_new (_("Show label:"));
  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
  gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (label), 0, 0, 1, 1);
  show_panel_label = xfconf_channel_get_int (channel, XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, -1);

  list_store = gtk_list_store_new (N_COLUMNS,
                                   G_TYPE_INT,
                                   G_TYPE_STRING);

  for (i = 0; i < 4; i++) {
    gtk_list_store_append (list_store, &iter);
    gtk_list_store_set (list_store, &iter,
                        COLUMN_INT, i,
                        COLUMN_STRING, options[i],
                        -1);
    if (i == show_panel_label)
      active_iter = iter;
  }
  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
  cell = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE );
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_STRING, NULL);
  gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), COLUMN_STRING);
  gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &active_iter);
  gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (combo), 1, 0, 1, 1);
  g_signal_connect (G_OBJECT (combo), "changed",
                    G_CALLBACK (power_manager_plugin_combo_changed),
                    channel);
  g_signal_connect (G_OBJECT (channel), "property-changed::" XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL,
                    G_CALLBACK (power_manager_plugin_panel_label_changed),
                    combo);

  /* link the dialog to the plugin, so we can destroy it when the plugin
   * is closed, but the dialog is still open */
  g_object_set_data (G_OBJECT (plugin), "dialog", dialog);

  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK(power_manager_plugin_configure_response), power_manager_plugin);
  gtk_widget_show_all (grid);
}
예제 #18
0
gint
main(gint argc, gchar **argv)
{
	GtkWidget     *dialog;
    GtkWidget     *settings_editor;
	GtkWidget     *plug;
	GError        *error = NULL;

    /* setup translation domain */
    xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");

    /* initialize Gtk+ */
    if (!gtk_init_with_args (&argc, &argv, "", option_entries, GETTEXT_PACKAGE, &error))
    {
        if (G_LIKELY (error))
        {
            /* print error */
            g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message);
            g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
            g_print ("\n");

            /* cleanup */
            g_error_free (error);
        }
        else
        {
            g_error ("Unable to open display.");
        }

        return EXIT_FAILURE;
    }

    /* print version information */
    if (G_UNLIKELY (opt_version))
    {
        g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ());
        g_print ("%s\n", "Copyright (c) 2008-2011");
        g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved."));
        g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT);
        g_print ("\n");

        return EXIT_SUCCESS;
    }

    /* initialize xfconf */
    if (G_UNLIKELY (!xfconf_init (&error)))
    {
        /* print error and leave */
        g_critical ("Failed to connect to Xfconf daemon: %s", error->message);
        g_error_free (error);

        return EXIT_FAILURE;
    }

	channel = xfconf_channel_new ("xfce4-settings-editor");

	settings_editor = xfce_settings_editor_box_new (
		xfconf_channel_get_int (channel, "/last/paned-position", 180));

	if (G_UNLIKELY (opt_socket_id == 0))
    {
		dialog = xfce_titled_dialog_new_with_buttons (_("Settings Editor"), NULL,
					GTK_DIALOG_DESTROY_WITH_PARENT,
					"gtk-help", GTK_RESPONSE_HELP,
					"gtk-close", GTK_RESPONSE_OK,
					NULL);

		xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog),
										 _("Customize settings stored by Xfconf"));

		gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-system");
		gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL);
		gtk_window_set_default_size (GTK_WINDOW (dialog),
          xfconf_channel_get_int (channel, "/last/window-width", 640),
          xfconf_channel_get_int (channel, "/last/window-height", 500));

		gtk_container_add_with_properties(
			GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
						  settings_editor,
						  "expand", TRUE,
						  "fill", TRUE,
						  NULL);

		g_signal_connect (dialog, "response",
                    G_CALLBACK (settings_dialog_response), settings_editor);

		gtk_widget_show_all (dialog);

	}
	else
	{
		/* Create plug widget */
		plug = gtk_plug_new (opt_socket_id);
		g_signal_connect (plug, "delete-event", G_CALLBACK (plug_delete_event), settings_editor);

		gtk_window_set_default_size (GTK_WINDOW (plug),
		  xfconf_channel_get_int (channel, "/last/window-width", 640),
          xfconf_channel_get_int (channel, "/last/window-height", 500));

		gtk_widget_show (plug);

		gtk_container_add (GTK_CONTAINER(plug), settings_editor);

		/* Stop startup notification */
		gdk_notify_startup_complete ();

		gtk_widget_show (GTK_WIDGET (settings_editor));
	}

    gtk_main ();

	g_object_unref(channel);

    /* shutdown xfconf */
    xfconf_shutdown ();

    return EXIT_SUCCESS;
}
예제 #19
0
파일: main.c 프로젝트: chergert/simply-chat
gint
main (gint argc,
      gchar *argv[])
{
	GtkStyleContext *context;
	GtkWidget *a;
	GtkWidget *avatar;
	GtkWidget *grid;
	GtkWidget *l;
	GtkWidget *main_vbox;
	GtkWidget *scroller;
	GtkWidget *toolbar;
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *viewport;
	gint i;

	gtk_init(&argc, &argv);

	window = g_object_new(GTK_TYPE_WINDOW,
	                      "title", _("Simply Chat"),
	                      NULL);

	main_vbox = g_object_new(GTK_TYPE_VBOX,
	                         "visible", TRUE,
	                         NULL);
	gtk_container_add(GTK_CONTAINER(window), main_vbox);

	toolbar = g_object_new(GTK_TYPE_TOOLBAR,
	                       "show-arrow", FALSE,
	                       "visible", TRUE,
	                       NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(main_vbox), toolbar,
	                                  "expand", FALSE,
	                                  NULL);

	l = g_object_new(GTK_TYPE_COMBO_BOX,
	                 "has-entry", TRUE,
	                 "visible", TRUE,
	                 NULL);
	gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(l))), "Available");
	a = g_object_new(GTK_TYPE_TOOL_ITEM,
	                 "child", l,
	                 "visible", TRUE,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(toolbar), a,
	                                  "expand", TRUE,
	                                  NULL);

	scroller = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
	                        "visible", TRUE,
	                        NULL);
	gtk_container_add(GTK_CONTAINER(main_vbox), scroller);

	viewport = g_object_new(GTK_TYPE_VIEWPORT,
	                        "visible", TRUE,
	                        NULL);
	context = gtk_widget_get_style_context(viewport);
	gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
	gtk_container_add(GTK_CONTAINER(scroller), viewport);

	vbox = g_object_new(GTK_TYPE_VBOX,
	                    "border-width", 6,
	                    "spacing", 6,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add(GTK_CONTAINER(viewport), vbox);

	a = g_object_new(GTK_TYPE_ALIGNMENT,
	                 "left-padding", 12,
	                 "right-padding", 6,
	                 "visible", TRUE,
	                 NULL);
	grid = g_object_new(CHAT_TYPE_GRID,
	                    "column-spacing", 6,
	                    "row-spacing", 6,
	                    "visible", TRUE,
	                    NULL);
	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", "<b>_Frequent <span size='smaller'>(20)</span></b>",
	                 "mnemonic-widget", grid,
	                 "use-markup", TRUE,
	                 "use-underline", TRUE,
	                 "visible", TRUE,
	                 "xalign", 0.0f,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), l,
	                                  "expand", FALSE,
	                                  NULL);
	gtk_container_add(GTK_CONTAINER(a), grid);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), a,
	                                  "expand", FALSE,
	                                  NULL);

	for (i = 0; i < 20; i++) {
		avatar = g_object_new(CHAT_TYPE_AVATAR,
		                      "visible", TRUE,
		                      NULL);
		gtk_container_add(GTK_CONTAINER(grid), avatar);
	}

	a = g_object_new(GTK_TYPE_ALIGNMENT,
	                 "left-padding", 12,
	                 "right-padding", 6,
	                 "visible", TRUE,
	                 NULL);
	grid = g_object_new(CHAT_TYPE_GRID,
	                    "column-spacing", 6,
	                    "row-spacing", 6,
	                    "visible", TRUE,
	                    NULL);
	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", "<b>_Buddies <span size='smaller'>(100)</span></b>",
	                 "mnemonic-widget", grid,
	                 "use-markup", TRUE,
	                 "use-underline", TRUE,
	                 "visible", TRUE,
	                 "xalign", 0.0f,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), l,
	                                  "expand", FALSE,
	                                  NULL);
	gtk_container_add(GTK_CONTAINER(a), grid);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), a,
	                                  "expand", FALSE,
	                                  NULL);

	for (i = 0; i < 100; i++) {
		avatar = g_object_new(CHAT_TYPE_AVATAR,
		                      "visible", TRUE,
		                      NULL);
		gtk_container_add(GTK_CONTAINER(grid), avatar);
	}

	g_signal_connect(window, "delete-event", gtk_main_quit, NULL);

	gtk_window_present(GTK_WINDOW(window));
	gtk_main();

	return 0;
}
/* Constrcut side bar widget. */
static GtkWidget *
libre_impuesto_window_construct_sidebar (LibreImpuesto *impuesto,
					 LibreImpuestoWindow *impuesto_window)
{
  GtkStack * stack;
  GtkWidget *switcher;
  GtkTreePath *tree_path;
  GtkTreeStore * tree_store;
  GtkTreeViewColumn *column;
  GtkTreeSelection *selection;
  GtkCellRenderer *cell_renderer;
  GtkWidget *paned, *box_switcher, *widget, *frame, *scroll;


  paned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);

  g_object_bind_property (impuesto_window, "sidebar-visible",
			  paned, "visible",
			  G_BINDING_SYNC_CREATE);

  box_switcher = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  switcher = gtk_stack_switcher_new ();
  g_object_set_data(G_OBJECT(impuesto_window), "switcher", switcher);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), 
				  GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_end (GTK_BOX (box_switcher), switcher, FALSE, FALSE, 0);

  stack = GTK_STACK (gtk_stack_new ());
  gtk_stack_set_homogeneous ( stack, TRUE);
  gtk_box_pack_end (GTK_BOX (box_switcher), GTK_WIDGET(stack), TRUE, TRUE, 0);

  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  
  tree_store = libre_impuesto_get_tree_data_general( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column,_( "Libre Impuestos"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  gtk_tree_view_expand_all(GTK_TREE_VIEW(widget));

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));


  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Generales"),
				     "title",_("General Options"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);


  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  tree_store = libre_impuesto_get_tree_data_formulario( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column, _("Electronic Forms"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));

  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Modulos"),
				     "title",_( "Electronic Forms"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);

  tree_path = gtk_tree_path_new_from_string ("0");
  gtk_tree_view_expand_row (GTK_TREE_VIEW(widget), tree_path, FALSE);


  scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  tree_store = libre_impuesto_get_tree_data_consultor( impuesto );
  widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL(tree_store)); 

  column = gtk_tree_view_column_new();
  gtk_tree_view_column_set_title (column,_("Consultores"));

  cell_renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "pixbuf", 0);

  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute (column, cell_renderer, "text", 1);

  gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column);

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget));
  g_signal_connect_swapped ( selection, "changed",
			     G_CALLBACK (node_tree_selection_changed_cb), 
			     G_OBJECT (impuesto_window));

  gtk_container_add (GTK_CONTAINER (scroll), widget);

  gtk_container_add_with_properties (GTK_CONTAINER (stack), scroll, 
				     "name", _("Consultores"),
				     "title",_( "Consultores"),
				     "icon-name", GTK_STOCK_HOME,
				     NULL);

  tree_path = gtk_tree_path_new_from_string ("0");
  gtk_tree_view_expand_row (GTK_TREE_VIEW(widget), tree_path, FALSE);

  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));

  gtk_paned_pack1 ( GTK_PANED(paned), box_switcher, TRUE, FALSE );

  gtk_widget_show_all (box_switcher);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);

  widget = gtk_drawing_area_new ();
  gtk_widget_set_name (widget, "logo");

  /*gtk_widget_set_size_request (widget, 
			       gdk_pixbuf_get_width (logo), 
			       gdk_pixbuf_get_height (logo));*/

  gtk_widget_set_size_request (widget, -1, 50);

  g_signal_connect (widget, "draw",
		    G_CALLBACK (draw_area_cb), NULL);

  gtk_container_add (GTK_CONTAINER (frame), widget);

  gtk_paned_pack2 (GTK_PANED(paned), frame, TRUE, FALSE);

  return paned;

}
/* object libre impuesto window constructed */
static void
libre_impuesto_window_constructed (GObject *object)
{
  GtkBox *box;
  GtkPaned *paned;
  GtkWidget *widget;
  GtkWidget *notebook;
  GtkWidget *background;
  LibreImpuesto *impuesto;
  LibreImpuestoWindow *impuesto_window = LIBRE_IMPUESTO_WINDOW (object);
  LibreImpuestoWindowPrivate *priv = impuesto_window->priv;

  impuesto = libre_impuesto_window_get_impuesto (impuesto_window);
  libre_impuesto_window_actions_init(impuesto_window);

  // Create a GtkBox container
  widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (impuesto_window), widget);

  box = GTK_BOX (widget);

  widget = libre_impuesto_window_construct_menubar (impuesto_window);
  if (widget != NULL)
    gtk_box_pack_start (box, widget, FALSE, FALSE, 0);

  widget = libre_impuesto_window_construct_headerbar (impuesto_window);
  if (widget != NULL)
    gtk_box_pack_start (box, widget, FALSE, FALSE, 0);

  widget = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (box, widget, TRUE, TRUE, 0);

  paned = GTK_PANED (widget);


  widget = gtk_statusbar_new();
  g_object_bind_property ( impuesto_window, "statusbar-visible",
			   widget, "visible",
			   G_BINDING_SYNC_CREATE);
  gtk_statusbar_push (GTK_STATUSBAR (widget), 
		      1, PACKAGE_STRING);

  gtk_box_pack_start (box, widget, FALSE, FALSE, 0);

  widget = gtk_statusbar_get_message_area (GTK_STATUSBAR (widget));
  gtk_widget_set_halign (widget, GTK_ALIGN_END);
    
  widget = libre_impuesto_window_construct_sidebar (impuesto, impuesto_window);
  if (widget != NULL)
    gtk_paned_pack1 (paned, widget, FALSE, FALSE);

  background = gtk_drawing_area_new();
  gtk_widget_set_name (background, "libre-impuesto-background");
  g_signal_connect (background, "draw",
  G_CALLBACK (draw_area_cb), NULL);

  notebook = impuesto_notebook_new();
  priv->notebook = GTK_NOTEBOOK (notebook);
  g_object_set_data ( G_OBJECT(impuesto_window), "notebook", notebook);
  g_signal_connect ( GTK_NOTEBOOK (notebook), "tab-close-request",
		    G_CALLBACK (notebook_page_close_request_cb), impuesto_window);
  g_signal_connect ( GTK_NOTEBOOK (notebook), "switch-page",
		     G_CALLBACK (switch_page_cb), 
		     impuesto_window);

  widget = gtk_stack_new();
  priv->stack = GTK_STACK (widget);
  gtk_container_add_with_properties (GTK_CONTAINER (widget), background, 
				     "name", "background",
				     NULL);

  gtk_container_add_with_properties (GTK_CONTAINER (widget), notebook, 
				     "name", "notebook",
				     NULL);
  if (widget != NULL)
    gtk_paned_pack2 (paned, widget, TRUE, FALSE);

  gtk_widget_show_all (GTK_WIDGET(box));

  //gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 0);
  gtk_application_add_window (GTK_APPLICATION (impuesto), 
			      GTK_WINDOW(impuesto_window));

  /* Chain up to parent's constructed() method. */
  G_OBJECT_CLASS (libre_impuesto_window_parent_class)->constructed (object);
}
예제 #22
0
int
main (int argc,
      char *argv[])
{
  GtkCssProvider *provider;
  GtkWindow *window;
  GtkHeaderBar *header_bar;
  GbSlider *slider;
  GtkButton *button;

  gtk_init (&argc, &argv);

  provider = gtk_css_provider_new ();
  gtk_css_provider_load_from_data (provider, CSS_DATA, -1, NULL);
  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
                                             GTK_STYLE_PROVIDER (provider),
                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  window = g_object_new (GTK_TYPE_WINDOW,
                         "title", "Slider Test",
                         "default-width", 1280,
                         "default-height", 720,
                         NULL);

  header_bar = g_object_new (GTK_TYPE_HEADER_BAR,
                             "show-close-button", TRUE,
                             "visible", TRUE,
                             NULL);
  gtk_window_set_titlebar (window, GTK_WIDGET (header_bar));

  slider = g_object_new (GB_TYPE_SLIDER,
                         "visible", TRUE,
                         NULL);
  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (slider));

  button = g_object_new (GTK_TYPE_BUTTON,
                         "label", "Toggle",
                         "visible", TRUE,
                         NULL);
  g_signal_connect (button,
                    "clicked",
                    G_CALLBACK (clicked_cb),
                    slider);
  gtk_container_add_with_properties (GTK_CONTAINER (header_bar), GTK_WIDGET (button),
                                     "pack-type", GTK_PACK_START,
                                     NULL);

  text_view = g_object_new (GTK_TYPE_TEXT_VIEW,
                            "visible", TRUE,
                            NULL);
  gtk_container_add (GTK_CONTAINER (slider), GTK_WIDGET (text_view));

  entry = g_object_new (GTK_TYPE_ENTRY,
                        "visible", TRUE,
                        NULL);
  g_signal_connect (entry, "key-press-event", G_CALLBACK (key_press), slider);
  gtk_container_add_with_properties (GTK_CONTAINER (slider), GTK_WIDGET (entry),
                                     "position", GB_SLIDER_BOTTOM,
                                     NULL);

  gtk_window_present (window);
  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
  gtk_main ();

  return 0;
}
예제 #23
0
static void
ppg_add_instrument_dialog_init (PpgAddInstrumentDialog *dialog)
{
	PpgAddInstrumentDialogPrivate *priv;
	GtkWidget *content_area;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *l;
	GtkWidget *scroller;

	priv = G_TYPE_INSTANCE_GET_PRIVATE(dialog, PPG_TYPE_ADD_INSTRUMENT_DIALOG,
	                                   PpgAddInstrumentDialogPrivate);
	dialog->priv = priv;

	g_object_set(dialog,
	             "border-width", 6,
	             "default-width", 350,
	             "default-height", 400,
#if !GTK_CHECK_VERSION(2, 91, 0)
	             "has-separator", FALSE,
#endif
	             "title", _("Add Instrument"),
	             NULL);

	content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

	vbox = g_object_new(GTK_TYPE_VBOX,
	                    "border-width", 6,
	                    "spacing", 12,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add(GTK_CONTAINER(content_area), vbox);

	l = g_object_new(GTK_TYPE_LABEL,
	                 "justify", GTK_JUSTIFY_CENTER,
	                 "label", _("Choose one or more instruments to\n"
	                            "add to your session."),
	                 "visible", TRUE,
	                 "wrap", TRUE,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), l,
	                                  "expand", FALSE,
	                                  NULL);

	hbox = g_object_new(GTK_TYPE_HBOX,
	                    "spacing", 12,
	                    "visible", TRUE,
	                    NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(vbox), hbox,
	                                  "expand", FALSE,
	                                  NULL);

	priv->entry = g_object_new(GTK_TYPE_ENTRY,
	                           "activates-default", TRUE,
	                           "visible", TRUE,
	                           NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), priv->entry,
	                                  "position", 1,
	                                  NULL);
	g_signal_connect(priv->entry,
	                 "changed",
	                 G_CALLBACK(ppg_add_instrument_dialog_entry_changed),
	                 dialog);

	l = g_object_new(GTK_TYPE_LABEL,
	                 "label", _("_Search:"),
	                 "mnemonic-widget", priv->entry,
	                 "use-underline", TRUE,
	                 "visible", TRUE,
	                 NULL);
	gtk_container_add_with_properties(GTK_CONTAINER(hbox), l,
	                                  "expand", FALSE,
	                                  "position", 0,
	                                  NULL);

	scroller = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
	                        "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
	                        "shadow-type", GTK_SHADOW_IN,
	                        "visible", TRUE,
	                        "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
	                        NULL);
	gtk_container_add(GTK_CONTAINER(vbox), scroller);

	priv->model = ppg_instruments_store_new();
	priv->filter = g_object_new(GTK_TYPE_TREE_MODEL_FILTER,
	                            "child-model", priv->model,
	                            NULL);
	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(priv->filter),
	                                       ppg_add_instrument_dialog_filter_func,
	                                       dialog, NULL);

	priv->icon_view = g_object_new(GTK_TYPE_ICON_VIEW,
	                               "model", priv->filter,
	                               "pixbuf-column", PPG_INSTRUMENTS_STORE_COLUMN_PIXBUF,
	                               "visible", TRUE,
	                               "text-column", PPG_INSTRUMENTS_STORE_COLUMN_TITLE,
	                               NULL);
	gtk_container_add(GTK_CONTAINER(scroller), priv->icon_view);
	g_signal_connect(priv->icon_view,
	                 "selection-changed",
	                 G_CALLBACK(ppg_add_instrument_dialog_selection_changed),
	                 dialog);
	g_signal_connect(priv->icon_view,
	                 "item-activated",
	                 G_CALLBACK(ppg_add_instrument_dialog_item_activated),
	                 dialog);

	gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE,
	                      GTK_RESPONSE_CLOSE);
	priv->add_button = gtk_dialog_add_button(GTK_DIALOG(dialog),
	                                         GTK_STOCK_ADD,
	                                         GTK_RESPONSE_OK);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

	g_object_set(priv->add_button, "sensitive", FALSE, NULL);

	g_signal_connect(dialog,
	                 "response",
	                 G_CALLBACK(ppg_add_instrument_dialog_response),
	                 NULL);
}
예제 #24
0
/**
 * gb_view_source_init:
 * @: (in): A #GbViewSource.
 *
 * Initializes the newly created #GbViewSource instance.
 */
static void
gb_view_source_init (GbViewSource *source)
{
    GbViewSourcePrivate *priv;
    GtkWidget *overlay;

    ENTRY;

    source->priv = priv =
                       G_TYPE_INSTANCE_GET_PRIVATE(source,
                               GB_TYPE_VIEW_SOURCE,
                               GbViewSourcePrivate);

    g_object_set(source,
                 "icon-name", GTK_STOCK_FILE,
                 "name", _("Unsaved Document"),
                 NULL);

    priv->buffer = gtk_source_buffer_new(NULL);
    g_signal_connect_swapped(priv->buffer,
                             "notify::cursor-position",
                             G_CALLBACK(gb_view_source_notify_cursor),
                             source);
    g_signal_connect_swapped(priv->buffer, "modified-changed",
                             G_CALLBACK(gb_view_source_buffer_modified_changed),
                             source);

    overlay = g_object_new(GTK_TYPE_OVERLAY,
                           "visible", TRUE,
                           NULL);
    g_signal_connect(overlay, "get-child-position",
                     G_CALLBACK(gb_view_source_position_progress),
                     NULL);
    gtk_container_add_with_properties(GTK_CONTAINER(source), overlay,
                                      "left-attach", 0,
                                      "width", 1,
                                      "top-attach", 0,
                                      "height", 1,
                                      NULL);

    priv->vpaned = g_object_new(GTK_TYPE_VPANED,
                                "visible", TRUE,
                                NULL);
    gtk_container_add(GTK_CONTAINER(overlay), priv->vpaned);

    priv->progress = g_object_new(GB_TYPE_PROGRESS_BAR,
                                  "visible", FALSE,
                                  NULL);
    gtk_overlay_add_overlay(GTK_OVERLAY(overlay), priv->progress);

    priv->scroller1 = g_object_new(gb_get_scrolled_window_gtype(),
                                   "expand", TRUE,
                                   "visible", TRUE,
                                   NULL);
    gtk_container_add_with_properties(GTK_CONTAINER(priv->vpaned), priv->scroller1,
                                      "shrink", FALSE,
                                      "resize", TRUE,
                                      NULL);

    priv->source1 = gb_view_source_create_source_view(source);
    gtk_container_add(GTK_CONTAINER(priv->scroller1), priv->source1);

    {
        GtkSourceLanguageManager *langs = gtk_source_language_manager_get_default();
        const gchar * const * ids = gtk_source_language_manager_get_language_ids(langs);
        GtkSourceLanguage *lang;
        const gchar *section;
        GHashTable *section_menu;
        GPtrArray *sorted;
        GtkWidget *controls = gb_view_get_controls(GB_VIEW(source));
        GtkWidget *menu;
        GtkWidget *mitem;
        GtkWidget *submenu;
        guint i;

        section_menu = g_hash_table_new(g_str_hash, g_str_equal);
        menu = gtk_menu_new();

        sorted = g_ptr_array_new();
        for (i = 0; ids[i]; i++) {
            lang = gtk_source_language_manager_get_language(langs, ids[i]);
            g_ptr_array_add(sorted, lang);
        }
        g_ptr_array_sort(sorted, lang_sort_func);
        for (i = 0; i < sorted->len; i++) {
            lang = g_ptr_array_index(sorted, i);
            section = gtk_source_language_get_section(lang);
            if (!(submenu = g_hash_table_lookup(section_menu, section))) {
                submenu = gtk_menu_new();
                mitem = g_object_new(GTK_TYPE_MENU_ITEM,
                                     "label", section,
                                     "submenu", submenu,
                                     "visible", TRUE,
                                     NULL);
                gtk_container_add(GTK_CONTAINER(menu), mitem);
                g_hash_table_insert(section_menu, (gchar*)section, submenu);
            }
            mitem = g_object_new(GTK_TYPE_MENU_ITEM,
                                 "label", gtk_source_language_get_name(lang),
                                 "visible", TRUE,
                                 NULL);
            g_signal_connect_swapped(mitem, "activate",
                                     G_CALLBACK(gb_view_source_lang_activate),
                                     source);
            g_object_set_data(G_OBJECT(mitem), "language-id",
                              (gchar *)gtk_source_language_get_id(lang));
            gtk_container_add(GTK_CONTAINER(submenu), mitem);
        }
        g_ptr_array_free(sorted, TRUE);

        priv->lang_combo = g_object_new(GB_TYPE_MENU_BUTTON,
                                        "hexpand", FALSE,
                                        "label", "",
                                        "menu", menu,
                                        "tooltip-text", _("Set source language."),
                                        "visible", TRUE,
                                        NULL);
        gb_widget_shrink_font(
            gb_menu_button_get_label_widget(
                GB_MENU_BUTTON(priv->lang_combo)));

        gtk_style_context_add_class(gtk_widget_get_style_context(priv->lang_combo),
                                    GB_STYLE_CLASS_TOP_BAR);
        gtk_container_add_with_properties(GTK_CONTAINER(controls), priv->lang_combo,
                                          "expand", FALSE,
                                          NULL);

        g_hash_table_unref(section_menu);
    }

    {
        GtkWidget *controls = gb_view_get_controls(GB_VIEW(source));
        GtkWidget *b;
        GtkWidget *item;
        GtkWidget *menu;
        GtkWidget *group = NULL;
        gboolean active;
        gchar *str;
        int tabs[] = { 2, 3, 4, 5, 8, 0 };
        int i;

        b = g_object_new(GB_TYPE_MENU_BUTTON,
                         "hexpand", FALSE,
                         "label", "4",
                         "tooltip-text", _("Set tab-character width."),
                         "visible", TRUE,
                         "width-request", 45,
                         NULL);

        menu = gtk_menu_new();
        for (i = 0; tabs[i]; i++) {
            str = g_strdup_printf("%d", tabs[i]);
            item = g_object_new(GTK_TYPE_RADIO_MENU_ITEM,
                                "group", group,
                                "label", str,
                                "visible", TRUE,
                                NULL);
            if (!group) {
                group = item;
            }
            active = (tabs[i] == gtk_source_view_get_tab_width(
                          GTK_SOURCE_VIEW(priv->source1)));
            g_object_set(item, "active", active, NULL);
            if (active) {
                g_object_set(b, "label", str, NULL);
            }
            g_signal_connect(item, "activate",
                             G_CALLBACK(gb_view_source_tab_size_activate),
                             source);
            gtk_container_add(GTK_CONTAINER(menu), item);
            g_free(str);
        }
        g_object_set(b, "menu", menu, NULL);

        item = g_object_new(GTK_TYPE_SEPARATOR_MENU_ITEM,
                            "visible", TRUE,
                            NULL);
        gtk_container_add(GTK_CONTAINER(menu), item);

        item = g_object_new(GTK_TYPE_CHECK_MENU_ITEM,
                            "active", TRUE,
                            "label", _("Use Spaces"),
                            "visible", TRUE,
                            NULL);
        g_signal_connect(item, "toggled",
                         G_CALLBACK(gb_view_source_spaces_toggled),
                         source);
        gtk_container_add(GTK_CONTAINER(menu), item);

        gb_widget_shrink_font(gb_menu_button_get_label_widget(GB_MENU_BUTTON(b)));
        gtk_style_context_add_class(gtk_widget_get_style_context(b),
                                    GB_STYLE_CLASS_TOP_BAR);
        gtk_container_add_with_properties(GTK_CONTAINER(controls), b,
                                          "expand", FALSE,
                                          NULL);
        priv->size_combo = b;
    }

    {
        GtkWidget *controls = gb_view_get_controls(GB_VIEW(source));
        GtkWidget *img;
        GtkWidget *b;

        img = g_object_new(GTK_TYPE_IMAGE,
                           "icon-name", "gb-split",
                           "icon-size", GTK_ICON_SIZE_MENU,
                           "visible", TRUE,
                           NULL);
        b = g_object_new(GTK_TYPE_TOGGLE_BUTTON,
                         "child", img,
                         "tooltip-text", _("Split the editor into two views."),
                         "visible", TRUE,
                         NULL);
        gtk_style_context_add_class(gtk_widget_get_style_context(b),
                                    GB_STYLE_CLASS_TOP_BAR);
        gtk_container_add_with_properties(GTK_CONTAINER(controls), b,
                                          "expand", FALSE,
                                          NULL);
        g_signal_connect(b, "toggled",
                         G_CALLBACK(split_toggled),
                         source);
    }

    {
        GtkWidget *hbox;
        GtkWidget *vp;
        GtkWidget *c;

        hbox = g_object_new(GTK_TYPE_HBOX,
                            "height-request", 30,
                            "visible", TRUE,
                            NULL);
        gtk_container_add_with_properties(GTK_CONTAINER(source), hbox,
                                          "height", 1,
                                          "left-attach", 0,
                                          "top-attach", 1,
                                          "width", 1,
                                          NULL);

        gtk_container_add(GTK_CONTAINER(hbox),
                          (c = g_object_new(GTK_TYPE_COMBO_BOX,
                                            "visible", TRUE,
                                            NULL)));
        gtk_style_context_add_class(gtk_widget_get_style_context(c),
                                    GB_STYLE_CLASS_BOTTOM_BAR);

        vp = g_object_new(GTK_TYPE_VIEWPORT,
                          "visible", TRUE,
                          NULL);
        gtk_style_context_add_class(gtk_widget_get_style_context(vp),
                                    GB_STYLE_CLASS_BOTTOM_BAR);
        gtk_container_add_with_properties(GTK_CONTAINER(hbox), vp,
                                          "expand", FALSE,
                                          "fill", TRUE,
                                          NULL);

        priv->pos_label = g_object_new(GTK_TYPE_LABEL,
                                       "label", _("Line 1, Column 1"),
                                       "visible", TRUE,
                                       "xalign", 1.0f,
                                       "xpad", 6,
                                       NULL);
        gb_widget_shrink_font(priv->pos_label);
        gtk_container_add(GTK_CONTAINER(vp), priv->pos_label);
    }

    priv->theme_handler =
        g_signal_connect_swapped(gtk_settings_get_default(),
                                 "notify::gtk-application-prefer-dark-theme",
                                 G_CALLBACK(gb_view_source_update_style),
                                 source);

    EXIT;
}
예제 #25
0
static void
egg_search_bar_init (EggSearchBar *self)
{
  EggSearchBarPrivate *priv = egg_search_bar_get_instance_private (self);
  GtkStyleContext *style_context;
  GtkBox *box;

  priv->window_signals = egg_signal_group_new (GTK_TYPE_WINDOW);
  egg_signal_group_connect_object (priv->window_signals,
                                   "key-press-event",
                                   G_CALLBACK (toplevel_key_press_event_before),
                                   self,
                                   G_CONNECT_SWAPPED);
  egg_signal_group_connect_object (priv->window_signals,
                                   "key-press-event",
                                   G_CALLBACK (toplevel_key_press_event_after),
                                   self,
                                   G_CONNECT_SWAPPED | G_CONNECT_AFTER);

  priv->revealer =
    g_object_new (GTK_TYPE_REVEALER,
                  "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN,
                  "visible", TRUE,
                  NULL);
  /* outer box used for styling */
  box =
    g_object_new (GTK_TYPE_BOX,
                  "orientation", GTK_ORIENTATION_HORIZONTAL,
                  "visible", TRUE,
                  NULL);
  priv->box =
    g_object_new (GTK_TYPE_BOX,
                  "hexpand", TRUE,
                  "margin-bottom", 3,
                  "margin-end", 6,
                  "margin-start", 6,
                  "margin-top", 3,
                  "orientation", GTK_ORIENTATION_HORIZONTAL,
                  "visible", TRUE,
                  NULL);
  priv->entry =
    g_object_connect (g_object_new (GTK_TYPE_SEARCH_ENTRY,
                                    "placeholder-text", _("Search"),
                                    "visible", TRUE,
                                    NULL),
                      "swapped_object_signal::activate", egg_search_bar__entry_activate, self,
                      NULL);
  priv->close_button =
    g_object_new (GTK_TYPE_BUTTON,
                  "child", g_object_new (GTK_TYPE_IMAGE,
                                         "icon-name", "window-close-symbolic",
                                         "visible", TRUE,
                                         NULL),
                  "visible", FALSE,
                  NULL);

  style_context = gtk_widget_get_style_context (GTK_WIDGET (box));
  gtk_style_context_add_class (style_context, "search-bar");

  gtk_container_add (GTK_CONTAINER (priv->revealer), GTK_WIDGET (box));
  gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (priv->box));
  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->revealer));
  gtk_container_add_with_properties (GTK_CONTAINER (priv->box),
                                     GTK_WIDGET (priv->close_button),
                                     "fill", FALSE,
                                     "pack-type", GTK_PACK_END,
                                     NULL);
  gtk_box_set_center_widget (priv->box, GTK_WIDGET (priv->entry));
}
static void
ide_omni_search_display_add_provider (IdeOmniSearchDisplay *self,
                                      IdeSearchProvider    *provider)
{
  ProviderEntry *entry;
  guint i;

  g_return_if_fail (IDE_IS_OMNI_SEARCH_DISPLAY (self));
  g_return_if_fail (IDE_IS_SEARCH_PROVIDER (provider));

  /*
   * Make sure we don't add an item twice. Probably can assert here, but
   * warning will do for now.
   */
  for (i = 0; i < self->providers->len; i++)
    {
      ProviderEntry *ptr;

      ptr = g_ptr_array_index (self->providers, i);

      if (ptr->provider == provider)
        {
          g_warning (_("Cannot add provider more than once."));
          return;
        }
    }

  /*
   * Add the entry to our array and sort the array to determine our target
   * widget packing position.
   */
  entry = g_new0 (ProviderEntry, 1);
  entry->provider = g_object_ref (provider);
  entry->group = g_object_new (IDE_TYPE_OMNI_SEARCH_GROUP,
                               "provider", provider,
                               "visible", FALSE,
                               NULL);
  g_object_add_weak_pointer (G_OBJECT (entry->group), (gpointer *)&entry->group);
  g_signal_connect_object (entry->group,
                           "result-activated",
                           G_CALLBACK (ide_omni_search_display_result_activated),
                           self,
                           G_CONNECT_SWAPPED);
  g_signal_connect_object (entry->group,
                           "result-selected",
                           G_CALLBACK (ide_omni_search_display_result_selected),
                           self,
                           G_CONNECT_SWAPPED);
  g_ptr_array_add (self->providers, entry);
  g_ptr_array_sort (self->providers, provider_entry_sort);

  /*
   * Find the location of the entry and use the index to pack the display
   * group widget.
   */
  for (i = 0; i < self->providers->len; i++)
    {
      ProviderEntry *ptr;

      ptr = g_ptr_array_index (self->providers, i);

      if (ptr->provider == provider)
        {
          gtk_container_add_with_properties (GTK_CONTAINER (self),
                                             GTK_WIDGET (entry->group),
                                             "position", i,
                                             NULL);
          break;
        }
    }
}