static void
terminal_screen_container_set_placement_internal (TerminalScreenContainer *container,
        GtkCornerType corner)
{
	TerminalScreenContainerPrivate *priv = container->priv;

#ifdef USE_SCROLLED_WINDOW
	gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (priv->scrolled_window), corner);
#else
	switch (corner)
	{
	case GTK_CORNER_TOP_LEFT:
	case GTK_CORNER_BOTTOM_LEFT:
		gtk_box_reorder_child (GTK_BOX (priv->hbox), priv->vscrollbar, 1);
		break;
	case GTK_CORNER_TOP_RIGHT:
	case GTK_CORNER_BOTTOM_RIGHT:
		gtk_box_reorder_child (GTK_BOX (priv->hbox), priv->vscrollbar, 0);
		break;
	default:
		g_assert_not_reached ();
	}
#endif

	priv->window_placement = corner;
	g_object_notify (G_OBJECT (container), "window-placement");
}
static VALUE
rg_set_placement(VALUE self, VALUE corner_type)
{
    gtk_scrolled_window_set_placement(_SELF(self), 
                                      RVAL2GTKCORNERTYPE(corner_type));
    return self;
}
Exemple #3
0
/* Determines the location of the child widget with respect to the scrollbars.
 * The default is GTK_CORNER_TOP_LEFT, meaning the child is in the top left,
 * with the scrollbars underneath and to the right. Other values in GtkCornerType are
 * GTK_CORNER_TOP_RIGHT, GTK_CORNER_BOTTOM_LEFT, and GTK_CORNER_BOTTOM_RIGHT. */
int
clip_GTK_SCROLLEDWINDOWSETPLACEMENT (ClipMachine *cm)
{
    C_widget *csw = _fetch_cw_arg(cm);
    int placement = _clip_parni(cm,2);
    CHECKOPT(2,NUMERIC_t);
    CHECKCWID(csw,GTK_IS_SCROLLED_WINDOW);
    gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW(csw->widget), placement);
    return 0;
err:
    return 1;
}
Exemple #4
0
void ChatArea(GtkWidget *vbox)
{
  GtkWidget *hbox;
  GtkWidget *frame, *scroll, *view, *label, *msg;
  GtkAdjustment *adjustment; /* Uso interno de ajuste de scroll */

  frame  = gtk_frame_new("Chat");
  scroll = gtk_scrolled_window_new(NULL,NULL);
  view   = gtk_text_view_new();  
  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
  label  = gtk_label_new("Mensaje");
  hbox   = gtk_hbox_new(FALSE,2),
  msg    = gtk_entry_new();

  gtk_box_pack_start(GTK_BOX(vbox), frame,FALSE,FALSE,2);
  gtk_container_add(GTK_CONTAINER(frame), scroll);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll),view);
  gtk_box_pack_end(GTK_BOX(vbox), hbox,FALSE,FALSE,2);
  gtk_box_pack_start(GTK_BOX(hbox), label,FALSE,FALSE,2);
  gtk_box_pack_end(GTK_BOX(hbox), msg,FALSE,FALSE,2);

  gtk_widget_set_size_request(msg,600,-1);
  gtk_text_view_set_editable(GTK_TEXT_VIEW(view),FALSE);
  gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view),GTK_WRAP_WORD_CHAR);
  gtk_widget_set_size_request(scroll,600,330);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll),GTK_CORNER_BOTTOM_LEFT);
  adjustment = (GtkAdjustment *) gtk_adjustment_new(0.,0., 396.,18.,183.,396.);
  gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW(scroll),adjustment);

  gtk_text_buffer_create_tag(buffer, "lmarg", "left_margin", 5, NULL);
  gtk_text_buffer_create_tag(buffer, "red_fg","foreground", "red", NULL); 
  gtk_text_buffer_create_tag(buffer, "blue_fg","foreground", "blue", NULL); 
  gtk_text_buffer_create_tag(buffer, "magenta_fg","foreground", "#FF00FF", NULL);
  gtk_text_buffer_create_tag(buffer, "black_bg","background", "black", NULL);
  gtk_text_buffer_create_tag(buffer, "green_fg","foreground", "#00BB00", NULL); 
  gtk_text_buffer_create_tag(buffer, "italic", "style", PANGO_STYLE_ITALIC, NULL);
  gtk_text_buffer_create_tag(buffer, "bold", "weight", PANGO_WEIGHT_BOLD, NULL);

  gtk_text_buffer_get_iter_at_offset(buffer, &iter, 0);

  g_signal_connect(G_OBJECT(msg), "activate", G_CALLBACK(readMessageCB), NULL);
  g_signal_connect(G_OBJECT(scroll), "size-allocate", G_CALLBACK(scrolling), NULL);
}
Exemple #5
0
GtkWidget *
create_file_view(FileView *view)
{
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *menu_bar;
  GtkWidget *button;
  GtkWidget *pixmapwid;
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle *style;
  GdkFont *font;
  GtkWidget *sw;
  gint i;

  /* Top Pane */
  vbox = gtk_vbox_new(FALSE, 0);
  gtk_widget_show(vbox);

  menu_bar = create_filelist_menu_bar(view);
  gtk_widget_show(menu_bar);
  gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0);

  hbox = gtk_hbox_new(FALSE, 0);
  gtk_widget_show(hbox);

  /* Show/Hide Button */
  if (view == &app.right_view)
    button = gtk_button_new_with_label("<");
  else
    button = gtk_button_new_with_label(">");
  GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
  gtk_signal_connect(GTK_OBJECT(button), "button_press_event", 
                    GTK_SIGNAL_FUNC(show_hide_file_view_cb), view);
  gtk_tooltips_set_tip(GTK_TOOLTIPS(app.tooltips), button,
                       _("Left Click: Maximize/Minimize File View\n"
                         "Right Click: Sync Dirs"), NULL);
  gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
  gtk_widget_show(button);

  /* Hidden files toggle button */
  view->hidden_toggle = gtk_toggle_button_new_with_label("H");
  GTK_WIDGET_UNSET_FLAGS(view->hidden_toggle, GTK_CAN_FOCUS);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(view->hidden_toggle),
                               view->show_hidden);
  gtk_signal_connect(GTK_OBJECT(view->hidden_toggle), "toggled",
                     GTK_SIGNAL_FUNC(toggle_show_hidden_cb), view);
  gtk_tooltips_set_tip(GTK_TOOLTIPS(app.tooltips), view->hidden_toggle,
                       _("Show/Hide hidden files"), NULL);
  gtk_box_pack_start(GTK_BOX(hbox), view->hidden_toggle, FALSE, FALSE, 0);
  gtk_widget_show(view->hidden_toggle);

  /* Dir Entry Combo */
  view->dir_entry = gtk_combo_new();
  gtk_combo_disable_activate(GTK_COMBO(view->dir_entry));
  gtk_combo_set_use_arrows_always(GTK_COMBO(view->dir_entry), TRUE);
  gtk_combo_set_case_sensitive(GTK_COMBO(view->dir_entry), TRUE);
  gtk_signal_connect(GTK_OBJECT(GTK_COMBO(view->dir_entry)->entry), 
              "activate", GTK_SIGNAL_FUNC(dir_entry_cb), view);
  gtk_signal_connect(GTK_OBJECT(GTK_COMBO(view->dir_entry)->popwin),
              "hide", GTK_SIGNAL_FUNC(dir_popwin_cb), view);
  gtk_box_pack_start(GTK_BOX(hbox), view->dir_entry, TRUE, TRUE, 0);
  gtk_widget_show(view->dir_entry);

  /* Up Dir Button */
  button = gtk_button_new();
  GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
  gtk_signal_connect(GTK_OBJECT(button), "button_press_event",
                     GTK_SIGNAL_FUNC(updir_click_cb), view);
  gtk_tooltips_set_tip(GTK_TOOLTIPS(app.tooltips), button,
                       _("Left Click: Up Dir   Right Click: Home"), NULL);
  gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
  gtk_widget_show(button);

  style = gtk_widget_get_style(app.main_window);
  pixmap = gdk_pixmap_create_from_xpm_d(app.main_window->window, &mask, 
                                        &style->bg[GTK_STATE_NORMAL], 
                                        icon_dirparent_xpm);
  pixmapwid = gtk_pixmap_new(pixmap, mask);
  gtk_container_add(GTK_CONTAINER(button), pixmapwid);
  gtk_widget_show(pixmapwid);

  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

  sw = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
          GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(sw), cfg.scrollbar_pos);
  gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
  gtk_widget_show(sw);

  /* File List */
  view->clist = gtk_clist_new(MAX_COLUMNS);
  for (i = 0; i < MAX_COLUMNS; i++)
  {
    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
    GtkWidget *label = gtk_label_new(all_columns[i].title);

    view->sort_arrows[i] = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
    gtk_box_pack_end(GTK_BOX(hbox), view->sort_arrows[i], FALSE, TRUE, 0);

    gtk_widget_show(label);
    gtk_widget_show(hbox);
    gtk_clist_set_column_widget(GTK_CLIST(view->clist), i, hbox);
    GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(view->clist)->column[i].button,
                           GTK_CAN_FOCUS);
  } 
  gtk_clist_column_titles_show(GTK_CLIST(view->clist));
  gtk_clist_set_shadow_type(GTK_CLIST(view->clist), GTK_SHADOW_ETCHED_IN);
  gtk_clist_set_selection_mode(GTK_CLIST(view->clist), GTK_SELECTION_EXTENDED);
  gtk_clist_set_use_drag_icons(GTK_CLIST(view->clist), TRUE);
  gtk_clist_set_row_height(GTK_CLIST(view->clist), 0);
  
  font = gdk_font_load(cfg.list_font);
  if (font != NULL)
  {
    style = gtk_style_copy(gtk_widget_get_style(view->clist));
    style->font = font;
    gtk_widget_set_style(view->clist, style);
  }

  for (i = 0; i < MAX_COLUMNS; i++)
  {
    gtk_clist_set_column_width(GTK_CLIST(view->clist), i, all_columns[i].size);
    gtk_clist_set_column_visibility(GTK_CLIST(view->clist), i,
                                    all_columns[i].is_visible);
  }

  gtk_signal_connect(GTK_OBJECT(view->clist), "select_row",
                     GTK_SIGNAL_FUNC(select_row_cb), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "button_press_event",
                     GTK_SIGNAL_FUNC(mouse_click_cb), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "key_press_event",
                     GTK_SIGNAL_FUNC(file_list_key_press_cb), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "click_column",
                     GTK_SIGNAL_FUNC(column_button_cb), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "drag_data_get",
                     GTK_SIGNAL_FUNC(clist_drag_data_get), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "drag_motion",
                     GTK_SIGNAL_FUNC(clist_drag_motion), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "drag_leave",
                     GTK_SIGNAL_FUNC(clist_drag_leave), view);
  gtk_signal_connect(GTK_OBJECT(view->clist), "drag_data_received",
                     GTK_SIGNAL_FUNC(clist_drag_data_received), view);
  gtk_drag_dest_set(view->clist, GTK_DEST_DEFAULT_MOTION |
    GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table,
    n_targets, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK |
    GDK_ACTION_ASK);

  gtk_container_add(GTK_CONTAINER(sw), view->clist);
  gtk_widget_show(view->clist);

  /* Set the CLIST_COLOR for resetting from the DRAG_HILIGHT color */
  {
    GtkStyle *style = gtk_widget_get_style(view->clist);
    CLIST_COLOR.red   = style->base[GTK_STATE_NORMAL].red;
    CLIST_COLOR.green = style->base[GTK_STATE_NORMAL].green;
    CLIST_COLOR.blue  = style->base[GTK_STATE_NORMAL].blue;
  }

  return vbox;
}
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_scrolled_window_set_properties (GtkWidget * widget, GbWidgetSetArgData * data)
{
  gint i;
  gchar *hpolicy, *vpolicy, *hupdate_policy, *vupdate_policy;
  gboolean set_policy = FALSE;
  GtkPolicyType hpolicy_value = GTK_POLICY_AUTOMATIC;
  GtkPolicyType vpolicy_value = GTK_POLICY_AUTOMATIC;
  GtkUpdateType hupdate_policy_value = GTK_UPDATE_CONTINUOUS;
  GtkUpdateType vupdate_policy_value = GTK_UPDATE_CONTINUOUS;
  gchar *shadow, *placement;

  hpolicy = gb_widget_input_choice (data, HPolicy);
  if (data->apply)
    {
      set_policy = TRUE;
      for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]);
	   i++)
	{
	  if (!strcmp (hpolicy, GbPolicyChoices[i])
	      || !strcmp (hpolicy, GbPolicySymbols[i]))
	    hpolicy_value = GbPolicyValues[i];
	}
    }
  else
    hpolicy_value = GTK_SCROLLED_WINDOW (widget)->hscrollbar_policy;

  vpolicy = gb_widget_input_choice (data, VPolicy);
  if (data->apply)
    {
      set_policy = TRUE;
      for (i = 0; i < sizeof (GbPolicyValues) / sizeof (GbPolicyValues[0]);
	   i++)
	{
	  if (!strcmp (vpolicy, GbPolicyChoices[i])
	      || !strcmp (vpolicy, GbPolicySymbols[i]))
	    vpolicy_value = GbPolicyValues[i];
	}
    }
  else
    vpolicy_value = GTK_SCROLLED_WINDOW (widget)->vscrollbar_policy;

  if (set_policy)
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
				    hpolicy_value, vpolicy_value);

  shadow = gb_widget_input_choice (data, ShadowType);
  if (data->apply)
    {
      for (i = 0; i < GladeShadowChoicesSize; i++)
	{
	  if (!strcmp (shadow, GladeShadowChoices[i])
	      || !strcmp (shadow, GladeShadowSymbols[i]))
	    {
	      gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GladeShadowValues[i]);
	      break;
	    }
	}
    }

  placement = gb_widget_input_choice (data, WindowPlacement);
  if (data->apply)
    {
      for (i = 0; i < GladeCornerChoicesSize; i++)
	{
	  if (!strcmp (placement, GladeCornerChoices[i])
	      || !strcmp (placement, GladeCornerSymbols[i]))
	    {
	      gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (widget),
						 GladeCornerValues[i]);
	      break;
	    }
	}
    }
}
Exemple #7
0
/*
 * GUI initialization
 * args:
 *   width - window width
 *   height - window height
 *
 * asserts:
 *   none
 *
 * returns: error code (0 -OK)
 */
int gui_attach_gtk3(int width, int height)
{
	if(!gtk_init_called)
	{
		if(!gtk_init_check(NULL, NULL))
		{
			fprintf(stderr, "GUVCVIEW: (GUI) Gtk3 can't open display\n");
			return -1;
		}

		gtk_init_called = 1;
	}


	/*check for device errors*/
	//if(!device)
	//{
	//	gui_error("Guvcview error", "no video device found", 1);
	//	return -1;
	//}

	g_set_application_name(_("Guvcview Video Capture"));

#if !GTK_VER_AT_LEAST(3,12)
	/* make sure the type is realized so that we can change the properties*/
	g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
	/* make sure gtk-button-images property is set to true (defaults to false in karmic)*/
	g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
#endif

	/* Create a main window */
	main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (main_window), _("Guvcview"));
	gtk_widget_show (main_window);

	/* get screen resolution */
	GdkScreen* screen = NULL;
	screen = gtk_window_get_screen(GTK_WINDOW(main_window));
	int desktop_width = gdk_screen_get_width(screen);
	int desktop_height = gdk_screen_get_height(screen);

	if(debug_level > 0)
		printf("GUVCVIEW: (GUI) Screen resolution is (%d x %d)\n", desktop_width, desktop_height);

	if((width > desktop_width) && (desktop_width > 0))
		width = desktop_width;
	if((height > desktop_height) && (desktop_height > 0))
		height = desktop_height;

	gtk_window_resize(GTK_WINDOW(main_window), width, height);

	/* Add delete event handler */
	g_signal_connect(GTK_WINDOW(main_window), "delete_event", G_CALLBACK(delete_event), NULL);

	/*window icon*/
	char* icon1path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/guvcview.png", NULL);
	if (g_file_test(icon1path, G_FILE_TEST_EXISTS))
		gtk_window_set_icon_from_file(GTK_WINDOW (main_window), icon1path, NULL);
	g_free(icon1path);

	/*---------------------------- Main table ---------------------------------*/
	GtkWidget *maintable = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
	gtk_widget_show (maintable);

	/*----------------------------- Top Menu ----------------------------------*/
	gui_attach_gtk3_menu(maintable);

	/*----------------------------- Buttons -----------------------------------*/
	GtkWidget *HButtonBox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_halign (HButtonBox, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (HButtonBox, TRUE);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(HButtonBox),GTK_BUTTONBOX_SPREAD);
	gtk_box_set_homogeneous(GTK_BOX(HButtonBox),TRUE);
	gtk_widget_show(HButtonBox);

	/*photo button*/
	if(check_photo_timer())
	{
		CapImageButt = gtk_button_new_with_mnemonic (_("Stop Cap. (I)"));
		g_object_set_data (G_OBJECT (CapImageButt), "control_info",
							GINT_TO_POINTER(1));
	}
	else
	{
		CapImageButt = gtk_button_new_with_mnemonic (_("Cap. Image (I)"));
		g_object_set_data (G_OBJECT (CapImageButt), "control_info",
							GINT_TO_POINTER(0));
	}

	char *pix2path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/camera.png",NULL);
	if (g_file_test(pix2path, G_FILE_TEST_EXISTS))
	{
		GtkWidget *ImgButton_Img = gtk_image_new_from_file (pix2path);
#if GTK_VER_AT_LEAST(3,12)		
		gtk_button_set_always_show_image(GTK_BUTTON(CapImageButt), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(CapImageButt), ImgButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(CapImageButt), GTK_POS_TOP);
	}
	g_free(pix2path);
	
	gtk_box_pack_start(GTK_BOX(HButtonBox), CapImageButt, TRUE, TRUE, 2);
	gtk_widget_show (CapImageButt);

	g_signal_connect (GTK_BUTTON(CapImageButt), "clicked",
		G_CALLBACK (capture_image_clicked), NULL);

	/*video button*/
	CapVideoButt = gtk_toggle_button_new_with_mnemonic (_("Cap. Video (V)"));
	gui_set_video_capture_button_status_gtk3(get_encoder_status());

	char *pix3path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/movie.png",NULL);
	if (g_file_test(pix3path, G_FILE_TEST_EXISTS))
	{
		GtkWidget *VideoButton_Img = gtk_image_new_from_file (pix3path);
#if GTK_VER_AT_LEAST(3,12)
		gtk_button_set_always_show_image(GTK_BUTTON(CapVideoButt), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(CapVideoButt), VideoButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(CapVideoButt), GTK_POS_TOP);
	}
	g_free(pix3path);

	gtk_box_pack_start(GTK_BOX(HButtonBox), CapVideoButt, TRUE, TRUE, 2);
	gtk_widget_show (CapVideoButt);

	g_signal_connect (GTK_BUTTON(CapVideoButt), "clicked",
		G_CALLBACK (capture_video_clicked), NULL);

	/*quit button*/
	//GtkWidget *quitButton = gtk_button_new_from_stock(GTK_STOCK_QUIT);
	GtkWidget *quitButton = gtk_button_new_with_mnemonic (_("Quit"));

	char* pix4path = g_strconcat (PACKAGE_DATA_DIR, "/pixmaps/guvcview/close.png", NULL);
	if (g_file_test(pix4path,G_FILE_TEST_EXISTS))
	{
		GtkWidget *QButton_Img = gtk_image_new_from_file (pix4path);
#if GTK_VER_AT_LEAST(3,12)		
		gtk_button_set_always_show_image(GTK_BUTTON(quitButton), TRUE);
#endif
		gtk_button_set_image(GTK_BUTTON(quitButton), QButton_Img);
		gtk_button_set_image_position(GTK_BUTTON(quitButton), GTK_POS_TOP);

	}
	/*must free path strings*/
	g_free(pix4path);
	gtk_box_pack_start(GTK_BOX(HButtonBox), quitButton, TRUE, TRUE, 2);
	gtk_widget_show_all (quitButton);

	g_signal_connect (GTK_BUTTON(quitButton), "clicked",
		G_CALLBACK (quit_button_clicked), NULL);

	gtk_box_pack_start(GTK_BOX(maintable), HButtonBox, FALSE, TRUE, 2);

	/*--------------------------- Tab container -------------------------------*/
	GtkWidget *tab_box = gtk_notebook_new();
	gtk_widget_show (tab_box);

	/*------------------------ Image controls Tab -----------------------------*/

	GtkWidget *scroll_1 = gtk_scrolled_window_new(NULL,NULL);
	gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_1), GTK_CORNER_TOP_LEFT);
	gtk_widget_show(scroll_1);

	/*
	 * viewport is only needed for gtk < 3.8
	 * for 3.8 and above controls tab can be directly added to scroll1
	 */
	GtkWidget* viewport = gtk_viewport_new(NULL,NULL);
	gtk_widget_show(viewport);

	gtk_container_add(GTK_CONTAINER(scroll_1), viewport);

	gui_attach_gtk3_v4l2ctrls(viewport);

	GtkWidget *tab_1 = gtk_grid_new();
	gtk_widget_show (tab_1);

    GtkWidget *tab_1_label = gtk_label_new(_("Image Controls"));
	gtk_widget_show (tab_1_label);
	/** check for files */
	gchar *tab_1_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/image_controls.png",NULL);
	/** don't test for file - use default empty image if load fails */
	/** get icon image*/
	GtkWidget *tab_1_icon = gtk_image_new_from_file(tab_1_icon_path);
	gtk_widget_show (tab_1_icon);

	g_free(tab_1_icon_path);
	gtk_grid_attach (GTK_GRID(tab_1), tab_1_icon, 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID(tab_1), tab_1_label, 1, 0, 1, 1);

	gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_1, tab_1);

	/*----------------------------H264 Controls Tab --------------------------*/
	if(v4l2core_get_h264_unit_id(get_v4l2_device_handler()) > 0)
	{
		GtkWidget *scroll_2 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_2), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_2);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport2 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport2);

		gtk_container_add(GTK_CONTAINER(scroll_2), viewport2);

		gui_attach_gtk3_h264ctrls(viewport2);

		GtkWidget *tab_2 = gtk_grid_new();
		gtk_widget_show (tab_2);

		GtkWidget *tab_2_label = gtk_label_new(_("H264 Controls"));
		gtk_widget_show (tab_2_label);
		/** check for files */
		gchar *tab_2_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/image_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_2_icon = gtk_image_new_from_file(tab_2_icon_path);
		gtk_widget_show (tab_2_icon);

		g_free(tab_2_icon_path);
		gtk_grid_attach (GTK_GRID(tab_2), tab_2_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_2), tab_2_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_2, tab_2);
	}

	/*exclude video and audio tabs if we are in control panel mode*/
	if(!is_control_panel)
	{
		/*----------------------- Video controls Tab ------------------------------*/

		GtkWidget *scroll_3 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_3), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_3);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport3 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport3);

		gtk_container_add(GTK_CONTAINER(scroll_3), viewport3);

		gui_attach_gtk3_videoctrls(viewport3);

		GtkWidget *tab_3 = gtk_grid_new();
		gtk_widget_show (tab_3);

		GtkWidget *tab_3_label = gtk_label_new(_("Video Controls"));
		gtk_widget_show (tab_3_label);
		/** check for files */
		gchar *tab_3_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/video_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_3_icon = gtk_image_new_from_file(tab_3_icon_path);
		gtk_widget_show (tab_3_icon);

		g_free(tab_3_icon_path);
		gtk_grid_attach (GTK_GRID(tab_3), tab_3_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_3), tab_3_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_3, tab_3);

		/*----------------------- Audio controls Tab ------------------------------*/

		GtkWidget *scroll_4 = gtk_scrolled_window_new(NULL,NULL);
		gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll_4), GTK_CORNER_TOP_LEFT);
		gtk_widget_show(scroll_4);

		/*
		 * viewport is only needed for gtk < 3.8
		 * for 3.8 and above controls tab can be directly added to scroll1
		 */
		GtkWidget* viewport4 = gtk_viewport_new(NULL,NULL);
		gtk_widget_show(viewport4);

		gtk_container_add(GTK_CONTAINER(scroll_4), viewport4);

		gui_attach_gtk3_audioctrls(viewport4);

		GtkWidget *tab_4 = gtk_grid_new();
		gtk_widget_show (tab_4);

		GtkWidget *tab_4_label = gtk_label_new(_("Audio Controls"));
		gtk_widget_show (tab_4_label);
		/** check for files */
		gchar *tab_4_icon_path = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/audio_controls.png",NULL);
		/** don't test for file - use default empty image if load fails */
		/** get icon image*/
		GtkWidget *tab_4_icon = gtk_image_new_from_file(tab_4_icon_path);
		gtk_widget_show (tab_4_icon);

		g_free(tab_4_icon_path);
		gtk_grid_attach (GTK_GRID(tab_4), tab_4_icon, 0, 0, 1, 1);
		gtk_grid_attach (GTK_GRID(tab_4), tab_4_label, 1, 0, 1, 1);

		gtk_notebook_append_page(GTK_NOTEBOOK(tab_box), scroll_4, tab_4);
	}

	/* Attach the notebook (tabs) */
	gtk_box_pack_start(GTK_BOX(maintable), tab_box, TRUE, TRUE, 2);

	/*-------------------------- Status bar ------------------------------------*/
	status_bar = gtk_statusbar_new();
	status_warning_id = gtk_statusbar_get_context_id (GTK_STATUSBAR(status_bar), "warning");

    gtk_widget_show(status_bar);
	/* add the status bar*/
	gtk_box_pack_start(GTK_BOX(maintable), status_bar, FALSE, FALSE, 2);


	/* attach to main window container */
	gtk_container_add (GTK_CONTAINER (main_window), maintable);

	/* add key events*/
	gtk_widget_add_events (GTK_WIDGET (main_window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
	g_signal_connect (GTK_WINDOW(main_window), "key_press_event", G_CALLBACK(window_key_pressed), NULL);

	/* add update timers:
	 *  devices
	 */
	gtk_devices_timer_id = g_timeout_add( 1000, check_device_events, NULL);
	/*controls*/
	gtk_control_events_timer_id = g_timeout_add(1000, check_control_events, NULL);

	return 0;
}
Exemple #8
0
void meta_tab(struct ALL_DATA *all_data)
{
	struct GLOBAL *global = all_data->global;
	struct GWIDGET *gwidget = all_data->gwidget;
	struct paRecordData *pdata = all_data->pdata;

	int line = 0;
	int i = 0;
	//TABLE
	GtkWidget *table3 = gtk_grid_new();
	  gtk_grid_set_column_homogeneous (GTK_GRID(table3), FALSE);
	  gtk_widget_set_hexpand (table3, TRUE);
	  gtk_widget_set_halign (table3, GTK_ALIGN_FILL);
	
	  gtk_grid_set_row_spacing (GTK_GRID(table3), 4);
	  gtk_grid_set_column_spacing (GTK_GRID (table3), 4);
	  gtk_container_set_border_width (GTK_CONTAINER (table3), 2);
	  gtk_widget_show (table3);
	
	//SCROLL
	GtkWidget *scroll3 = gtk_scrolled_window_new(NULL,NULL);
	
	//ADD TABLE TO SCROLL
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll3),table3);
	gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll3), GTK_CORNER_TOP_LEFT);
	gtk_widget_show(scroll3);
	
	//new grid for tab label and icon
	GtkWidget *Tab3 = gtk_grid_new();
	  GtkWidget *Tab3Label = gtk_label_new(_("Meta Controls"));
	    gtk_widget_show (Tab3Label);

	  gchar* Tab3IconPath = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/meta_controls.png",NULL);

	  GtkWidget *Tab3Icon = gtk_image_new_from_file(Tab3IconPath);
	    g_free(Tab3IconPath);
	    gtk_widget_show (Tab3Icon);
	    gtk_grid_attach (GTK_GRID(Tab3), Tab3Icon, 0, 0, 1, 1);
	    gtk_grid_attach (GTK_GRID(Tab3), Tab3Label, 1, 0, 1, 1);
	    
	gtk_widget_show (Tab3);
	
	//ADD SCROLL to NOTEBOOK (TAB)
	gtk_notebook_append_page(GTK_NOTEBOOK(gwidget->boxh),scroll3,Tab3);

	//enable meta
	line++;
	gwidget->MetaEnableCB=gtk_check_button_new_with_label (_(" Meta"));
	gtk_grid_attach(GTK_GRID(table3), gwidget->MetaEnableCB, 1, 0, 1, 1);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gwidget->MetaEnableCB),  global->Meta_enable);
	gtk_widget_show (gwidget->MetaEnableCB);
	g_signal_connect (GTK_CHECK_BUTTON(gwidget->MetaEnableCB), "toggled",
		G_CALLBACK (MetaEnable_changed), all_data);
    

	line++;
	
	gwidget->label_XImuDevice = gtk_label_new(_("xIMU Device:"));//label_SndAPI
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_XImuDevice), 1, 0.5);

	gtk_grid_attach (GTK_GRID(table3), gwidget->label_XImuDevice, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_XImuDevice);
	
	gwidget->XImuDeviceCB = gtk_combo_box_text_new (); //SndAPI
	gtk_widget_set_halign (gwidget->XImuDeviceCB, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->XImuDeviceCB, TRUE);
	gtk_grid_attach(GTK_GRID(table3), gwidget->XImuDeviceCB, 1, line, 1, 1);
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->XImuDeviceCB),_("None"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->XImuDeviceCB),_("/dev/ttyUSB0"));
	gtk_widget_show (gwidget->XImuDeviceCB);
	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->XImuDeviceCB),global->XImuDeviceCB_idx);//Sound_API
	gtk_widget_set_sensitive (gwidget->XImuDeviceCB, TRUE);
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->XImuDeviceCB), "changed", G_CALLBACK (XImuDeviceCB_changed), all_data);

	gwidget->XImuPropBtn= gtk_button_new_with_label (_("properties"));
	gtk_grid_attach (GTK_GRID(table3), gwidget->XImuPropBtn, 2, line, 1, 1);
	gtk_widget_show (gwidget->XImuPropBtn);
	g_signal_connect (GTK_BUTTON(gwidget->XImuPropBtn), "clicked", G_CALLBACK (ximu_properties_dialog), all_data);

	line++;
	
	gwidget->label_EncoderDevice = gtk_label_new(_("Encoder Device:"));
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_EncoderDevice), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table3), gwidget->label_EncoderDevice, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_EncoderDevice);
//---
	gwidget->EncoderDeviceCB = gtk_combo_box_text_new ();//SndDevice
	
	gtk_widget_set_halign (gwidget->EncoderDeviceCB, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->EncoderDeviceCB, TRUE);
	gtk_grid_attach(GTK_GRID(table3), gwidget->EncoderDeviceCB, 1, line, 1, 1);

	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->EncoderDeviceCB),_("None"));
//TODO: request available encoder, now I have only one id=271264
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->EncoderDeviceCB),_("271264"));
	gtk_widget_show (gwidget->EncoderDeviceCB);

	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->EncoderDeviceCB),global->EncoderDeviceCB_idx);

	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->EncoderDeviceCB), "changed",
		G_CALLBACK (EncoderDeviceCB_changed), all_data);

gwidget->EncoderPropBtn= gtk_button_new_with_label (_("properties"));
gtk_grid_attach (GTK_GRID(table3), gwidget->EncoderPropBtn, 2, line, 1, 1);
gtk_widget_show (gwidget->EncoderPropBtn);
g_signal_connect (GTK_BUTTON(gwidget->EncoderPropBtn), "clicked", G_CALLBACK (encoder_properties_dialog), all_data);
    
//---	
	line++;
	gwidget->EncoderRateCB= gtk_combo_box_text_new ();//SndSampleRate
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->EncoderRateCB),_("Dev. Default"));
	gtk_widget_set_halign (gwidget->EncoderRateCB, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->EncoderRateCB, TRUE);
	gtk_grid_attach(GTK_GRID(table3), gwidget->EncoderRateCB, 1, line, 1, 1);
	gtk_widget_show (gwidget->EncoderRateCB);
	
	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->EncoderRateCB),global->EncoderRateCB_idx);
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->EncoderRateCB), "changed", G_CALLBACK (EncoderRateCB_changed), all_data);
	gwidget->label_EncoderRate = gtk_label_new(_("Encoder Rate:"));
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_EncoderRate), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table3), gwidget->label_EncoderRate, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_EncoderRate);
	
	//channels
	line++;
//TODO: request available bridge, now I have only one id=253523
	gwidget->TensoDeviceCB= gtk_combo_box_text_new ();
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoDeviceCB),_("None"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoDeviceCB),_("253523"));
	
	gtk_widget_set_halign (gwidget->TensoDeviceCB, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->TensoDeviceCB, TRUE);
	gtk_grid_attach(GTK_GRID(table3), gwidget->TensoDeviceCB, 1, line, 1, 1);
	gtk_widget_show (gwidget->TensoDeviceCB);
	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->TensoDeviceCB),global->TensoDeviceCB_idx);
	
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->TensoDeviceCB), "changed", G_CALLBACK (TensoDeviceCB_changed), all_data);
	
	gwidget->label_TensoDeviceCB = gtk_label_new(_("Tensor Device:"));
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_TensoDeviceCB), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table3), gwidget->label_TensoDeviceCB, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_TensoDeviceCB);
    
        gwidget->TensoPropBtn= gtk_button_new_with_label (_("properties"));
        gtk_grid_attach (GTK_GRID(table3), gwidget->TensoPropBtn, 2, line, 1, 1);
        gtk_widget_show (gwidget->TensoPropBtn);
        g_signal_connect (GTK_BUTTON(gwidget->TensoPropBtn), "clicked", G_CALLBACK (tenso_properties_dialog), all_data);

	line++;
	gwidget->TensoRateCB = gtk_combo_box_text_new ();
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB),_("8"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB),_("16"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB),_("32"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB),_("64"));
	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB),_("128"));

	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->TensoRateCB), global->TensoDeviceCB_idx);
	
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->TensoRateCB), "changed", G_CALLBACK (TensoRateCB_changed), all_data);

	gtk_widget_set_halign (gwidget->TensoRateCB, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->TensoRateCB, TRUE);
	gtk_grid_attach(GTK_GRID(table3), gwidget->TensoRateCB, 1, line, 1, 1);
	gtk_widget_show (gwidget->TensoRateCB);
	
	gwidget->label_TensoRateCB = gtk_label_new(_("Sensor Rate:"));
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_TensoRateCB), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table3), gwidget->label_TensoRateCB, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_TensoRateCB);
	
//---------------------------------------------------------------------------------------------------
	
line++;
	gwidget->label_TensoChannels = gtk_label_new(_("Sensor Channels:"));
	gtk_misc_set_alignment (GTK_MISC (gwidget->label_TensoChannels), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table3), gwidget->label_TensoChannels, 0, line, 1, 1);
	gtk_widget_show (gwidget->label_TensoChannels);
	
	
	gwidget->table_TensoChannels = gtk_grid_new();
	  gtk_grid_set_row_spacing (GTK_GRID (gwidget->table_TensoChannels), 4);
	  gtk_grid_set_column_spacing (GTK_GRID (gwidget->table_TensoChannels), 4);
	  gtk_container_set_border_width (GTK_CONTAINER (gwidget->table_TensoChannels), 4);
	  gtk_widget_set_size_request (gwidget->table_TensoChannels, -1, -1);
	  gtk_widget_set_halign (gwidget->table_TensoChannels, GTK_ALIGN_FILL);
	  gtk_widget_set_hexpand (gwidget->table_TensoChannels, TRUE);
	  gtk_grid_attach (GTK_GRID(table3), gwidget->table_TensoChannels, 1, line, 3, 1);
	  gtk_widget_show (gwidget->table_TensoChannels);

	// 0
	  gwidget->TensoChannTB_0 = gtk_check_button_new_with_label (_(" 0"));
	    g_object_set_data (G_OBJECT (gwidget->TensoChannTB_0), "effect_info", GINT_TO_POINTER(CH_0));
	    gtk_widget_set_halign (gwidget->TensoChannTB_0, GTK_ALIGN_FILL);
	    gtk_widget_set_hexpand (gwidget->TensoChannTB_0, TRUE);
	    gtk_grid_attach(GTK_GRID(gwidget->table_TensoChannels), gwidget->TensoChannTB_0, 1, 0, 1, 1);
	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gwidget->TensoChannTB_0),global->tenso_enabled_ch_0);
	    gtk_widget_show (gwidget->TensoChannTB_0);
	    g_signal_connect (GTK_CHECK_BUTTON(gwidget->TensoChannTB_0), "toggled", G_CALLBACK (TensoChannTB_0_changed), all_data);

	// 1
	  gwidget->TensoChannTB_1 = gtk_check_button_new_with_label (_(" 1"));
	    g_object_set_data (G_OBJECT (gwidget->TensoChannTB_1), "effect_info", GINT_TO_POINTER(CH_1));
	    gtk_widget_set_halign (gwidget->TensoChannTB_1, GTK_ALIGN_FILL);
	    gtk_widget_set_hexpand (gwidget->TensoChannTB_1, TRUE);
	    gtk_grid_attach(GTK_GRID(gwidget->table_TensoChannels), gwidget->TensoChannTB_1, 2, 0, 1, 1);
	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gwidget->TensoChannTB_1),global->tenso_enabled_ch_1);
	    gtk_widget_show (gwidget->TensoChannTB_1);
	    g_signal_connect (GTK_CHECK_BUTTON(gwidget->TensoChannTB_1), "toggled", G_CALLBACK (TensoChannTB_1_changed), all_data);

	// 2
	  gwidget->TensoChannTB_2 = gtk_check_button_new_with_label (_(" 2"));
	    g_object_set_data (G_OBJECT (gwidget->TensoChannTB_2), "effect_info", GINT_TO_POINTER(CH_2));
	    gtk_widget_set_halign (gwidget->TensoChannTB_2, GTK_ALIGN_FILL);
	    gtk_widget_set_hexpand (gwidget->TensoChannTB_2, TRUE);
	    gtk_grid_attach(GTK_GRID(gwidget->table_TensoChannels), gwidget->TensoChannTB_2, 3, 0, 1, 1);
	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gwidget->TensoChannTB_2),global->tenso_enabled_ch_2);
	    gtk_widget_show (gwidget->TensoChannTB_2);
	    g_signal_connect (GTK_CHECK_BUTTON(gwidget->TensoChannTB_2), "toggled", G_CALLBACK (TensoChannTB_2_changed), all_data);

      // 3
	    gwidget->TensoChannTB_3 = gtk_check_button_new_with_label (_(" 3"));
	    g_object_set_data (G_OBJECT (gwidget->TensoChannTB_3), "effect_info", GINT_TO_POINTER(CH_3));
	    gtk_widget_set_halign (gwidget->TensoChannTB_3, GTK_ALIGN_FILL);
	    gtk_widget_set_hexpand (gwidget->TensoChannTB_3, TRUE);
	    gtk_grid_attach(GTK_GRID(gwidget->table_TensoChannels), gwidget->TensoChannTB_3, 4, 0, 1, 1);
	    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gwidget->TensoChannTB_3),global->tenso_enabled_ch_3);

	    gtk_widget_show (gwidget->TensoChannTB_3);
	    g_signal_connect (GTK_CHECK_BUTTON(gwidget->TensoChannTB_3), "toggled", G_CALLBACK (TensoChannTB_3_changed), all_data);

}
Exemple #9
0
/*--------------------------- file chooser dialog ----------------------------*/
void video_tab(struct ALL_DATA *all_data)
{
	struct GLOBAL *global = all_data->global;
	struct vdIn *videoIn = all_data->videoIn;
	struct GWIDGET *gwidget = all_data->gwidget;
	//struct paRecordData *pdata = all_data->pdata;

	GtkWidget *table2;
	GtkWidget *scroll2;
	GtkWidget *Tab2;
	GtkWidget *Tab2Label;
	GtkWidget *Tab2Icon;
	GtkWidget *label_Device;
	//GtkWidget *FrameRate;
	GtkWidget *label_FPS;
	GtkWidget *ShowFPS;
	GtkWidget *labelResol;
	GtkWidget *label_InpType;
	GtkWidget *label_videoFilters;
	GtkWidget *table_filt;
	GtkWidget *FiltMirrorEnable;
	GtkWidget *FiltUpturnEnable;
	GtkWidget *FiltNegateEnable;
	GtkWidget *FiltMonoEnable;
	GtkWidget *FiltPiecesEnable;
	GtkWidget *FiltParticlesEnable;
	GtkWidget *set_jpeg_comp;
	GtkWidget *label_jpeg_comp;

	int line = 0;
	int i = 0;
	VidFormats *listVidFormats;

	//TABLE
	table2 = gtk_grid_new();
	gtk_grid_set_column_homogeneous (GTK_GRID(table2), FALSE);
	gtk_widget_set_hexpand (table2, TRUE);
	gtk_widget_set_halign (table2, GTK_ALIGN_FILL);

	gtk_grid_set_row_spacing (GTK_GRID(table2), 4);
	gtk_grid_set_column_spacing (GTK_GRID (table2), 4);
	gtk_container_set_border_width (GTK_CONTAINER (table2), 2);
	gtk_widget_show (table2);
	//SCROLL
	scroll2 = gtk_scrolled_window_new(NULL,NULL);
	//ADD TABLE TO SCROLL
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll2),table2);
	gtk_scrolled_window_set_placement(GTK_SCROLLED_WINDOW(scroll2), GTK_CORNER_TOP_LEFT);
	gtk_widget_show(scroll2);

	//new hbox for tab label and icon
	Tab2 = gtk_grid_new();
	Tab2Label = gtk_label_new(_("Video"));
	gtk_widget_show (Tab2Label);

	gchar* Tab2IconPath = g_strconcat (PACKAGE_DATA_DIR,"/pixmaps/guvcview/video_controls.png",NULL);
	//don't test for file - use default empty image if load fails
	//get icon image
	Tab2Icon = gtk_image_new_from_file(Tab2IconPath);
	g_free(Tab2IconPath);
	gtk_widget_show (Tab2Icon);
	gtk_grid_attach (GTK_GRID(Tab2), Tab2Icon, 0, 0, 1, 1);
	gtk_grid_attach (GTK_GRID(Tab2), Tab2Label, 1, 0, 1, 1);

	gtk_widget_show (Tab2);
	gtk_notebook_append_page(GTK_NOTEBOOK(gwidget->boxh),scroll2,Tab2);

	//Devices
	label_Device = gtk_label_new(_("Device:"));
	gtk_misc_set_alignment (GTK_MISC (label_Device), 1, 0.5);

	gtk_grid_attach (GTK_GRID(table2), label_Device, 0, line, 1, 1);

	gtk_widget_show (label_Device);


	gwidget->Devices = gtk_combo_box_text_new ();
	gtk_widget_set_halign (gwidget->Devices, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->Devices, TRUE);
	if (videoIn->listDevices->num_devices < 1)
	{
		//use current
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->Devices),
			videoIn->videodevice);
		gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->Devices),0);
	}
	else
	{
		for(i=0;i<(videoIn->listDevices->num_devices);i++)
		{
			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->Devices),
				videoIn->listDevices->listVidDevices[i].name);
			if(videoIn->listDevices->listVidDevices[i].current)
				gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->Devices),i);
		}
	}
	gtk_grid_attach (GTK_GRID(table2), gwidget->Devices, 1, line, 1 ,1);
	gtk_widget_show (gwidget->Devices);
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->Devices), "changed",
		G_CALLBACK (Devices_changed), all_data);

	// Resolution
	gwidget->Resolution = gtk_combo_box_text_new ();
	gtk_widget_set_halign (gwidget->Resolution, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->Resolution, TRUE);
	char temp_str[20];
	int defres=0;

	{
		int current_format = videoIn->listFormats->current_format;
		listVidFormats = &videoIn->listFormats->listVidFormats[current_format];
	}


	if (global->debug)
		g_print("resolutions of format(%d) = %d \n",
			videoIn->listFormats->current_format+1,
			listVidFormats->numb_res);
	for(i = 0 ; i < listVidFormats->numb_res ; i++)
	{
		if (listVidFormats->listVidCap[i].width>0)
		{
			g_snprintf(temp_str,18,"%ix%i", listVidFormats->listVidCap[i].width,
							 listVidFormats->listVidCap[i].height);
			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->Resolution),temp_str);

			if ((global->width == listVidFormats->listVidCap[i].width) &&
				(global->height == listVidFormats->listVidCap[i].height))
					defres=i;//set selected resolution index
		}
	}

	// Frame Rate
	line++;

	gwidget->FrameRate = gtk_combo_box_text_new ();
	gtk_widget_set_halign (gwidget->FrameRate, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->FrameRate, TRUE);
	int deffps=0;
	if (global->debug)
		g_print("frame rates of %dº resolution=%d \n",
			defres+1,
			listVidFormats->listVidCap[defres].numb_frates);
	for ( i = 0 ; i < listVidFormats->listVidCap[defres].numb_frates ; i++)
	{
		g_snprintf(temp_str,18,"%i/%i fps", listVidFormats->listVidCap[defres].framerate_denom[i],
			listVidFormats->listVidCap[defres].framerate_num[i]);
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->FrameRate),temp_str);

		if (( global->fps_num == listVidFormats->listVidCap[defres].framerate_num[i]) &&
			(global->fps == listVidFormats->listVidCap[defres].framerate_denom[i]))
				deffps=i;//set selected
	}

	gtk_grid_attach (GTK_GRID(table2), gwidget->FrameRate, 1, line, 1 ,1);
	gtk_widget_show (gwidget->FrameRate);


	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->FrameRate),deffps);
	if (deffps==0)
	{
		if (listVidFormats->listVidCap[defres].framerate_denom)
			global->fps = listVidFormats->listVidCap[defres].framerate_denom[0];

		if (listVidFormats->listVidCap[defres].framerate_num)
			global->fps_num = listVidFormats->listVidCap[defres].framerate_num[0];

		g_print("fps is set to %i/%i\n", global->fps_num, global->fps);
	}
	gtk_widget_set_sensitive (gwidget->FrameRate, TRUE);
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->FrameRate), "changed",
		G_CALLBACK (FrameRate_changed), all_data);

	label_FPS = gtk_label_new(_("Frame Rate:"));
	gtk_misc_set_alignment (GTK_MISC (label_FPS), 1, 0.5);

	gtk_grid_attach (GTK_GRID(table2), label_FPS, 0, line, 1, 1);

	gtk_widget_show (label_FPS);

	ShowFPS=gtk_check_button_new_with_label (_(" Show"));
	gtk_grid_attach (GTK_GRID(table2), ShowFPS, 2, line, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ShowFPS),(global->FpsCount > 0));
	gtk_widget_show (ShowFPS);
	g_signal_connect (GTK_CHECK_BUTTON(ShowFPS), "toggled",
		G_CALLBACK (ShowFPS_changed), all_data);

	// add resolution combo box
	line++;
	gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->Resolution),defres);

	if(global->debug)
		g_print("Def. Res: %i  numb. fps:%i\n",defres,videoIn->listFormats->listVidFormats[videoIn->listFormats->current_format].listVidCap[defres].numb_frates);

	gtk_grid_attach (GTK_GRID(table2), gwidget->Resolution, 1, line, 1 ,1);
	gtk_widget_show (gwidget->Resolution);

	gtk_widget_set_sensitive (gwidget->Resolution, TRUE);
	g_signal_connect (gwidget->Resolution, "changed",
		G_CALLBACK (resolution_changed), all_data);

	labelResol = gtk_label_new(_("Resolution:"));
	gtk_misc_set_alignment (GTK_MISC (labelResol), 1, 0.5);
	gtk_grid_attach (GTK_GRID(table2), labelResol, 0, line, 1, 1);
	gtk_widget_show (labelResol);

	// Input Format
	line++;
	gwidget->InpType= gtk_combo_box_text_new ();
	gtk_widget_set_halign (gwidget->InpType, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (gwidget->InpType, TRUE);

	int fmtind=0;
	for (fmtind=0; fmtind < videoIn->listFormats->numb_formats; fmtind++)
	{
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(gwidget->InpType),videoIn->listFormats->listVidFormats[fmtind].fourcc);
		if(global->format == videoIn->listFormats->listVidFormats[fmtind].format)
			gtk_combo_box_set_active(GTK_COMBO_BOX(gwidget->InpType),fmtind); /*set active*/
	}

	gtk_grid_attach (GTK_GRID(table2), gwidget->InpType, 1, line, 1 ,1);

	gtk_widget_set_sensitive (gwidget->InpType, TRUE);
	g_signal_connect (GTK_COMBO_BOX_TEXT(gwidget->InpType), "changed",
		G_CALLBACK (InpType_changed), all_data);
	gtk_widget_show (gwidget->InpType);

	label_InpType = gtk_label_new(_("Camera Output:"));
	gtk_misc_set_alignment (GTK_MISC (label_InpType), 1, 0.5);

	gtk_grid_attach (GTK_GRID(table2), label_InpType, 0, line, 1, 1);

	gtk_widget_show (label_InpType);

	//jpeg compression quality for MJPEG and JPEG input formats
	if((global->format == V4L2_PIX_FMT_MJPEG || global->format == V4L2_PIX_FMT_JPEG) && videoIn->jpgcomp.quality > 0)
	{
		line++;
		gwidget->jpeg_comp = gtk_spin_button_new_with_range(0,100,1);
		gtk_widget_set_halign (gwidget->jpeg_comp, GTK_ALIGN_FILL);
		gtk_widget_set_hexpand (gwidget->jpeg_comp, TRUE);
		/*can't edit the spin value by hand*/
		gtk_editable_set_editable(GTK_EDITABLE(gwidget->jpeg_comp),FALSE);
		gtk_spin_button_set_value (GTK_SPIN_BUTTON(gwidget->jpeg_comp), videoIn->jpgcomp.quality);
		gtk_grid_attach (GTK_GRID(table2), gwidget->jpeg_comp, 1, line, 1 ,1);

		gtk_widget_set_sensitive (gwidget->jpeg_comp, TRUE);
		gtk_widget_show (gwidget->jpeg_comp);

		set_jpeg_comp = gtk_button_new_with_label(_("Apply"));
		gtk_grid_attach (GTK_GRID(table2), set_jpeg_comp, 2, line, 1 ,1);
		g_signal_connect (GTK_BUTTON (set_jpeg_comp), "clicked",
				G_CALLBACK (set_jpeg_comp_clicked), all_data);
		gtk_widget_set_sensitive (set_jpeg_comp, TRUE);
		gtk_widget_show (set_jpeg_comp);

		label_jpeg_comp = gtk_label_new(_("Quality:"));
		gtk_misc_set_alignment (GTK_MISC (label_jpeg_comp), 1, 0.5);

		gtk_grid_attach (GTK_GRID(table2), label_jpeg_comp, 0, line, 1 ,1);

		gtk_widget_show (label_jpeg_comp);
	}

	// Filter controls
	line++;
	label_videoFilters = gtk_label_new(_("---- Video Filters ----"));
	gtk_misc_set_alignment (GTK_MISC (label_videoFilters), 0.5, 0.5);

	gtk_grid_attach (GTK_GRID(table2), label_videoFilters, 0, line, 3, 1);
	gtk_widget_show (label_videoFilters);

	line++;
	table_filt = gtk_grid_new();
	gtk_grid_set_row_spacing (GTK_GRID (table_filt), 4);
	gtk_grid_set_column_spacing (GTK_GRID (table_filt), 4);
	gtk_container_set_border_width (GTK_CONTAINER (table_filt), 4);
	gtk_widget_set_size_request (table_filt, -1, -1);

	gtk_widget_set_halign (table_filt, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (table_filt, TRUE);
	gtk_grid_attach (GTK_GRID(table2), table_filt, 0, line, 3, 1);
	gtk_widget_show (table_filt);

	// Mirror
	FiltMirrorEnable=gtk_check_button_new_with_label (_(" Mirror"));
	g_object_set_data (G_OBJECT (FiltMirrorEnable), "filt_info", GINT_TO_POINTER(YUV_MIRROR));
	gtk_widget_set_halign (FiltMirrorEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltMirrorEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltMirrorEnable, 0, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltMirrorEnable),(global->Frame_Flags & YUV_MIRROR)>0);
	gtk_widget_show (FiltMirrorEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltMirrorEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);
	// Upturn
	FiltUpturnEnable=gtk_check_button_new_with_label (_(" Invert"));
	g_object_set_data (G_OBJECT (FiltUpturnEnable), "filt_info", GINT_TO_POINTER(YUV_UPTURN));
	gtk_widget_set_halign (FiltUpturnEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltUpturnEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltUpturnEnable, 1, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltUpturnEnable),(global->Frame_Flags & YUV_UPTURN)>0);
	gtk_widget_show (FiltUpturnEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltUpturnEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);
	// Negate
	FiltNegateEnable=gtk_check_button_new_with_label (_(" Negative"));
	g_object_set_data (G_OBJECT (FiltNegateEnable), "filt_info", GINT_TO_POINTER(YUV_NEGATE));
	gtk_widget_set_halign (FiltNegateEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltNegateEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltNegateEnable, 2, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltNegateEnable),(global->Frame_Flags & YUV_NEGATE)>0);
	gtk_widget_show (FiltNegateEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltNegateEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);
	// Mono
	FiltMonoEnable=gtk_check_button_new_with_label (_(" Mono"));
	g_object_set_data (G_OBJECT (FiltMonoEnable), "filt_info", GINT_TO_POINTER(YUV_MONOCR));
	gtk_widget_set_halign (FiltMonoEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltMonoEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltMonoEnable, 3, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltMonoEnable),(global->Frame_Flags & YUV_MONOCR)>0);
	gtk_widget_show (FiltMonoEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltMonoEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);

	// Pieces
	FiltPiecesEnable=gtk_check_button_new_with_label (_(" Pieces"));
	g_object_set_data (G_OBJECT (FiltPiecesEnable), "filt_info", GINT_TO_POINTER(YUV_PIECES));
	gtk_widget_set_halign (FiltPiecesEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltPiecesEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltPiecesEnable, 4, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltPiecesEnable),(global->Frame_Flags & YUV_PIECES)>0);
	gtk_widget_show (FiltPiecesEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltPiecesEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);

	// Particles
	FiltParticlesEnable=gtk_check_button_new_with_label (_(" Particles"));
	g_object_set_data (G_OBJECT (FiltParticlesEnable), "filt_info", GINT_TO_POINTER(YUV_PARTICLES));
	gtk_widget_set_halign (FiltParticlesEnable, GTK_ALIGN_FILL);
	gtk_widget_set_hexpand (FiltParticlesEnable, TRUE);
	gtk_grid_attach(GTK_GRID(table_filt), FiltParticlesEnable, 5, 0, 1, 1);

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FiltParticlesEnable),(global->Frame_Flags & YUV_PARTICLES)>0);
	gtk_widget_show (FiltParticlesEnable);
	g_signal_connect (GTK_CHECK_BUTTON(FiltParticlesEnable), "toggled",
		G_CALLBACK (FiltEnable_changed), all_data);

}
Exemple #10
0
static void
create_layout (GtkWidget *vbox)
{
  GtkAdjustment *hadjustment, *vadjustment;
  GtkLayout *layout;
  GtkWidget *layout_widget;
  GtkWidget *scrolledwindow;
  GtkWidget *button;
  gchar buf[16];
  gint i, j;

  scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
				       GTK_SHADOW_IN);
  gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolledwindow),
				     GTK_CORNER_TOP_RIGHT);

  gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);

  layout_widget = gtk_layout_new (NULL, NULL);
  layout = GTK_LAYOUT (layout_widget);
  gtk_container_add (GTK_CONTAINER (scrolledwindow), layout_widget);

  /* We set step sizes here since GtkLayout does not set
   * them itself.
   */
  hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (layout));
  vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (layout));
  gtk_adjustment_set_step_increment (hadjustment, 10.0);
  gtk_adjustment_set_step_increment (vadjustment, 10.0);
  gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (layout), hadjustment);
  gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (layout), vadjustment);

  gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK);
  g_signal_connect (layout, "draw",
		    G_CALLBACK (layout_draw_handler),
                    NULL);

  gtk_layout_set_size (layout, 1600, 128000);

  for (i = 0 ; i < 16 ; i++)
    for (j = 0 ; j < 16 ; j++)
      {
	g_snprintf (buf, sizeof (buf), "Button %d, %d", i, j);

	if ((i + j) % 2)
	  button = gtk_button_new_with_label (buf);
	else
	  button = gtk_label_new (buf);

	gtk_layout_put (layout, button,	j * 100, i * 100);
      }

  for (i = 16; i < 1280; i++)
    {
      g_snprintf (buf, sizeof (buf), "Button %d, %d", i, 0);

      if (i % 2)
	button = gtk_button_new_with_label (buf);
      else
	button = gtk_label_new (buf);

      gtk_layout_put (layout, button, 0, i * 100);
    }

  layout_timeout = g_timeout_add (1000, scroll_layout, layout);
}
Exemple #11
0
void menu_items_treatment (GtkWidget *Widget, guint Op)
{
  gint CurrentPage, i;

  CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook));
  switch(Op)
    {
    case NEW                  : new_file ();                   break;
    case OPEN                 : open_file ();                  break;
    case SAVE                 : save_file ();                  break;
    case SAVE_ALL             : save_all ();                   break;
    case SAVE_AS              : save_file_as ();               break;
    case PRINT                : print_buffer ();               break;
    case CLOSE                : close_file ();                 break;
    case CLOSE_ALL            : close_all ();                  break;
    case QUIT                 : quit ();                       break;
    case UNDO                 :
      if (OpenedFilesCnt)
	{
	  proceed_undo ();
	  break;
	 } 
    case REDO                 :
      if (OpenedFilesCnt)
	{
	  proceed_redo ();
	  break;
	}
    case CUT                  :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_cut_clipboard (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Selection cut to Clipboard...");
	}
      break;
    case COPY                 :
      if (OpenedFilesCnt)
	{
	  gtk_editable_copy_clipboard
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Selection copied to Clipboard...");
	}
	break;
    case PASTE                :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_paste_clipboard
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)));
	  print_msg ("Text pasted from Clipboard...");
	}
      break;
    case CLEAR                :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  gtk_editable_delete_text
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1);
	  print_msg ("Buffer cleared...");
	}
      break;
    case SELECT_ALL           :
      if (OpenedFilesCnt)
	{
	  gtk_editable_select_region
	    (GTK_EDITABLE(FPROPS(CurrentPage, Text)), 0, -1);
	  print_msg ("All Text selected...");
	}
      break;
    case COMPLETE             :
      if (OpenedFilesCnt)
	auto_completion (GTK_TEXT(FPROPS(CurrentPage, Text)));
      break;
    case FIND                 :
      if (OpenedFilesCnt)
	search (FALSE);
      break;
    case REPLACE              :
      if (OpenedFilesCnt)
	search (TRUE);
      break;
    case LINE                 :
      if (OpenedFilesCnt)
	goto_line ();
      break;
    case READONLY             : toggle_readonly ();            break;
    case CONVERTER            : converter ();                  break;
    case COLOR                : color_picker ();               break;
    case INSERT_TIME          : insert_time (CurrentPage);     break;
    case TO_UPPER             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (1);
	  print_msg ("Selection converted to upper Case...");
	}
      break;
    case TO_LOWER             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (2);
	  print_msg ("Selection converted to Lower Case...");
	}
      break;
    case CAPITALIZE           :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (3);
	  print_msg ("Selection Capitalized...");
	}
      break; 
    case INVERT_CASE          :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  change_case (4);
	  print_msg ("Case inverted...");
	}
      break;
    case UNIX_DOS             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_unix_to_dos ();
	}
      break;
    case UNIX_MAC             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_unix_to_mac ();
	}
      break;
    case DOS_UNIX             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_dos_to_unix ();
	}
      break;
    case DOS_MAC              :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_dos_to_mac ();
	}
      break;
    case MAC_DOS              :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_mac_to_dos ();
	}
      break;
    case MAC_UNIX             :
      if ((OpenedFilesCnt) && !FPROPS(CurrentPage, ReadOnly))
	{
	  conv_mac_to_unix ();
	}
      break;
    case UNIX_DOS_ALL             :
      convert_all(conv_unix_to_dos);
      break;
    case UNIX_MAC_ALL             :
      convert_all(conv_unix_to_mac);
      break;
    case DOS_UNIX_ALL             :
      convert_all(conv_dos_to_unix);
      break;
    case DOS_MAC_ALL              :
      convert_all(conv_dos_to_mac);
      break;
    case MAC_DOS_ALL              :
      convert_all(conv_mac_to_dos);
      break;
    case MAC_UNIX_ALL             :
      convert_all(conv_mac_to_unix);
      break;
    case FILE_INFO            : file_info (CurrentPage);       break;
    case TOOLBAR              :
      if ((!ToolBarToggleDisplay) && (TOOLBAR_DISPLAY))
	ToolBarToggleDisplay = TRUE;
      else
	{
	  if (TOOLBAR_DISPLAY)
	    {
	      TOOLBAR_DISPLAY = FALSE;
	      hide_toolbar ();
	      print_msg ("Hide Tool Bar...");
	    }
	  else
	    {
	      TOOLBAR_DISPLAY = TRUE;
	      show_toolbar ();
	      if (!ToolBarToggleDisplay) ToolBarToggleDisplay = TRUE;
	      print_msg ("Display Tool Bar...");
	    }
	}
      break;
    case MSGBAR               :
      if ((!MsgBarToggleDisplay) && (MSGBAR_DISPLAY))
	MsgBarToggleDisplay = TRUE;
      else
	{
	  if (MSGBAR_DISPLAY)
	    {
	      MSGBAR_DISPLAY = FALSE;
	      hide_msgbar ();
	    }
	  else
	    {
	      MSGBAR_DISPLAY = TRUE;
	      show_msgbar ();
	      if (!MsgBarToggleDisplay) MsgBarToggleDisplay = TRUE;
	      print_msg ("Display Msg Bar...");
	    }
	}
      break;
    case WORDWRAP        :
     if ((!ToggleWordwrap) && (TOGGLE_WORDWRAP))
	ToggleWordwrap = TRUE;
      else
	{
	  if (TOGGLE_WORDWRAP)
	    {
	      TOGGLE_WORDWRAP = FALSE;
	      for (i = 0; i < OpenedFilesCnt; i++)
		gtk_text_set_word_wrap (GTK_TEXT(FPROPS(CurrentPage, Text)),
					FALSE);
	      print_msg ("Wordwrap disabled...");
	    }
	  else
	    {
	      TOGGLE_WORDWRAP = TRUE;
	      for (i = 0; i < OpenedFilesCnt; i++)
		gtk_text_set_word_wrap (GTK_TEXT(FPROPS(CurrentPage, Text)),
					TRUE);
	      if (!ToggleWordwrap) ToggleWordwrap = TRUE;
	      print_msg ("Wordwrap enabled...");
	    }
	}
      break;
    case TAB_POS_TOP          :
      TAB_POSITION = 1;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_TOP);
      break;
    case TAB_POS_BOTTOM       :
      TAB_POSITION = 2;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_BOTTOM);
      break;
    case TAB_POS_LEFT         :
      TAB_POSITION = 3;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_LEFT);
      break;
    case TAB_POS_RIGHT        :
      TAB_POSITION = 4;
      gtk_notebook_set_tab_pos (GTK_NOTEBOOK(MainNotebook), GTK_POS_RIGHT);  
      break;
    case SCROLLBAR_POS_LEFT   :
      SCROLLBAR_POSITION = 1;
      for (i = 0; i < OpenedFilesCnt; i++)
	gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW
					   (gtk_notebook_get_nth_page
					    (GTK_NOTEBOOK(MainNotebook), i)),
					   GTK_CORNER_TOP_RIGHT);
      break;
    case SCROLLBAR_POS_RIGHT  :
      SCROLLBAR_POSITION = 2;
      for (i = 0; i < OpenedFilesCnt; i++)
	gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW
					   (gtk_notebook_get_nth_page
					    (GTK_NOTEBOOK(MainNotebook), i)),
					   GTK_CORNER_TOP_LEFT);
      break;
    case PREFS                : display_prefs (&Settings);     break;
    case HELP                 :
      print_msg ("No help available yet...");
      break;
    case ABOUT                : about ();                      break;
    }
  (void)Widget; /* avoid the "unused parameter" warning */
}
Exemple #12
0
void add_page_in_notebook (GtkNotebook *Notebook, gchar *FileName)
{
  GtkWidget *VScrolledWindow;
  GtkWidget *TabLabel, *MenuLabel;
  GtkWidget *PopUpMenu;
  GtkStyle *Style;
  t_fprops Storage;
  
  g_array_append_val (FileProperties, Storage);
  if (!FileName)
    {
      gchar *Untitled;
      
      Untitled = g_strdup_printf (UNTITLED " %d", ++NewFilesCnt);
      init_file_properties (Untitled, OpenedFilesCnt);
      g_free (Untitled);
    }
  else init_file_properties (FileName, OpenedFilesCnt);
  VScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(VScrolledWindow),
				  GTK_POLICY_NEVER,
				  GTK_POLICY_ALWAYS);
  if (SCROLLBAR_POSITION == 1)
    gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW(VScrolledWindow),
				       GTK_CORNER_TOP_RIGHT);
  if (SCROLLBAR_POSITION == 2)
    gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW(VScrolledWindow),
				       GTK_CORNER_TOP_LEFT);
  FPROPS(OpenedFilesCnt, Text) = gtk_text_new (NULL, NULL);
  Style = gtk_style_copy (gtk_widget_get_style(FPROPS(OpenedFilesCnt, Text)));
  Style -> font = gdk_font_load (FONT);
  Style -> bg[GTK_STATE_SELECTED].red = SELECTED_BG_RED;
  Style -> bg[GTK_STATE_SELECTED].green = SELECTED_BG_GREEN;
  Style -> bg[GTK_STATE_SELECTED].blue = SELECTED_BG_BLUE;
  Style -> fg[GTK_STATE_SELECTED].red = SELECTED_FG_RED;
  Style -> fg[GTK_STATE_SELECTED].green = SELECTED_FG_GREEN;
  Style -> fg[GTK_STATE_SELECTED].blue = SELECTED_FG_BLUE;
  Style -> base[GTK_STATE_NORMAL].red = BG_RED;
  Style -> base[GTK_STATE_NORMAL].green = BG_GREEN;
  Style -> base[GTK_STATE_NORMAL].blue = BG_BLUE;
  Style -> text[GTK_STATE_NORMAL].red = FG_RED;
  Style -> text[GTK_STATE_NORMAL].green = FG_GREEN;
  Style -> text[GTK_STATE_NORMAL].blue = FG_BLUE;
  gtk_widget_set_style (FPROPS(OpenedFilesCnt, Text), Style);
  if (!FPROPS(OpenedFilesCnt, ReadOnly))
    gtk_text_set_editable (GTK_TEXT(FPROPS(OpenedFilesCnt, Text)), TRUE);
  if (TOGGLE_WORDWRAP)
    gtk_text_set_word_wrap (GTK_TEXT(FPROPS(OpenedFilesCnt, Text)),
			    TRUE);
  PopUpMenu = popup_menu_new ();
  gtk_signal_connect_object (GTK_OBJECT(FPROPS(OpenedFilesCnt, Text)),
			     "event", (GtkSignalFunc)popup_menu_show,
			     GTK_OBJECT(PopUpMenu));
  gtk_container_add (GTK_CONTAINER(VScrolledWindow),
		     FPROPS(OpenedFilesCnt, Text));
  TabLabel = gtk_label_new ("");
  MenuLabel = gtk_label_new ("");
  gtk_notebook_append_page_menu (Notebook, VScrolledWindow,
				 TabLabel, MenuLabel);
  gtk_widget_show_all (GTK_WIDGET(Notebook));
  set_label (Notebook, OpenedFilesCnt);
  gtk_notebook_set_page (GTK_NOTEBOOK(Notebook), OpenedFilesCnt++);
}