Ejemplo n.º 1
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *vbox, *hbox, *button, *stack, *switcher;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
  gtk_container_add (GTK_CONTAINER (window), vbox);

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

  stack = gtk_stack_new ();
  gtk_box_pack_start (GTK_BOX (vbox), stack, TRUE, TRUE, 0);
  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Embedd");
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "clicked", G_CALLBACK (button_clicked), stack);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
Ejemplo n.º 2
0
static GtkWidget* main_window() {
  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Switcher");
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);

  GtkWidget* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
  gtk_container_add(GTK_CONTAINER(window), box);

  // Stack
  GtkWidget* main_area = gtk_stack_new();
  gtk_stack_set_transition_type(GTK_STACK(main_area),
                                GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
  gtk_stack_set_transition_duration(GTK_STACK(main_area), 2000);

  // Checkbox
  GtkWidget* check_button =
      gtk_check_button_new_with_label("Do not fn check me");
  gtk_stack_add_titled(GTK_STACK(main_area), check_button, "check_name",
                       "Check Box");

  // Label
  GtkWidget* label = gtk_label_new(NULL);
  gtk_label_set_markup(GTK_LABEL(label), "<big>OMG this text is huge!</big>");
  gtk_stack_add_titled(GTK_STACK(main_area), label, "label_name", "Big Label");

  // StackSwitcher
  GtkWidget* stack_switcher = gtk_stack_switcher_new();
  gtk_stack_switcher_set_stack(GTK_STACK_SWITCHER(stack_switcher),
                               GTK_STACK(main_area));

  gtk_box_pack_start(GTK_BOX(box), stack_switcher, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), main_area, TRUE, TRUE, 0);

  return window;
}
Ejemplo n.º 3
0
static void
photos_header_bar_init (PhotosHeaderBar *self)
{
  PhotosHeaderBarPrivate *priv;
  GtkStyleContext *context;

  self->priv = photos_header_bar_get_instance_private (self);
  priv = self->priv;

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "titlebar");

  priv->stack_switcher = g_object_ref_sink (gtk_stack_switcher_new ());
  gtk_widget_show (priv->stack_switcher);
  gtk_widget_set_no_show_all (priv->stack_switcher, TRUE);
}
Ejemplo n.º 4
0
static void
ekiga_window_init_actions_toolbar (EkigaWindow *mw)
{
  GtkWidget *image = NULL;
  GtkWidget *button = NULL;
  GtkWidget *switcher = NULL;

  g_return_if_fail (EKIGA_IS_WINDOW (mw));

  mw->priv->actions_toolbar = gtk_header_bar_new ();
  gtk_window_set_titlebar (GTK_WINDOW (mw), mw->priv->actions_toolbar);

  /* Start packing buttons */
  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("call-start-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (button),
                               _("Call the selected contact"));
  gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (button), "win.call");
  gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), button);

  mw->priv->preview_button = gtk_toggle_button_new ();
  image = gtk_image_new_from_icon_name ("camera-web-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (mw->priv->preview_button), image);
  gtk_widget_set_tooltip_text (GTK_WIDGET (mw->priv->preview_button),
                               _("Display images from your camera device"));

  gtk_actionable_set_detailed_action_name (GTK_ACTIONABLE (mw->priv->preview_button),
                                           "win.enable-preview");
  gtk_header_bar_pack_start (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->preview_button);

  switcher = gtk_stack_switcher_new ();
  gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (mw->priv->main_stack));
  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (mw->priv->actions_toolbar), switcher);
  gtk_widget_set_margin_end (GTK_WIDGET (switcher), 6);

  mw->priv->menu_button = gtk_menu_button_new ();
  g_object_set (G_OBJECT (mw->priv->menu_button), "use-popover", true, NULL);
  image = gtk_image_new_from_icon_name ("open-menu-symbolic", GTK_ICON_SIZE_MENU);
  gtk_button_set_image (GTK_BUTTON (mw->priv->menu_button), image);
  gtk_header_bar_pack_end (GTK_HEADER_BAR (mw->priv->actions_toolbar), mw->priv->menu_button);
  gtk_widget_show_all (mw->priv->actions_toolbar);

  gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (mw->priv->actions_toolbar), TRUE);
}
Ejemplo n.º 5
0
static void
ev_sidebar_init (EvSidebar *ev_sidebar)
{
	EvSidebarPrivate *priv;
	GtkWidget *switcher;
	GtkWidget *stack;

	priv = GET_PRIVATE (ev_sidebar);

	/* data model */
	priv->page_model = (GtkTreeModel *)
			gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
					    G_TYPE_STRING,
					    GTK_TYPE_WIDGET,
					    G_TYPE_STRING,
					    G_TYPE_STRING);

	switcher = gtk_stack_switcher_new ();
	priv->switcher = switcher;
	gtk_box_pack_end (GTK_BOX (ev_sidebar), switcher, FALSE, TRUE, 0);
	g_object_set (switcher, "icon-size", 1, NULL);
	gtk_container_set_border_width (GTK_CONTAINER (switcher), 6);
	gtk_widget_set_halign (switcher, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (switcher, TRUE);
	gtk_box_set_homogeneous (GTK_BOX (switcher), TRUE);
	gtk_widget_show (priv->switcher);

	stack = gtk_stack_new ();
	priv->stack = stack;
	gtk_stack_set_homogeneous (GTK_STACK (stack), TRUE);
	gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher),
				      GTK_STACK (stack));
	gtk_box_pack_end (GTK_BOX (ev_sidebar), stack, TRUE, TRUE, 0);
	gtk_widget_show (priv->stack);

	g_signal_connect (stack, "notify::visible-child",
			  G_CALLBACK (ev_sidebar_child_change_cb),
			  ev_sidebar);
}
/* 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;

}
Ejemplo n.º 7
0
static GtkWidget*
create_starter_widget (StarterPlugin* plugin)
{
	GError *error;
	GtkWidget *stack;
	GtkWidget *switcher;
	GtkWidget *starter_box;
	GtkWidget *switcher_box;
	GtkWidget *actions_frame;
	GtkWidget *actions_listbox;
	GtkWidget *recent_projects_box;
	GtkWidget *recent_listbox;
	GtkBuilder *builder;
	GtkWidget *button;
	
	error = NULL;
	builder = gtk_builder_new ();

	if (!gtk_builder_add_from_resource (builder, "/org/gnome/anjuta/ui/starter.ui", &error))
	{
		DEBUG_PRINT ("Could not load starter.ui! %s", error->message);
		g_error_free (error);
	}
	else
	{
		/* Manually assembling stack and switcher because they are not available in glade yet */
		switcher = gtk_stack_switcher_new ();
		stack = gtk_stack_new ();
		gtk_stack_switcher_set_stack (switcher, stack);
		gtk_stack_set_transition_type (stack, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
		gtk_stack_set_transition_duration (stack, TRANSITION_TIME);

		starter_box = GTK_WIDGET (gtk_builder_get_object (builder, STARTER_BOX));
		switcher_box = GTK_WIDGET (gtk_builder_get_object (builder, SWITCHER_BOX));
		gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (starter_box)), starter_box);
		g_object_ref (starter_box);
		gtk_box_pack_start (switcher_box, switcher, FALSE, FALSE, 0);
		gtk_box_pack_start (starter_box, stack, FALSE, FALSE, 0);
		gtk_widget_show_all (starter_box);

		actions_listbox = GTK_WIDGET (gtk_builder_get_object (builder, ACTIONS_LISTBOX));
		gtk_list_box_set_header_func (GTK_LIST_BOX (actions_listbox), add_action_separators, NULL, NULL);
		actions_frame = GTK_WIDGET (gtk_builder_get_object (builder, ACTIONS_FRAME));
		gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (actions_frame)), actions_frame);
		g_object_ref (actions_frame);
		gtk_stack_add_titled (stack, actions_frame, ACTIONS_ID, "Actions");

		recent_projects_box = GTK_WIDGET (gtk_builder_get_object (builder, RECENT_PROJECTS_BOX));
		gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (recent_projects_box)), recent_projects_box);
		g_object_ref (recent_projects_box);

		recent_listbox = GTK_WIDGET (gtk_builder_get_object (builder, RECENT_LISTBOX));
		refresh_recent_project_view (GTK_LIST_BOX (recent_listbox));

		gtk_stack_add_titled (stack, recent_projects_box, RECENT_PROJECTS_ID, "Recent Projects");

		button = GTK_WIDGET (gtk_builder_get_object (builder, REMOVE_PROJECT_BUTTON));
		g_signal_connect_object (G_OBJECT (button), "clicked",
			G_CALLBACK (on_remove_project_clicked), recent_listbox, G_CONNECT_AFTER);

		gtk_builder_connect_signals (builder, plugin);
	}
	g_object_unref (builder);
	return starter_box;
}
Ejemplo n.º 8
0
Archivo: start.c Proyecto: y20k/ezeedo
/**
 * Creates empty main application window
 */
GtkWidget
*create_mainwindow (ezeedo_wrapper_structure *ezeedo)
{
    // define widgets
    GtkWidget *window;
    GtkWidget *headerbar;
    GtkWidget *windowmenu_button;
    GtkWidget *stack;
    GtkWidget *stackswitcher;

    GtkWidget *todo_stack;
    GtkWidget *todo_paned;
    GtkWidget *todolist_scrollbox;
    GtkWidget *todolist_box;
    GtkWidget *categories_scrollbox;
    GtkWidget *categories_box;
    GtkWidget *task_entry;

    GtkWidget *done_stack;
    GtkWidget *donelist_scrollbox;
    GtkWidget *donelist_box;

    GtkWidget *archive_button;

    // define action
    GSimpleAction *about_action;

    // get window size and position from gsettings store
    GSettings     *settings;
    gint width;
    gint height;
    gint x;
    gint y;
    gint sidebar_size;

    settings     = g_settings_new     ("org.y20k.ezeedo");
    width        = g_settings_get_int (settings,
                                       "main-window-width");
    height       = g_settings_get_int (settings,
                                       "main-window-height");
    x            = g_settings_get_int (settings,
                                       "main-window-position-y");
    y            = g_settings_get_int (settings,
                                       "main-window-position-y");
    sidebar_size = g_settings_get_int (settings,
                                       "sidebar-size");
    g_object_unref (settings);

    // create main window with title and default size
    window = gtk_application_window_new (ezeedo->application);
    gtk_window_set_title        (GTK_WINDOW (window),
                                 "Ezeedo");
    gtk_window_set_icon_name    (GTK_WINDOW (window),
                                 EZEEDOICON);
    gtk_window_set_default_size (GTK_WINDOW (window),
                                 width,
                                 height);
    gtk_window_move             (GTK_WINDOW (window),
                                 x,
                                 y);

    // create headerbar and stack switcher
    headerbar       = gtk_header_bar_new ();
    gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(headerbar),
                                          true);
    stackswitcher   = gtk_stack_switcher_new ();

    // create stack for todo and done
    stack = gtk_stack_new ();

    // create stack for todolist
    todo_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                              0);

    // create paned container for left and right columns of todo tab
    todo_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
    gtk_paned_set_position (GTK_PANED(todo_paned),
                            sidebar_size);

    // create categories scrollbox and box for left pane
    categories_scrollbox = gtk_scrolled_window_new (NULL,
                                                    NULL);
    categories_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                  0);

    // create todolist scrollbox and box for right pane
    todolist_scrollbox = gtk_scrolled_window_new (NULL,
                                                  NULL);
    todolist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                0);

    // create task entry
    task_entry = gtk_entry_new ();
    gtk_widget_set_margin_start       (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_end         (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_top         (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_bottom      (GTK_WIDGET(task_entry),
                                       10);
    gtk_entry_set_placeholder_text    (GTK_ENTRY(task_entry),
                                       "Enter new task");
    gtk_entry_set_max_length          (GTK_ENTRY(task_entry),
                                       TASKLENGTH);
    gtk_widget_grab_focus (task_entry);
 
    // create stack for donelist
    done_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                  0);

    // create donelist scrollbox and box
    donelist_scrollbox = gtk_scrolled_window_new (NULL,
                                                  NULL);
    donelist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                0);

    // create archive button
    archive_button = gtk_button_new_with_label ("Archive all done tasks");
    gtk_widget_set_margin_start  (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_end    (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_top    (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_bottom (GTK_WIDGET (archive_button),
                                  10);

    // add some widgets to ezeedo wrapper structure
    ezeedo->window = window;
    ezeedo->todo_paned = todo_paned;
    ezeedo->categories_box = categories_box;
    ezeedo->todolist_box = todolist_box;
    ezeedo->donelist_box = donelist_box;

    // create window menu
    windowmenu_button = create_windowmenu (ezeedo);

    // create about action and connect about action signal
    about_action = g_simple_action_new ("about",
                                        NULL); 
    g_action_map_add_action (G_ACTION_MAP (window),
                             G_ACTION (about_action));
    g_signal_connect (about_action, "activate",
                      G_CALLBACK (show_about_window), window);

    // detect entry signal
    g_signal_connect (task_entry, "activate",
                      G_CALLBACK (add_task_entry), ezeedo);

    // detect archive button pressed
    g_signal_connect (archive_button, "clicked",
                      G_CALLBACK (display_info_dialog), "Task archival is not supported yet.");
 
    // detect window close
    g_signal_connect (G_OBJECT (window), "delete-event",
                      G_CALLBACK (close_window), ezeedo);


    // construct headerbar for main window
    gtk_window_set_titlebar   (GTK_WINDOW(window),
                               headerbar);
    gtk_header_bar_pack_start (GTK_HEADER_BAR(headerbar),
                               stackswitcher);
    gtk_header_bar_pack_end   (GTK_HEADER_BAR(headerbar),
                               windowmenu_button);

    // add stack to main window
    gtk_container_add (GTK_CONTAINER(window),
                       stack);

    // set stack switcher and populate stack with todolist and donelist
    gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(stackswitcher),
                                  GTK_STACK(stack));
    gtk_stack_add_titled         (GTK_STACK(stack),
                                  todo_stack,
                                  "To do",
                                  "To do");
    gtk_stack_add_titled         (GTK_STACK(stack),
                                  done_stack,
                                  "Done",
                                  "Done");

    // construct main todo stack
    gtk_container_add (GTK_CONTAINER(todo_stack),
                       todo_paned);

    gtk_paned_add1   (GTK_PANED(todo_paned),
                      categories_scrollbox);
    gtk_paned_add2   (GTK_PANED(todo_paned),
                      todolist_scrollbox);

    // add box to scrollable box
    gtk_container_add (GTK_CONTAINER(todolist_scrollbox),
                       todolist_box);

    // add task entry to todo stack
    gtk_container_add (GTK_CONTAINER(todo_stack),
                       task_entry);

    // add box to scrollable box
    gtk_container_add (GTK_CONTAINER(categories_scrollbox),
                       categories_box);

    // construct main donelist stack
    gtk_container_add (GTK_CONTAINER(done_stack),
                       donelist_scrollbox);
    gtk_container_add (GTK_CONTAINER(donelist_scrollbox),
                       donelist_box);

    return (window); 
}
Ejemplo n.º 9
0
PocketvoxSetup* pocketvox_setup_new()
{
	PocketvoxSetup *setup = (PocketvoxSetup *)g_object_new(TYPE_POCKETVOX_SETUP, NULL);

	setup->priv = G_TYPE_INSTANCE_GET_PRIVATE (setup,
			TYPE_POCKETVOX_SETUP, PocketvoxSetupPrivate);
	PocketvoxSetupPrivate *priv = setup->priv;

	bindtextdomain (GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);

	priv->settings = g_settings_new("org.pocketvox.config");

    //Build the window
    priv->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(priv->window), GTK_WIN_POS_CENTER_ALWAYS);
    gtk_window_set_title(GTK_WINDOW(priv->window), "pocketvox-gtk");
    gtk_window_set_default_size(GTK_WINDOW(priv->window), 500, 350);
    gtk_window_set_icon_name(GTK_WINDOW(priv->window), "pocketvox");
    gtk_container_set_border_width(GTK_CONTAINER(priv->window), 5);

	g_signal_connect_swapped(priv->window, "delete-event", G_CALLBACK(pocketvox_setup_save_and_quit), setup);

    GtkWidget *bar = gtk_header_bar_new();
    gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(bar), TRUE);
    gtk_window_set_titlebar(GTK_WINDOW(priv->window), bar);

    //add a vertical box
    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
    gtk_container_add(GTK_CONTAINER(priv->window), box);

    //a button for all
    GtkWidget* button_notification 	= gtk_button_new_with_label(_("Notifications"));
    GtkWidget* button_user 			= gtk_button_new_with_label(_("Users"));
    GtkWidget* button_pocketsphinx 	= gtk_button_new_with_label(_("Pocketsphinx"));
    GtkWidget* button_gstreamer		= gtk_button_new_with_label(_("Gstreamer"));

    gtk_widget_set_tooltip_text(button_notification, _("Display notifications parameters"));
    gtk_widget_set_tooltip_text(button_user, _("Display user parameters"));
    gtk_widget_set_tooltip_text(button_pocketsphinx, _("Display pocketsphinx parameters"));
    gtk_widget_set_tooltip_text(button_gstreamer, _("Display gstreamer parameters"));

    gtk_button_set_relief(GTK_BUTTON(button_notification), 	GTK_RELIEF_NONE);
    gtk_button_set_relief(GTK_BUTTON(button_user), 			GTK_RELIEF_NONE);
    gtk_button_set_relief(GTK_BUTTON(button_pocketsphinx), 	GTK_RELIEF_NONE);
    gtk_button_set_relief(GTK_BUTTON(button_gstreamer), 	GTK_RELIEF_NONE);

    GtkWidget *grid_button	= gtk_grid_new();
    gtk_grid_attach(GTK_GRID(grid_button), button_user, 		0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(grid_button), button_notification, 0, 1, 1, 1);
    gtk_grid_attach(GTK_GRID(grid_button), button_pocketsphinx, 0, 2, 1, 1);
    gtk_grid_attach(GTK_GRID(grid_button), button_gstreamer,	0, 3, 1, 1);

    GtkWidget* grid_notification 	= pocketvox_setup_get_notification_grid(setup);
    GtkWidget* grid_user			= pocketvox_setup_get_user_grid(setup);
    GtkWidget* grid_pocketsphinx	= pocketvox_setup_get_pocketsphinx_grid(setup);
    GtkWidget* grid_gstreamer		= pocketvox_setup_get_gstreamer_grid(setup);

    //connect all signals (TODO)
    g_signal_connect_swapped(button_notification, "clicked", G_CALLBACK(gtk_widget_show), grid_notification);
    g_signal_connect_swapped(button_notification, "clicked", G_CALLBACK(gtk_widget_hide), grid_user);
    g_signal_connect_swapped(button_notification, "clicked", G_CALLBACK(gtk_widget_hide),  grid_pocketsphinx);
    g_signal_connect_swapped(button_notification, "clicked", G_CALLBACK(gtk_widget_hide), grid_gstreamer);

    g_signal_connect_swapped(button_pocketsphinx, "clicked", G_CALLBACK(gtk_widget_hide), grid_notification);
    g_signal_connect_swapped(button_pocketsphinx, "clicked", G_CALLBACK(gtk_widget_hide), grid_user);
    g_signal_connect_swapped(button_pocketsphinx, "clicked", G_CALLBACK(gtk_widget_show),  grid_pocketsphinx);
    g_signal_connect_swapped(button_pocketsphinx, "clicked", G_CALLBACK(gtk_widget_hide), grid_gstreamer);

    g_signal_connect_swapped(button_user, "clicked", G_CALLBACK(gtk_widget_hide), grid_notification);
    g_signal_connect_swapped(button_user, "clicked", G_CALLBACK(gtk_widget_show), grid_user);
    g_signal_connect_swapped(button_user, "clicked", G_CALLBACK(gtk_widget_hide),  grid_pocketsphinx);
    g_signal_connect_swapped(button_user, "clicked", G_CALLBACK(gtk_widget_hide), grid_gstreamer);

    g_signal_connect_swapped(button_gstreamer, "clicked", G_CALLBACK(gtk_widget_hide), grid_notification);
    g_signal_connect_swapped(button_gstreamer, "clicked", G_CALLBACK(gtk_widget_hide), grid_user);
    g_signal_connect_swapped(button_gstreamer, "clicked", G_CALLBACK(gtk_widget_hide),  grid_pocketsphinx);
    g_signal_connect_swapped(button_gstreamer, "clicked", G_CALLBACK(gtk_widget_show), grid_gstreamer);

    //add
    GtkWidget* gridBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_pack_start(GTK_BOX(gridBox), grid_user, 		TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(gridBox), grid_notification, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(gridBox), grid_pocketsphinx, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(gridBox), grid_gstreamer, 	TRUE, TRUE, 0);

    GtkWidget* separator =  gtk_separator_new(GTK_ORIENTATION_VERTICAL);
    gtk_widget_show(separator);

    GtkWidget *hgridBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start(GTK_BOX(hgridBox), grid_button, 	FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(hgridBox), separator, 	FALSE, FALSE, 5);
    gtk_box_pack_start(GTK_BOX(hgridBox), gridBox, 		TRUE, TRUE, 0);

    GtkWidget *stack = gtk_stack_new();
    gtk_stack_set_transition_type(GTK_STACK(stack) , GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
    gtk_stack_set_transition_duration(GTK_STACK(stack), 1000);

    gtk_stack_add_titled(GTK_STACK(stack), hgridBox, "Setup", _("Configuration"));

	GtkWidget* scrolledWindow  = gtk_scrolled_window_new(NULL, NULL);

    //return void
    pocketvox_setup_get_modules_grid(setup);
    gtk_container_add(GTK_CONTAINER(scrolledWindow), priv->listBox);
    gtk_widget_show_all(scrolledWindow);

    gtk_stack_add_titled(GTK_STACK(stack), scrolledWindow, "Modules", _("Modules"));

    //adding a task switcher
    GtkWidget* stackSwitcher = gtk_stack_switcher_new();
    gtk_stack_switcher_set_stack(GTK_STACK_SWITCHER(stackSwitcher), GTK_STACK(stack));

    gtk_header_bar_set_custom_title(GTK_HEADER_BAR(bar), stackSwitcher);

	GtkWidget *add_module_button 	= gtk_button_new_from_icon_name("gtk-new", GTK_ICON_SIZE_MENU);
	GtkWidget *remove_module_button = gtk_button_new_from_icon_name("gtk-delete", GTK_ICON_SIZE_MENU);
	gtk_button_set_relief(GTK_BUTTON(add_module_button), GTK_RELIEF_NONE);
	gtk_button_set_relief(GTK_BUTTON(remove_module_button), GTK_RELIEF_NONE);

	gtk_header_bar_pack_start(GTK_HEADER_BAR(bar), add_module_button);
	gtk_header_bar_pack_start(GTK_HEADER_BAR(bar), remove_module_button);

	g_signal_connect_swapped(remove_module_button, 	"clicked", 					G_CALLBACK(pocketvox_setup_remove_module), 			setup);
	g_signal_connect_swapped(add_module_button, 	"clicked", 					G_CALLBACK(pocketvox_setup_add_module_callback),    setup);
	g_signal_connect_swapped(stack, 				"notify::visible-child", 	G_CALLBACK(pocketvox_stack_child_changed), 			add_module_button);
	g_signal_connect_swapped(stack, 				"notify::visible-child", 	G_CALLBACK(pocketvox_stack_child_changed), 			remove_module_button);

    //add them to the vbox
    gtk_box_pack_start(GTK_BOX(box), stack, TRUE, TRUE, 0);

    gtk_widget_show(grid_user);
    gtk_widget_hide(grid_notification);
    gtk_widget_hide(grid_pocketsphinx);
    gtk_widget_hide(grid_gstreamer);
    gtk_widget_show(gridBox);

    gtk_widget_show_all(grid_button);
    gtk_widget_show(hgridBox);
    gtk_widget_show(box);
	gtk_widget_show(stack);
	gtk_widget_show(stackSwitcher);
	gtk_widget_show_all(bar);

    //get the setup
	return setup;
}
Ejemplo n.º 10
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;
}