static void
run_theme_benchmark (void)
{
  GtkWidget* widget;
  GdkPixmap *pixmap;
  int top_height, bottom_height, left_width, right_width;
  MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
  {
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL
  };
  PangoLayout *layout;
  clock_t start;
  clock_t end;
  GTimer *timer;
  int i;
  MetaButtonLayout button_layout;
#define ITERATIONS 100
  int client_width;
  int client_height;
  int inc;
  
  widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_realize (widget);
  
  meta_theme_get_frame_borders (global_theme,
                                META_FRAME_TYPE_NORMAL,
                                get_text_height (widget),
                                get_flags (widget),
                                &top_height,
                                &bottom_height,
                                &left_width,
                                &right_width);
  
  layout = create_title_layout (widget);
  
  i = 0;
  while (i < MAX_BUTTONS_PER_CORNER)
    {
      button_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
      button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
      ++i;
    }
  
  button_layout.left_buttons[0] = META_BUTTON_FUNCTION_MENU;

  button_layout.right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE;
  button_layout.right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE;
  button_layout.right_buttons[2] = META_BUTTON_FUNCTION_CLOSE;

  timer = g_timer_new ();
  start = clock ();

  client_width = 50;
  client_height = 50;
  inc = 1000 / ITERATIONS; /* Increment to grow width/height,
                            * eliminates caching effects.
                            */
  
  i = 0;
  while (i < ITERATIONS)
    {
      /* Creating the pixmap in the loop is right, since
       * GDK does the same with its double buffering.
       */
      pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
                               client_width + left_width + right_width,
                               client_height + top_height + bottom_height,
                               -1);

      meta_theme_draw_frame (global_theme,
                             widget,
                             pixmap,
                             NULL,
                             0, 0,
                             META_FRAME_TYPE_NORMAL,
                             get_flags (widget),
                             client_width, client_height,
                             layout,
                             get_text_height (widget),
                             &button_layout,
                             button_states,
                             meta_preview_get_mini_icon (),
                             meta_preview_get_icon ());

      g_object_unref (G_OBJECT (pixmap));
      
      ++i;
      client_width += inc;
      client_height += inc;
    }

  end = clock ();
  g_timer_stop (timer);

  milliseconds_to_draw_frame = (g_timer_elapsed (timer, NULL) / (double) ITERATIONS) * 1000;
  
  g_print (_("Drew %d frames in %g client-side seconds (%g milliseconds per frame) and %g seconds wall clock time including X server resources (%g milliseconds per frame)\n"),
           ITERATIONS,
           ((double)end - (double)start) / CLOCKS_PER_SEC,
           (((double)end - (double)start) / CLOCKS_PER_SEC / (double) ITERATIONS) * 1000,
           g_timer_elapsed (timer, NULL),
           milliseconds_to_draw_frame);

  g_timer_destroy (timer);
  g_object_unref (G_OBJECT (layout));
  gtk_widget_destroy (widget);

#undef ITERATIONS
}
Example #2
0
static gboolean
egg_tray_manager_manage_xscreen (EggTrayManager *manager, Screen *xscreen)
{
  GtkWidget *invisible;
  char *selection_atom_name;
  guint32 timestamp;
  GdkScreen *screen;
  
  g_return_val_if_fail (EGG_IS_TRAY_MANAGER (manager), FALSE);
  g_return_val_if_fail (manager->screen == NULL, FALSE);

  /* If there's already a manager running on the screen
   * we can't create another one.
   */
#if 0
  if (egg_tray_manager_check_running_xscreen (xscreen))
    return FALSE;
#endif
  screen = gdk_display_get_screen (gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen)),
				   XScreenNumberOfScreen (xscreen));
  manager->screen = screen;
  
  invisible = gtk_invisible_new_for_screen (screen);
  gtk_widget_realize (invisible);
  
  gtk_widget_add_events (invisible, GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);

  selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
					 XScreenNumberOfScreen (xscreen));
  manager->selection_atom = XInternAtom (DisplayOfScreen (xscreen), selection_atom_name, False);

  g_free (selection_atom_name);

  manager->invisible = invisible;
  g_object_ref (G_OBJECT (manager->invisible));


  manager->orientation_atom = XInternAtom (DisplayOfScreen (xscreen),
					   "_NET_SYSTEM_TRAY_ORIENTATION",
					   FALSE);
  egg_tray_manager_set_orientation_property (manager);
  egg_tray_manager_set_visual_property (manager);
  
  timestamp = gdk_x11_get_server_time (invisible->window);
  XSetSelectionOwner (DisplayOfScreen (xscreen), manager->selection_atom,
		      GDK_WINDOW_XWINDOW (invisible->window), timestamp);

  /* Check if we were could set the selection owner successfully */
  if (XGetSelectionOwner (DisplayOfScreen (xscreen), manager->selection_atom) ==
      GDK_WINDOW_XWINDOW (invisible->window))
    {
      XClientMessageEvent xev;

      xev.type = ClientMessage;
      xev.window = RootWindowOfScreen (xscreen);
      xev.message_type = XInternAtom (DisplayOfScreen (xscreen), "MANAGER", False);

      xev.format = 32;
      xev.data.l[0] = timestamp;
      xev.data.l[1] = manager->selection_atom;
      xev.data.l[2] = GDK_WINDOW_XWINDOW (invisible->window);
      xev.data.l[3] = 0;	/* manager specific data */
      xev.data.l[4] = 0;	/* manager specific data */

      XSendEvent (DisplayOfScreen (xscreen),
		  RootWindowOfScreen (xscreen),
		  False, StructureNotifyMask, (XEvent *)&xev);

      manager->opcode_atom = XInternAtom (DisplayOfScreen (xscreen),
					  "_NET_SYSTEM_TRAY_OPCODE",
					  False);

      manager->message_data_atom = XInternAtom (DisplayOfScreen (xscreen),
						"_NET_SYSTEM_TRAY_MESSAGE_DATA",
						False);

      /* Add a window filter */
      gdk_window_add_filter (invisible->window, egg_tray_manager_window_filter, manager);
      return TRUE;
    }
  else
    {
      gtk_widget_destroy (invisible);
      g_object_unref (invisible);
      manager->invisible = NULL;

      manager->screen = NULL;
 
      return FALSE;
    }
}
Example #3
0
static void
liferea_shell_restore_state (const gchar *overrideWindowState)
{
	gchar		*toolbar_style, *accels_file;
	gint		last_vpane_pos, last_hpane_pos, last_wpane_pos;
	gint		resultState;
	
	debug0 (DEBUG_GUI, "Setting toolbar style");
	
	toolbar_style = conf_get_toolbar_style ();	
	liferea_shell_set_toolbar_style (toolbar_style);
	g_free (toolbar_style);

	debug0 (DEBUG_GUI, "Loading accelerators");
	
	accels_file = common_create_config_filename ("accels");
	gtk_accel_map_load (accels_file);
	g_free (accels_file);	

	debug0 (DEBUG_GUI, "Restoring window position");
	
	liferea_shell_restore_position ();

	debug0 (DEBUG_GUI, "Loading pane proportions");
		
	conf_get_int_value (LAST_VPANE_POS, &last_vpane_pos);
	if (last_vpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("leftpane")), last_vpane_pos);
	conf_get_int_value (LAST_HPANE_POS, &last_hpane_pos);
	if (last_hpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("normalViewPane")), last_hpane_pos);
	conf_get_int_value (LAST_WPANE_POS, &last_wpane_pos);
	if (last_wpane_pos)
		gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("wideViewPane")), last_wpane_pos);

	/* Apply horrible window state parameter logic:
	   -> overrideWindowState provides optional command line flags passed by
	      user or the session manager (prio 1)
	   -> lastState provides last shutdown preference (prio 2)
	 */

	/* Initialize with last saved state */
	conf_get_int_value (LAST_WINDOW_STATE, &resultState);

	/* Override with command line options */
	if (!g_strcmp0 (overrideWindowState, "hidden"))
		resultState = MAINWINDOW_HIDDEN;
	if (!g_strcmp0 (overrideWindowState, "shown"))
		resultState = MAINWINDOW_SHOWN;

	/* And set the window to the resulting state */
	switch (resultState) {
		case MAINWINDOW_HIDDEN:
			debug0 (DEBUG_GUI, "Restoring window state 'hidden (to tray)'");
			/* Realize needed so that the window structure can be
			   accessed... otherwise we get a GTK warning when window is
			   shown by clicking on notification icon or when theme
			   colors are fetched. */
			gtk_widget_realize (GTK_WIDGET (shell->priv->window));
			gtk_widget_hide (GTK_WIDGET (shell->priv->window));
			break;
		case MAINWINDOW_SHOWN:
		default:
			/* Safe default is always to show window */
			debug0 (DEBUG_GUI, "Restoring window state 'shown'");
			gtk_widget_show (GTK_WIDGET (shell->priv->window));
	}
}
static void
add_icons (const gchar **icons, const gchar **themed)
{
    GtkIconFactory *factory;
    GtkIconSource *source;
    GtkIconSet *iconset;
    GtkWidget *win;

    /* Setup the icon factory. */
    factory = gtk_icon_factory_new ();
    gtk_icon_factory_add_default (factory);
    
    /* Er, yeah, a hack, but it works. :) */
    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_realize(win);
    
    for ( ; *icons; icons++) {

        iconset = gtk_icon_set_new ();
        
        source = make_icon_source (*icons, "22x22", "png", GTK_ICON_SIZE_BUTTON);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_icon_source (*icons, "22x22", "png", GTK_ICON_SIZE_MENU);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_icon_source (*icons, "22x22", "png", GTK_ICON_SIZE_LARGE_TOOLBAR);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_icon_source (*icons, "22x22", "png", GTK_ICON_SIZE_SMALL_TOOLBAR);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_icon_source (*icons, "48x48", "png", GTK_ICON_SIZE_DIALOG);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_icon_source (*icons, "scalable", "svg", -1);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        
        gtk_icon_factory_add (factory, *icons, iconset);
        gtk_icon_set_unref (iconset);
    }
    
    for ( ; themed && *themed; themed++) {

        iconset = gtk_icon_set_new ();
        
        source = make_theme_source (*themed, GTK_ICON_SIZE_BUTTON);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_theme_source (*themed, GTK_ICON_SIZE_MENU);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_theme_source (*themed, GTK_ICON_SIZE_LARGE_TOOLBAR);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_theme_source (*themed, GTK_ICON_SIZE_SMALL_TOOLBAR);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_theme_source (*themed, GTK_ICON_SIZE_DIALOG);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        source = make_theme_source (*themed, -1);
        gtk_icon_set_add_source (iconset, source);
        gtk_icon_source_free (source);
        
        gtk_icon_factory_add (factory, *themed, iconset);
        gtk_icon_set_unref (iconset);
    }
    
    gtk_widget_destroy (win);
    g_object_unref (factory);
}
Example #5
0
int main (int argc, char *argv[])
{
    //const std::string creatureDB[]={"pidgeot","gardevoir"}; - For creature catalog~~
    //std::cout<<creatureDB[0];

    /* Initialize GTK+ */
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, (GLogFunc) gtk_false, NULL);
    gtk_init (&argc, &argv);
    g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, NULL);

    /* Main window configuration */
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win), false);
    gtk_widget_set_size_request(win,windowWidth,windowHeight);
    gtk_container_set_border_width (GTK_CONTAINER (win), 0);
    gtk_window_set_title (GTK_WINDOW (win), "Pokemon");
    gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win);
    g_signal_connect (win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win),"images/winIcon.png",NULL);
    //gtk_window_set_decorated (GTK_WINDOW(win),FALSE); //Óáèðàåò ñòàíäàðòíîå îôîðìëåíèå îêíà windows

    /* Initializing objects */
    zeBigContainer = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    zeBigContainerOverlay = gtk_overlay_new();
    topPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartCenter = gtk_alignment_new (0.5,0.5,1,1);
    topPartLeft = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    topPartCenter = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    topPartRight = gtk_box_new (GTK_ORIENTATION_VERTICAL,0);
    bottomPart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    buttons = gtk_grid_new ();
    dialogScrollFrame = gtk_scrolled_window_new(NULL,NULL);
    dialogText = gtk_text_view_new ();
    dialogBuffer = gtk_text_buffer_new (NULL);
    button1 = gtk_button_new ();
    button2 = gtk_button_new ();
    button3 = gtk_button_new ();
    button4 = gtk_button_new_with_label ("Restart");
    button5 = gtk_button_new_with_label ("Back to choosing screen");
    topMidPart = gtk_image_new_from_file ("images/topPic.jpg");
    IMGBackground = gtk_image_new_from_file ("images/pokeBackground.jpg");
    leftImage = gtk_image_new_from_file ("images/filler.PNG");
    rightImage = gtk_image_new_from_file ("images/filler.PNG");
    leftBar = gtk_progress_bar_new ();
    rightBar = gtk_progress_bar_new ();

    /* Setting dialogText */
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_LEFT, 5);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_BOTTOM, 20);
    gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(dialogText), GTK_TEXT_WINDOW_TOP, 5);
    gtk_text_view_set_editable(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(dialogText), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dialogText),GTK_WRAP_WORD);

    /* Setting progress bars */
    gtk_progress_bar_set_inverted(GTK_PROGRESS_BAR(rightBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(leftBar),TRUE);
    gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(rightBar),TRUE);

    /* Various initializations */
    gtk_box_set_homogeneous((GtkBox*)topPartCenter,TRUE);
    gtk_box_set_homogeneous((GtkBox*)topPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)bottomPart,TRUE);
    gtk_box_set_homogeneous((GtkBox*)zeBigContainer,TRUE);
    gtk_grid_set_row_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)buttons,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)buttons,12);
    gtk_grid_set_column_spacing((GtkGrid*)buttons,12);
    g_object_set (buttons,"margin",12,NULL);
    g_object_set (topPart,"margin",12,NULL);
    gtk_container_set_border_width(GTK_CONTAINER(dialogScrollFrame),5);
    //gtk_box_set_child_packing((GtkBox*)zeBigContainer,bottomPart,gTRUE,gTRUE,100,GTK_PACK_START);
    gtk_text_view_set_buffer (GTK_TEXT_VIEW(dialogText), dialogBuffer);
    gtk_text_buffer_set_text(dialogBuffer, "", -1);
    //gtk_text_buffer_get_iter_at_offset (dialogBuffer, &lastCharIter, -1);
    gtk_text_buffer_get_end_iter(dialogBuffer, &endIter);
    fontDesc = pango_font_description_from_string("Consolas");
    gtk_widget_override_font(dialogText,fontDesc);
    endMark = gtk_text_mark_new ("endMark",FALSE);
    endMark = gtk_text_buffer_get_mark(dialogBuffer,"insert");
    gtk_button_set_always_show_image(GTK_BUTTON(button1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(button3),TRUE);

    /* Building objects */
    gtk_container_add (GTK_CONTAINER(win),zeBigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(zeBigContainerOverlay),zeBigContainer);
    gtk_container_add (GTK_CONTAINER(zeBigContainerOverlay),IMGBackground);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),topPart);
    gtk_container_add (GTK_CONTAINER(zeBigContainer),bottomPart);
    gtk_container_add (GTK_CONTAINER(topPart),topPartLeft); // Â topPartLeft âñòàâëÿòü ëåâûé áàð
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftBar);
    gtk_container_add (GTK_CONTAINER(topPartLeft),leftImage);
    gtk_container_add (GTK_CONTAINER(topPart),topPartCenter);
    gtk_container_add (GTK_CONTAINER(topPart),topPartRight); // â topPartRight - ïðàâûé...
    gtk_container_add (GTK_CONTAINER(topPartRight),rightBar);
    gtk_container_add (GTK_CONTAINER(topPartRight),rightImage);
    gtk_container_add (GTK_CONTAINER(topPartCenter),topMidPart);
    gtk_container_add (GTK_CONTAINER(bottomPart),dialogScrollFrame);
    gtk_container_add (GTK_CONTAINER(dialogScrollFrame),dialogText);
    gtk_container_add (GTK_CONTAINER(bottomPart),buttons);
    gtk_grid_attach (GTK_GRID(buttons),button1, 1,1,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button2, 1,2,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button3, 1,3,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button4, 1,4,1,1);
    gtk_grid_attach (GTK_GRID(buttons),button5, 1,5,1,1);

    /* Signal connects and some shiatd */
    g_signal_connect(G_OBJECT(button1), "clicked", Cast1, NULL);
    g_signal_connect(G_OBJECT(button2), "clicked", Cast2, NULL);
    g_signal_connect(G_OBJECT(button3), "clicked", Cast3, NULL);
    g_signal_connect(G_OBJECT(button4), "clicked", combatStart, NULL);
    g_signal_connect(G_OBJECT(button5), "clicked", backToChoosingScreen,NULL);

    /* Creature chooser window configuration */ // TO BE CONTINUED..........................................................................
    /* Window creation/configuration (win2) */
    win2win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_resizable (GTK_WINDOW (win2win), false);
    gtk_widget_set_size_request(win2win,windowWidth,windowHeight);
    gtk_window_set_title (GTK_WINDOW (win2win), "Pokemon creature chooser");
    gtk_window_set_position (GTK_WINDOW (win2win), GTK_WIN_POS_CENTER);
    gtk_widget_realize (win2win);
    g_signal_connect (win2win, "destroy", gtk_main_quit, NULL);
    gtk_window_set_icon_from_file(GTK_WINDOW(win2win),"images/winIcon.png",NULL);


    /* Initializing objects (win2) */
    win2topLabel = gtk_image_new_from_file("images/logo.png");
    //win2topLabel = gtk_label_new("");
    //gtk_label_set_markup(GTK_LABEL(win2topLabel),"<small>Small</small><big>Bold</big>");
    win2BigContainer = gtk_grid_new();
    win2BigContainerOverlay = gtk_overlay_new ();
    win2TopPart = gtk_grid_new ();
    win2MiddlePart = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,0);
    win2BottomPart = gtk_grid_new();
    win2BackgroundIMG = gtk_image_new_from_file ("images/pokeBackground.jpg");
    win2button1 = gtk_button_new_with_label(">>Switch Screens<<");
    win2button2 = gtk_button_new_with_label("Exit");
    win2buttonReset = gtk_button_new_with_label("Reset");
    win2creatureIcon1 = gtk_button_new();
    win2creatureIcon2 = gtk_button_new();
    win2creatureIcon3 = gtk_button_new();
    win2creatureIcon4 = gtk_button_new();
    win2creatureIcon5 = gtk_button_new();
    win2creatureIcon1IMG = gtk_image_new_from_file("images/ImagePidgeotSmall.png");
    win2creatureIcon2IMG = gtk_image_new_from_file("images/ImageGardevoirSmall.png");
    win2creatureIcon3IMG = gtk_image_new_from_file("images/ImageArcanineSmall.png");
    win2creatureIcon4IMG = gtk_image_new_from_file("images/ImagePikachuSmall.png");
    win2creatureIcon5IMG = gtk_image_new_from_file("images/ImageFishSmall.png");
    win2ImageVersus = gtk_image_new_from_file ("images/versus.png");
    win2MiddleFirst = gtk_image_new_from_file ("images/facelessVoid.png");
    win2MiddleSecond = gtk_image_new_from_file ("images/facelessVoid.png");

    /* Various initializations (win2) */
    gtk_grid_set_row_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BigContainer,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BigContainer,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BigContainer,12);
    //g_object_set (win2BigContainer,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2BottomPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2BottomPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2BottomPart,12);
    g_object_set (win2BottomPart,"margin",12,NULL);

    gtk_grid_set_row_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_column_homogeneous((GtkGrid*)win2TopPart,TRUE);
    gtk_grid_set_row_spacing((GtkGrid*)win2TopPart,12);
    gtk_grid_set_column_spacing((GtkGrid*)win2TopPart,12);
    g_object_set (win2TopPart,"margin",12,NULL);

    gtk_box_set_homogeneous(GTK_BOX(win2MiddlePart),TRUE);

    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon1),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon2),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon3),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon4),TRUE);
    gtk_button_set_always_show_image(GTK_BUTTON(win2creatureIcon5),TRUE);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon1),win2creatureIcon1IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon2),win2creatureIcon2IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon3),win2creatureIcon3IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon4),win2creatureIcon4IMG);
    gtk_button_set_image(GTK_BUTTON(win2creatureIcon5),win2creatureIcon5IMG);

    /* Building objects (win2) */
    gtk_container_add (GTK_CONTAINER(win2win),win2BigContainerOverlay);
    gtk_overlay_add_overlay(GTK_OVERLAY(win2BigContainerOverlay),win2BigContainer);
    gtk_container_add (GTK_CONTAINER(win2BigContainerOverlay),win2BackgroundIMG);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2topLabel,1,1,1,2);//1
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2TopPart,1,2,1,3);//3
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon1,1,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon2,2,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon3,3,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon4,4,1,1,1);
    gtk_grid_attach(GTK_GRID(win2TopPart),win2creatureIcon5,5,1,1,1);
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2MiddlePart,1,5,1,3);//3
    gtk_grid_attach(GTK_GRID(win2BigContainer),win2BottomPart,1,8,1,3);//3
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleFirst);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2ImageVersus);
    gtk_container_add (GTK_CONTAINER(win2MiddlePart),win2MiddleSecond);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button1, 1,1,3,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2buttonReset,4,1,1,1);
    gtk_grid_attach (GTK_GRID(win2BottomPart),win2button2, 5,1,1,1);

    /* Signal connects (win2) */
    g_signal_connect (G_OBJECT(win2button1),"clicked",win2StartGame,NULL);
    g_signal_connect (G_OBJECT(win2button2),"clicked",gtk_main_quit,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon1),"clicked",win2pidgeotSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon2),"clicked",win2gardevoirSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon3),"clicked",win2arcanineSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon4),"clicked",win2pikachuSelect,NULL);
    g_signal_connect (G_OBJECT(win2creatureIcon5),"clicked",win2mightyfishSelect,NULL);
    g_signal_connect (G_OBJECT(win2buttonReset),"clicked",win2CharReset,NULL);

    /* Other stuff */
    srand(time(NULL));
    write ("___________________________________________________\n");

    /* Enter the main loop */
    gtk_widget_show_all (win2win);
    gtk_main ();

    return 0;
};
Example #6
0
void autosplit_show(GtkWidget *main_window)
{
    GtkWidget *vbox;
    GtkWidget *table;
    GtkWidget *hbbox;
    GtkWidget *message_label;
    GtkWidget *hseparator;
    GtkWidget *ok_button, *cancel_button;

    if (autosplit_time == NULL) {
        autosplit_time = g_strdup("5:00.00");
    }

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_realize(window);
    gtk_window_set_modal(GTK_WINDOW(window), TRUE);
    gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(main_window));
    gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ON_PARENT);
    gdk_window_set_functions(gtk_widget_get_window(window), GDK_FUNC_MOVE);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
    gtk_widget_show(vbox);

    table = gtk_table_new(3, 2, FALSE);
    gtk_container_add(GTK_CONTAINER(vbox), table);
    gtk_widget_show(table);

    message_label = gtk_label_new(_("Enter the time for autosplit:"));
    gtk_misc_set_alignment(GTK_MISC(message_label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), message_label, 0, 1, 0, 1, GTK_FILL, 0, 5, 0);
    gtk_widget_show(message_label);

    message_label = gtk_label_new(_("Example (5min, 32sec, 12subsec):"));
    gtk_misc_set_alignment(GTK_MISC(message_label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), message_label, 0, 1, 1, 2, GTK_FILL, 0, 5, 0);
    gtk_widget_show(message_label);

    message_label = gtk_label_new(" 5:32.12");
    gtk_misc_set_alignment(GTK_MISC(message_label), 0, 0.5);
    gtk_table_attach(GTK_TABLE(table), message_label, 1, 2, 1, 2, GTK_FILL, 0, 5, 0);
    gtk_widget_show(message_label);

    autosplit_time_entry = gtk_entry_new();
    gtk_entry_set_text(GTK_ENTRY(autosplit_time_entry), autosplit_time);
    gtk_entry_set_width_chars(GTK_ENTRY(autosplit_time_entry), 10);
    gtk_table_attach(GTK_TABLE(table), autosplit_time_entry, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 5, 0);
    gtk_widget_show(autosplit_time_entry);

    hseparator = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox), hseparator, FALSE, TRUE, 5);
    gtk_widget_show(hseparator);

    hbbox = gtk_hbutton_box_new();
    gtk_container_add(GTK_CONTAINER(vbox), hbbox);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(hbbox), GTK_BUTTONBOX_END);
    gtk_box_set_spacing(GTK_BOX(hbbox), 10);
    gtk_widget_show(hbbox);

    cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_box_pack_end(GTK_BOX(hbbox), cancel_button, FALSE, FALSE, 5);
    g_signal_connect(G_OBJECT(cancel_button), "clicked", (GCallback)cancel_button_clicked, window);
    gtk_widget_show(cancel_button);

    ok_button = gtk_button_new_from_stock(GTK_STOCK_OK);
    gtk_box_pack_end(GTK_BOX(hbbox), ok_button, FALSE, FALSE, 5);
    g_signal_connect(G_OBJECT(ok_button), "clicked", (GCallback)ok_button_clicked, window);
    gtk_widget_show(ok_button);

    gtk_widget_show(window);
}
Example #7
0
void l_kasdok(const char *data_dok,
              int tipz,  //1-приход 2-расход
              const char *nomdok,
              const char *kassa,
              GtkWidget *wpredok)
{
    class  kasdok_data data;
    data.datad.new_plus(data_dok);
    data.tipz=tipz;
    data.nomdok.new_plus(nomdok);
    data.kassa.new_plus(kassa);

//Чтение реквизитов документа
    l_kasdok_rd(&data,wpredok);

    data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
    gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);

//gtk_window_set_default_size (GTK_WINDOW  (data.window),400,-1);
//gdk_color_parse("black",&color);
//gtk_widget_modify_bg(data.window,GTK_STATE_NORMAL,&color);
    char bros[312];
    if(tipz == 1)
        sprintf(bros,"%s %s",name_system,gettext("Работа с приходным кассовым ордером"));
    if(tipz == 2)
        sprintf(bros,"%s %s",name_system,gettext("Работа с расходным кассовым ордером"));

    gtk_window_set_title (GTK_WINDOW (data.window),bros);
    gtk_container_set_border_width (GTK_CONTAINER (data.window), 5);

    gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
    gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);


    if(wpredok != NULL)
    {
        gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
        //Удерживать окно над породившем его окном всегда
        gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
        //Закрыть окно если окно предок удалено
        gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
    }

    gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(kasdok_key_press),&data);
    gtk_signal_connect_after(GTK_OBJECT(data.window),"key_release_event",GTK_SIGNAL_FUNC(iceb_key_release),&data.kl_shift);

    GtkWidget *hbox = gtk_hbox_new (FALSE, 1);
    gtk_container_add (GTK_CONTAINER (data.window), hbox);

    GtkWidget *vbox1 = gtk_vbox_new (FALSE, 1);
    GtkWidget *vbox2 = gtk_vbox_new (FALSE, 1);

    gtk_box_pack_start (GTK_BOX (hbox), vbox1, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
    gtk_widget_show(hbox);


    data.label_rek_dok=gtk_label_new ("");
    gtk_box_pack_start (GTK_BOX (vbox2),data.label_rek_dok,FALSE, FALSE, 0);

    data.label_red=gtk_label_new ("");
    gtk_box_pack_start (GTK_BOX (vbox2),data.label_red,FALSE, FALSE, 0);

    GdkColor color;
    gdk_color_parse("red",&color);
    gtk_widget_modify_fg(data.label_red,GTK_STATE_NORMAL,&color);

//формируем заголовок с реквизитами документа
    iceb_u_str string;

    l_kasdok_str_rek(&data,&string);

    gtk_widget_show(vbox1);
    gtk_widget_show(vbox2);

    data.sw = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_set_usize(GTK_WIDGET(data.sw),-1,200);

    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (data.sw),GTK_SHADOW_ETCHED_IN);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (data.sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
//gtk_box_pack_start (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);
    gtk_box_pack_end (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);
    gtk_widget_show(data.sw);

//Кнопки
    GtkTooltips *tooltips[KOL_F_KL];

    sprintf(bros,"%sF1 %s",RFK,gettext("Шапка"));
    data.knopka[SFK1]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[SFK1]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK1],TRUE,TRUE, 0);
    tooltips[SFK1]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[SFK1],data.knopka[SFK1],gettext("Просмотр шапки документа"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK1]),(gpointer)SFK1);
    gtk_widget_show(data.knopka[SFK1]);

    sprintf(bros,"F2 %s",gettext("Ввести"));
    data.knopka[FK2]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK2],TRUE,TRUE, 0);
    tooltips[FK2]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Ввод новой записи"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
    gtk_widget_show(data.knopka[FK2]);

    sprintf(bros,"%sF2 %s",RFK,gettext("Корректировать"));
    data.knopka[SFK2]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[SFK2]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK2],TRUE,TRUE, 0);
    tooltips[SFK2]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[SFK2],data.knopka[SFK2],gettext("Корректировка выбранной записи"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK2]),(gpointer)SFK2);
    gtk_widget_show(data.knopka[SFK2]);

    sprintf(bros,"F3 %s",gettext("Удалить"));
    data.knopka[FK3]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK3]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK3],TRUE,TRUE, 0);
    tooltips[FK3]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK3],data.knopka[FK3],gettext("Удалить выбранную запись"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK3]),(gpointer)FK3);
    gtk_widget_show(data.knopka[FK3]);

    sprintf(bros,"%sF3 %s",RFK,gettext("Удалить"));
    data.knopka[SFK3]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[SFK3]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK3],TRUE,TRUE, 0);
    tooltips[SFK3]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[SFK3],data.knopka[SFK3],gettext("Удалить документ"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK3]),(gpointer)SFK3);
    gtk_widget_show(data.knopka[SFK3]);

    sprintf(bros,"F4 %s",gettext("Проводки"));
    data.knopka[FK4]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK4],TRUE,TRUE, 0);
    tooltips[FK4]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Переход в режим работы с проводками для этого документа"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
    gtk_widget_show(data.knopka[FK4]);

    sprintf(bros,"F5 %s",gettext("Печать"));
    data.knopka[FK5]=gtk_button_new_with_label(bros);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK5],TRUE,TRUE, 0);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK5]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    tooltips[FK5]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK5],data.knopka[FK5],gettext("Распечатка документов"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK5]),(gpointer)FK5);
    gtk_widget_show(data.knopka[FK5]);


    sprintf(bros,"F7 %s",gettext("Подтверждение"));
    data.knopka[FK7]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK7]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK7],TRUE,TRUE, 0);
    tooltips[FK7]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK7],data.knopka[FK7],gettext("Подтверждение записи"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK7]),(gpointer)FK7);
    gtk_widget_show(data.knopka[FK7]);

    sprintf(bros,"%sF7 %s",RFK,gettext("Подтверждение"));
    data.knopka[SFK7]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[SFK7]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK7],TRUE,TRUE, 0);
    tooltips[SFK7]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[SFK7],data.knopka[SFK7],gettext("Подтверждение всех записей в документе"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK7]),(gpointer)SFK7);
    gtk_widget_show(data.knopka[SFK7]);

    sprintf(bros,"F8 %s",gettext("Снять под-ние"));
    data.knopka[FK8]=gtk_button_new_with_label(bros);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK8]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK8],TRUE,TRUE, 0);
    tooltips[FK8]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK8],data.knopka[FK8],gettext("Снять подтверждение со всего документа"),NULL);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK8]),(gpointer)FK8);
    gtk_widget_show(data.knopka[FK8]);


    sprintf(bros,"F10 %s",gettext("Выход"));
    data.knopka[FK10]=gtk_button_new_with_label(bros);
    gtk_box_pack_start(GTK_BOX(vbox1),data.knopka[FK10],TRUE,TRUE, 0);
    tooltips[FK10]=gtk_tooltips_new();
    gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне"),NULL);
    gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]), "clicked",GTK_SIGNAL_FUNC(kasdok_knopka),&data);
    gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
    gtk_widget_show(data.knopka[FK10]);

    gtk_widget_realize(data.window);
    gdk_window_set_cursor(data.window->window,gdk_cursor_new(ICEB_CURSOR));

    gtk_widget_grab_focus(data.knopka[FK10]);

    kasdok_create_list(&data);
    gtk_widget_show(data.window);

//if(metka == 0)
    gtk_window_maximize(GTK_WINDOW(data.window));
//gtk_window_fullscreen(GTK_WINDOW(data.window));


    gtk_main();



    if(wpredok != NULL)
        gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

}
Example #8
0
void pluginwindow_create()
{
	PluginWindow *pluginwindow;
	GtkWidget *window;
	GtkWidget *vbox1;
	GtkWidget *hbox2;
	GtkWidget *scrolledwindow2;
	GtkWidget *plugin_list_view;
	GtkWidget *vbox2;
	GtkWidget *frame2;
	GtkWidget *label13;
	GtkWidget *scrolledwindow3;
	GtkWidget *plugin_desc;
	GtkWidget *hbuttonbox1;
	GtkWidget *hbuttonbox2;
	GtkWidget *help_btn;
	GtkWidget *load_btn;
	GtkWidget *unload_btn;
	GtkWidget *close_btn;
	gchar *markup;
	GtkWidget *desc_lbl;
	GtkWidget *vbox3;
	GtkWidget *hbox_info;
	static GdkGeometry geometry;

	debug_print("Creating plugins window...\n");

	pluginwindow = g_new0(PluginWindow, 1);

	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "pluginwindow");
	gtk_container_set_border_width(GTK_CONTAINER(window), 8);
	gtk_window_set_title(GTK_WINDOW(window), _("Plugins"));
	gtk_window_set_modal(GTK_WINDOW(window), TRUE);
	manage_window_set_transient(GTK_WINDOW(window));

	vbox1 = gtk_vbox_new(FALSE, 4);
	gtk_widget_show(vbox1);
	gtk_container_add(GTK_CONTAINER(window), vbox1);
	gtk_box_set_homogeneous(GTK_BOX(vbox1), FALSE);
	gtk_widget_realize(window);

	hbox2 = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox2);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox2, TRUE, TRUE, 0);

	vbox3 = gtk_vbox_new(FALSE, 4);
	gtk_widget_show(vbox3);
	gtk_box_pack_start(GTK_BOX(hbox2), vbox3, FALSE, FALSE, 0);

	scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow2);
	gtk_box_pack_start(GTK_BOX(vbox3), scrolledwindow2, TRUE, TRUE, 0);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow2),
					GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
				       (scrolledwindow2), GTK_POLICY_NEVER,
				       GTK_POLICY_AUTOMATIC);

	plugin_list_view = pluginwindow_list_view_create(pluginwindow);
	gtk_widget_show(plugin_list_view);
	gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list_view);
	gtk_widget_grab_focus(GTK_WIDGET(plugin_list_view));

	gtkut_stock_button_set_create(&hbuttonbox1,
				&load_btn, _("Load..."),
				&unload_btn, _("Unload"),
				NULL, NULL);
	gtk_widget_show(hbuttonbox1);
	gtk_box_pack_start(GTK_BOX(vbox3), hbuttonbox1, FALSE, FALSE, 0);
	
	vbox2 = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(vbox2);
	gtk_box_pack_start(GTK_BOX(hbox2), vbox2, TRUE, TRUE, 0);

	frame2 = gtk_frame_new(NULL);
	gtk_widget_show(frame2);
	gtk_box_pack_start(GTK_BOX(vbox2), frame2, FALSE, TRUE, 0);

	label13 = gtk_label_new(_("Description"));
	gtk_widget_show(label13);
	gtk_container_add(GTK_CONTAINER(frame2), label13);
	gtk_misc_set_alignment(GTK_MISC(label13), 0, 0.5);
	gtk_misc_set_padding(GTK_MISC(label13), 2, 2);

	scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
	gtk_widget_show(scrolledwindow3);
	gtk_box_pack_start(GTK_BOX(vbox2), scrolledwindow3, TRUE, TRUE, 0);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow3),
					GTK_SHADOW_ETCHED_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
				       (scrolledwindow3), GTK_POLICY_NEVER,
				       GTK_POLICY_ALWAYS);

	plugin_desc = gtk_text_view_new();
	gtk_widget_show(plugin_desc);
	gtk_container_add(GTK_CONTAINER(scrolledwindow3), plugin_desc);

	hbox_info = gtk_hbox_new(FALSE, 5);
	gtk_widget_show(hbox_info);
	
	desc_lbl = gtk_label_new("");
	markup = g_markup_printf_escaped(_("For more information about plugins see the "
					   "<a href=\"%s\"><span underline=\"none\">Claws Mail website</span></a>."),PLUGINS_URI);
	gtk_label_set_markup(GTK_LABEL(desc_lbl), markup);
	g_free(markup);
	gtk_misc_set_alignment(GTK_MISC(desc_lbl), 0, 0.5);
	gtk_widget_show(desc_lbl);
	gtk_box_pack_start(GTK_BOX(hbox_info), desc_lbl, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(hbox_info), gtk_label_new(""), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox1), hbox_info, FALSE, FALSE, 0);

	gtkut_stock_button_set_create_with_help(&hbuttonbox2, &help_btn,
			&close_btn, GTK_STOCK_CLOSE,
			NULL, NULL, NULL, NULL);

	gtk_box_set_spacing(GTK_BOX(hbuttonbox2), 6);
	gtk_widget_show(hbuttonbox2);
	gtk_box_pack_end(GTK_BOX(vbox1), hbuttonbox2, FALSE, FALSE, 0);

	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugin_desc), GTK_WRAP_WORD);
	gtk_widget_set_sensitive(GTK_WIDGET(unload_btn), FALSE);

	g_signal_connect(G_OBJECT(help_btn), "clicked",
			 G_CALLBACK(manual_open_with_anchor_cb),
			 MANUAL_ANCHOR_PLUGINS);
	g_signal_connect(G_OBJECT(load_btn), "clicked",
			 G_CALLBACK(load_cb), pluginwindow);
	g_signal_connect(G_OBJECT(unload_btn), "clicked",
			 G_CALLBACK(unload_cb), pluginwindow);
	g_signal_connect(G_OBJECT(close_btn), "clicked",
			 G_CALLBACK(close_cb), pluginwindow);
	g_signal_connect(G_OBJECT(window), "size_allocate",
			 G_CALLBACK(pluginwindow_size_allocate_cb), NULL);
	g_signal_connect(G_OBJECT(window), "key_press_event",
			   G_CALLBACK(pluginwindow_key_pressed), pluginwindow);
	g_signal_connect(G_OBJECT(window), "delete_event",
			 G_CALLBACK(pluginwindow_delete_cb), pluginwindow);
	MANAGE_WINDOW_SIGNALS_CONNECT(window);

	CLAWS_SET_TIP(load_btn,
			_("Click here to load one or more plugins"));

	CLAWS_SET_TIP(unload_btn,
			_("Unload the selected plugin"));

	pluginwindow->window = window;
	pluginwindow->plugin_list_view = plugin_list_view;
	pluginwindow->plugin_desc = plugin_desc;
	pluginwindow->unload_btn = unload_btn;
	pluginwindow->selected_plugin = NULL;

	set_plugin_list(pluginwindow);

	inc_lock();

	if (!geometry.min_height) {
		geometry.min_width = -1;
		geometry.min_height = 300;
	}

	gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
				      GDK_HINT_MIN_SIZE);
	gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.pluginswin_width,
				    prefs_common.pluginswin_height);

	gtk_widget_show(window);
}
Example #9
0
/* serverside */
static void
on_message_received (const char *message,
		     gpointer    data)
{
	const PlumaEncoding *encoding = NULL;
	gchar **commands;
	gchar **params;
	gint workspace;
	gint viewport_x;
	gint viewport_y;
	gchar *display_name;
	gint screen_number;
	gint i;
	PlumaApp *app;
	PlumaWindow *window;
	GdkDisplay *display;
	GdkScreen *screen;

	g_return_if_fail (message != NULL);

	pluma_debug_message (DEBUG_APP, "Received message:\n%s\n", message);

	commands = g_strsplit (message, "\v", -1);

	/* header */
	params = g_strsplit (commands[0], "\t", 6);
	startup_timestamp = atoi (params[0]);
	display_name = params[1];
	screen_number = atoi (params[2]);
	workspace = atoi (params[3]);
	viewport_x = atoi (params[4]);
	viewport_y = atoi (params[5]);

	display = display_open_if_needed (display_name);
	if (display == NULL)
	{
		g_warning ("Could not open display %s\n", display_name);
		g_strfreev (params);
		goto out;
	}

	screen = gdk_display_get_screen (display, screen_number);

	g_strfreev (params);

	/* body */
	for (i = 1; commands[i] != NULL; i++)
	{
		params = g_strsplit (commands[i], "\t", -1);

		if (strcmp (params[0], "NEW-WINDOW") == 0)
		{
			new_window_option = TRUE;
		}
		else if (strcmp (params[0], "NEW-DOCUMENT") == 0)
		{
			new_document_option = TRUE;
		}
		else if (strcmp (params[0], "OPEN-URIS") == 0)
		{
			gint n_uris, j;
			gchar **uris;

			line_position = atoi (params[1]);

			if (params[2] != '\0')
				encoding = pluma_encoding_get_from_charset (params[2]);

			n_uris = atoi (params[3]);
			uris = g_strsplit (params[4], " ", n_uris);

			for (j = 0; j < n_uris; j++)
			{
				GFile *file;

				file = g_file_new_for_uri (uris[j]);
				file_list = g_slist_prepend (file_list, file);
			}

			file_list = g_slist_reverse (file_list);

			/* the list takes ownerhip of the strings,
			 * only free the array */
			g_free (uris);
		}
		else
		{
			g_warning ("Unexpected bacon command");
		}

		g_strfreev (params);
	}

	/* execute the commands */

	app = pluma_app_get_default ();

	if (new_window_option)
	{
		window = pluma_app_create_window (app, screen);
	}
	else
	{
		/* get a window in the current workspace (if exists) and raise it */
		window = _pluma_app_get_window_in_viewport (app,
							    screen,
							    workspace,
							    viewport_x,
							    viewport_y);
	}

	if (file_list != NULL)
	{
		_pluma_cmd_load_files_from_prompt (window,
						   file_list,
						   encoding,
						   line_position);

		if (new_document_option)
			pluma_window_create_tab (window, TRUE);
	}
	else
	{
		PlumaDocument *doc;
		doc = pluma_window_get_active_document (window);

		if (doc == NULL ||
		    !pluma_document_is_untouched (doc) ||
		    new_document_option)
			pluma_window_create_tab (window, TRUE);
	}

	/* set the proper interaction time on the window.
	 * Fall back to roundtripping to the X server when we
	 * don't have the timestamp, e.g. when launched from
	 * terminal. We also need to make sure that the window
	 * has been realized otherwise it will not work. lame.
	 */
	if (!gtk_widget_get_realized (GTK_WIDGET (window)))
		gtk_widget_realize (GTK_WIDGET (window));

	if (startup_timestamp <= 0)
		startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));

	gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)),
				      startup_timestamp);

	gtk_window_present (GTK_WINDOW (window));

 out:
	g_strfreev (commands);

	free_command_line_data ();
}
Example #10
0
int
main (int argc, char *argv[])
{
#if GST_GL_HAVE_WINDOW_X11
  XInitThreads ();
#endif
  gst_init (&argc, &argv);
  gtk_init (&argc, &argv);

  GstElement* pipeline = gst_pipeline_new ("pipeline");

  //window that contains an area where the video is drawn
  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
  gtk_window_move (GTK_WINDOW (window), 300, 10);
  gtk_window_set_title (GTK_WINDOW (window), "gtkgstwidget");

  //window to control the states
  GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE);
  gtk_window_move (GTK_WINDOW (window_control), 10, 10);
  GtkWidget* grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window_control), grid);

  //control state null
  GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL");
  g_signal_connect (G_OBJECT (button_state_null), "clicked",
      G_CALLBACK (button_state_null_cb), pipeline);
  gtk_grid_attach (GTK_GRID (grid), button_state_null, 0, 1, 1, 1);
  gtk_widget_show (button_state_null);

  //control state ready
  GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY");
  g_signal_connect (G_OBJECT (button_state_ready), "clicked",
      G_CALLBACK (button_state_ready_cb), pipeline);
  gtk_grid_attach (GTK_GRID (grid), button_state_ready, 0, 2, 1, 1);
  gtk_widget_show (button_state_ready);

  //control state paused
  GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED");
  g_signal_connect (G_OBJECT (button_state_paused), "clicked",
      G_CALLBACK (button_state_paused_cb), pipeline);
  gtk_grid_attach (GTK_GRID (grid), button_state_paused, 0, 3, 1, 1);
  gtk_widget_show (button_state_paused);

  //control state playing
  GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING");
  g_signal_connect (G_OBJECT (button_state_playing), "clicked",
      G_CALLBACK (button_state_playing_cb), pipeline);
  gtk_grid_attach (GTK_GRID (grid), button_state_playing, 0, 4, 1, 1);
  gtk_widget_show (button_state_playing);

  gtk_widget_show (grid);
  gtk_widget_show (window_control);

  //area where the video is drawn
  g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline);

  //configure the pipeline
  GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc");
  GstElement* effect = gst_element_factory_make ("glfiltercube", "cube");
  GstElement* videosink = gst_element_factory_make ("gtkglsink", "gtkglsink");

  GtkWidget *area;
  g_object_get (videosink, "widget", &area, NULL);
  gtk_container_add (GTK_CONTAINER (window), area);

  gtk_widget_realize(area);

  GstCaps *caps = gst_caps_new_simple("video/x-raw",
                                      "width", G_TYPE_INT, 640,
                                      "height", G_TYPE_INT, 480,
                                      "format", G_TYPE_STRING, "BGRA",
                                      NULL);

  gst_bin_add_many (GST_BIN (pipeline), videosrc, effect, videosink, NULL);

  gboolean link_ok = gst_element_link (effect, videosink) ;
  if(!link_ok)
  {
      g_warning("Failed to link glfiltercube to gtkglsink!\n") ;
      return -1;
  }
  if (!gst_element_link_filtered (videosrc, effect, caps)) {
      g_warning("Failed to link viideotestsrc to glfiltercube!\n") ;
      return -1;
  }
  gst_caps_unref (caps);

  //set window id on this event
  GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline);
  g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline);
  g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline);
  gst_object_unref (bus);

  //start
  GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  if (ret == GST_STATE_CHANGE_FAILURE)
  {
      g_print ("Failed to start up pipeline!\n");
      return -1;
  }

  gtk_widget_show_all (window);

  gtk_main();

  gst_deinit ();

  return 0;
}
Example #11
0
void
show_girdwnd  (gpointer, TImgData *imgdata)
{
    GtkWidget *win;
    GtkWidget *button;
    GtkWidget *scrolled_window = NULL;
    GtkWidget *image = NULL;

    const gchar *title_source = "Setting gird on SOURCE image";
    const gchar *title_dest = "Setting gird on DESTINATION image";

    dst_sigdata.event_box = NULL;
    src_sigdata.event_box = NULL;

    GtkWidget *vbox = NULL;
    GtkWidget *vbox2 = NULL;
    GtkWidget *label = NULL;
    GtkWidget *hbox = NULL;


//    GtkWidget *toolbar = NULL;
//    GtkToolItem *zin = NULL;
//    GtkToolItem *zout = NULL;
//    GtkToolItem *zfit = NULL;
//    GtkToolItem *zall = NULL;
//    GtkToolItem *sep = NULL;


    /* Create the main window */
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width (GTK_CONTAINER (win), 0);

    if(imgdata->is_source)
        gtk_window_set_title (GTK_WINDOW (win), title_source);
    else
        gtk_window_set_title (GTK_WINDOW (win), title_dest);

    gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(win), 600, 500);
    gtk_window_set_icon(GTK_WINDOW(win), gdk_pixbuf_new_from_file("cibo00_Algebraic_Mosaic.svg", NULL));	//http://www.openclipart.org/detail/12322
    gtk_widget_realize (win);
    g_signal_connect (win, "destroy", (GCallback) close_wnd, win);

    /* Create a vertical box with buttons */
    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (win), vbox);


//    /* Toolbbar menu */
//    toolbar = gtk_toolbar_new();
//    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_BOTH);
//
//    gtk_container_set_border_width(GTK_CONTAINER(toolbar), 2);
//
////    save = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE_AS);
////    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), save, -1);
//
//    sep = gtk_separator_tool_item_new();
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), sep, -1);
//
//    zin = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_IN);
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), zin, -1);
//
//    zout = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_OUT);
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), zout, -1);
//
//    zfit = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_FIT);
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), zfit, -1);
//
//    zall = gtk_tool_button_new_from_stock(GTK_STOCK_ZOOM_100);
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), zall, -1);

//    sep = gtk_separator_tool_item_new();
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), sep, -1);
//
//    refresh = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH);
//    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), refresh, -1);

   // gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);


    //  g_signal_connect (G_OBJECT (open), "clicked", G_CALLBACK (open_file), NULL);
    //  g_signal_connect (G_OBJECT (save), "clicked", G_CALLBACK (save_file), NULL);
//    g_signal_connect (G_OBJECT (zin), "clicked", G_CALLBACK (zoomin), NULL);
//    g_signal_connect (G_OBJECT (zout), "clicked", G_CALLBACK (zoomout), NULL);
//    g_signal_connect (G_OBJECT (zall), "clicked", G_CALLBACK (zoomnormal), NULL);
//    g_signal_connect (G_OBJECT (zfit), "clicked", G_CALLBACK (zoomfit), NULL);


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

//
//    vbox2 = gtk_vbox_new (FALSE, 6);
//    gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 6);


    //  GtkWidget *valign;

//    valign = gtk_alignment_new(0, 1, 1, 0);
//    label = gtk_label_new ("Tools:");
//    gtk_container_add(GTK_CONTAINER(valign), label);
//    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);

// create a new scrolled window.
    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 0);

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);



    //image_left = gtk_image_new_from_file("Lenna.png");


    //gtk_box_pack_start (GTK_BOX (vbox), image, TRUE, TRUE, 0);



    image = gtk_image_new ();
    gtk_misc_set_alignment (GTK_MISC(image), 0.0,0.0);

    GtkWidget *event_box;
    event_box = gtk_event_box_new ();
    gtk_container_add (GTK_CONTAINER (event_box), image);

    TSignalData *d;

    if(imgdata->is_source)
        d = &src_sigdata;
    else
        d = &dst_sigdata;

    d->idata = imgdata;
    d->image = image;

    g_signal_connect (G_OBJECT (event_box),
                      "motion_notify_event",//g_signal_name (GDK_MOTION_NOTIFY),
                      G_CALLBACK (button_move_callback), (gpointer)d);


    g_signal_connect (G_OBJECT (event_box),
                      "button-press-event",
                      G_CALLBACK (button_press_callback), (gpointer)d);

    g_signal_connect (G_OBJECT (event_box),
                      "button-release-event",
                      G_CALLBACK (button_release_callback), (gpointer)d);


    g_signal_connect (G_OBJECT (event_box),
                      "expose-event",
                      G_CALLBACK (expose_callback), (gpointer)d);

    ocvMat2gtkImg(imgdata->ocvMatImage, &image);
    gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), event_box);


    //hbox = gtk_hbox_new (FALSE, 6);
    //gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 6);

    vbox2 = gtk_vbox_new (FALSE, 6);
    gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 6);



    GtkWidget *valign;

    valign = gtk_alignment_new(0, 1, 0, 1);
    label = gtk_label_new ("Horizontal line:");
    gtk_container_add(GTK_CONTAINER(valign), label);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);


    valign = gtk_alignment_new(0, 1, 1, 1);
    button = gtk_button_new_with_label ("Add");
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (add_line_horizontal), d);
    gtk_container_add(GTK_CONTAINER(valign), button);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);

    valign = gtk_alignment_new(0, 1, 1, 1);
    button = gtk_button_new_with_label ("Remove");
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (remove_line_horizontal), d);
    gtk_container_add(GTK_CONTAINER(valign), button);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);


    valign = gtk_alignment_new(0, 1, 0, 1);
    label = gtk_label_new ("Vertical line:");
    gtk_container_add(GTK_CONTAINER(valign), label);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);

    valign = gtk_alignment_new(0, 1, 1, 1);
    button = gtk_button_new_with_label ("Add");
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (add_line_vertical), d);
    gtk_container_add(GTK_CONTAINER(valign), button);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);

    valign = gtk_alignment_new(0, 1, 1, 1);
    button = gtk_button_new_with_label ("Remove");
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (remove_line_vertical), d);
    gtk_container_add(GTK_CONTAINER(valign), button);
    gtk_box_pack_start(GTK_BOX(vbox2), valign, FALSE, FALSE, 0);

    gtk_widget_show_all (win);
}
Example #12
0
void create_win_sym()
{
  if (!current_CS) {
    dbg("create_win_sym, null CS\n");
    return;
  }

  if (current_CS->in_method < 0 || current_CS->in_method >= MAX_GTAB_NUM_KEY) {
    p_err("bad current_CS %d\n", current_CS->in_method);
  }

  if (current_method_type() != method_type_PHO && current_method_type() != method_type_TSIN && current_method_type() != method_type_ANTHY && !cur_inmd)
    return;

  if (read_syms() || cur_in_method != current_CS->in_method) {
    destory_win();
  } else {
    if (!syms)
      return;
  }


  if (gwin_sym) {
    if (win_sym_enabled)
      show_win_sym();
    else
      hide_win_sym();

    return;
  }

  gwin_sym = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_has_resize_grip(GTK_WINDOW(gwin_sym), FALSE);
#if WIN32
  set_no_focus(gwin_sym);
#endif

  cur_in_method = current_CS->in_method;

  GtkWidget *hbox_top = gtk_hbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (gwin_sym), hbox_top);

  GtkWidget *vbox_top = gtk_vbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_top), vbox_top, TRUE, TRUE, 0);

  gtk_container_set_border_width (GTK_CONTAINER (vbox_top), 0);

  int i;
  for(i=0; i < symsN; i++) {
    SYM_ROW *psym = &syms[i];
    GtkWidget *hbox_row = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), hbox_row, FALSE, FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (hbox_row), 0);

    int j;
    for(j=0; j < psym->symN; j++) {
      char *str = psym->sym[j];

      if (!str[0])
         continue;

      GtkWidget *button = gtk_button_new();
      GtkWidget *label = gtk_label_new(str);

      gtk_container_add(GTK_CONTAINER(button), label);
      set_label_font_size(label, gcin_font_size_symbol);

      gtk_container_set_border_width (GTK_CONTAINER (button), 0);
      gtk_box_pack_start (GTK_BOX (hbox_row), button, FALSE, FALSE, 0);

      if (utf8_str_N(str) > 0) {
        char phos[512];

        sym_lookup_key(str, phos);

        int phos_len = strlen(phos);

        if (phos_len) {
#if GTK_CHECK_VERSION(2,12,0)
          gtk_widget_set_tooltip_text (button, phos);
#else
          GtkTooltips *button_pho_tips = gtk_tooltips_new ();
          gtk_tooltips_set_tip (GTK_TOOLTIPS (button_pho_tips), button, phos, NULL);
#endif
        }
      }

      g_signal_connect (G_OBJECT (button), "clicked",  G_CALLBACK (cb_button_sym), label);
    }
  }

  gtk_box_pack_start (GTK_BOX (hbox_top), gtk_vseparator_new(), FALSE, FALSE, 0);

  GtkWidget *vbox_arrow = gtk_vbox_new (TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox_top), vbox_arrow, TRUE, TRUE, 0);
  GtkWidget *eve_up=gtk_event_box_new(), *eve_down=gtk_event_box_new();
  gtk_box_pack_start (GTK_BOX (vbox_arrow), eve_up, TRUE, TRUE, 0);
  gtk_container_add(GTK_CONTAINER(eve_up), gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN));
  gtk_box_pack_start (GTK_BOX (vbox_arrow), eve_down, TRUE, TRUE, 0);
  gtk_container_add(GTK_CONTAINER(eve_down), gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN));

  g_signal_connect(G_OBJECT(eve_up),"button-press-event", G_CALLBACK(mouse_button_callback_up_down), (gpointer)1);
  g_signal_connect(G_OBJECT(eve_down),"button-press-event", G_CALLBACK(mouse_button_callback_up_down), NULL);


  gtk_widget_realize (gwin_sym);
#if UNIX
  GdkWindow *gdkwin_sym = gtk_widget_get_window(gwin_sym);
  set_no_focus(gwin_sym);
#else
  win32_init_win(gwin_sym);
#endif

  if (win_sym_enabled)
    gtk_widget_show_all(gwin_sym);

  g_signal_connect (G_OBJECT (gwin_sym), "scroll-event", G_CALLBACK (button_scroll_event), NULL);

  move_win_sym();
#if 0
  dbg("in_method:%d\n", current_CS->in_method);
#endif
  return;
}
static int gtkFontDlgPopup(Ihandle* ih, int x, int y)
{
  InativeHandle* parent = iupDialogGetNativeParent(ih);
  GtkWidget* dialog;
  int response;
  char* preview_text, *standardfont;

  iupAttribSetInt(ih, "_IUPDLG_X", x);   /* used in iupDialogUpdatePosition */
  iupAttribSetInt(ih, "_IUPDLG_Y", y);

#if GTK_CHECK_VERSION(3, 2, 0)
  dialog = gtk_font_chooser_dialog_new(iupgtkStrConvertToSystem(iupAttribGet(ih, "TITLE")), GTK_WINDOW(parent));
#else
  dialog = gtk_font_selection_dialog_new(iupgtkStrConvertToSystem(iupAttribGet(ih, "TITLE")));
#endif
  if (!dialog)
    return IUP_ERROR;

#if !GTK_CHECK_VERSION(3, 2, 0)
  if (parent)
    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
#endif

  standardfont = iupAttribGet(ih, "VALUE");
  if (!standardfont)
    standardfont = IupGetGlobal("DEFAULTFONT");
#if GTK_CHECK_VERSION(3, 2, 0)
  gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dialog), standardfont);
#else
  gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dialog), standardfont);
#endif

  preview_text = iupAttribGet(ih, "PREVIEWTEXT");
  if (preview_text)
  {
    preview_text = iupgtkStrConvertToSystem(preview_text);
#if GTK_CHECK_VERSION(3, 2, 0)
    if (iupStrEqualNoCase(preview_text, "NONE"))
      gtk_font_chooser_set_show_preview_entry(GTK_FONT_CHOOSER(dialog), FALSE);
    else
      gtk_font_chooser_set_preview_text(GTK_FONT_CHOOSER(dialog), preview_text);
#else
    gtk_font_selection_dialog_set_preview_text(GTK_FONT_SELECTION_DIALOG(dialog), preview_text);
#endif
  }

  if (IupGetCallback(ih, "HELP_CB"))
  {
#if GTK_CHECK_VERSION(3, 10, 0)
    const char* help = "_Help";
#else
    const char* help = GTK_STOCK_HELP;
#endif

    gtk_dialog_add_button(GTK_DIALOG(dialog), help, GTK_RESPONSE_HELP);
  }
  
  /* initialize the widget */
  gtk_widget_realize(GTK_WIDGET(dialog));
  
  ih->handle = GTK_WIDGET(dialog);
  iupDialogUpdatePosition(ih);
  ih->handle = NULL;
                                    
  do 
  {
    response = gtk_dialog_run(GTK_DIALOG(dialog));

    if (response == GTK_RESPONSE_HELP)
    {
      Icallback cb = IupGetCallback(ih, "HELP_CB");
      if (cb && cb(ih) == IUP_CLOSE)
        response = GTK_RESPONSE_CANCEL;
    }
  } while (response == GTK_RESPONSE_HELP);

  if (response == GTK_RESPONSE_OK)
  {
#if GTK_CHECK_VERSION(3, 2, 0)
    char* fontname = gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dialog));
#else
    char* fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog));
#endif
    iupAttribSetStr(ih, "VALUE", fontname);
    g_free(fontname);
    iupAttribSet(ih, "STATUS", "1");
  }
  else
  {
    iupAttribSet(ih, "VALUE", NULL);
    iupAttribSet(ih, "STATUS", NULL);
  }

  gtk_widget_destroy(GTK_WIDGET(dialog));  

  return IUP_NOERROR;
}
Example #14
0
void wxListBox::GtkAddItem( const wxString &item, int pos )
{
    wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );

    GtkWidget *list_item;

    wxString label(item);
#if wxUSE_CHECKLISTBOX
    if (m_hasCheckBoxes)
    {
        label.Prepend(wxCHECKLBOX_STRING);
    }
#endif // wxUSE_CHECKLISTBOX

    list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );

    GList *gitem_list = g_list_alloc ();
    gitem_list->data = list_item;

    if (pos == -1)
        gtk_list_append_items( GTK_LIST (m_list), gitem_list );
    else
        gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos );

    gtk_signal_connect_after( GTK_OBJECT(list_item), "select",
      GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );

    if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
        gtk_signal_connect_after( GTK_OBJECT(list_item), "deselect",
          GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                        "button_press_event",
                        (GtkSignalFunc)gtk_listbox_button_press_callback,
                        (gpointer) this );

    gtk_signal_connect_after( GTK_OBJECT(list_item),
                        "button_release_event",
                        (GtkSignalFunc)gtk_listbox_button_release_callback,
                        (gpointer) this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                           "key_press_event",
                           (GtkSignalFunc)gtk_listbox_key_press_callback,
                           (gpointer)this );


    gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );

    ConnectWidget( list_item );

    if (GTK_WIDGET_REALIZED(m_widget))
    {
        gtk_widget_show( list_item );

        gtk_widget_realize( list_item );
        gtk_widget_realize( GTK_BIN(list_item)->child );

#if wxUSE_TOOLTIPS
        if (m_tooltip) m_tooltip->Apply( this );
#endif
    }

    // Apply current widget style to the new list_item
    GtkRcStyle *style = CreateWidgetStyle();
    if (style)
    {
        gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
        GtkBin *bin = GTK_BIN( list_item );
        gtk_widget_modify_style( GTK_WIDGET( bin->child ), style );
        gtk_rc_style_unref( style );
    }
}
Example #15
0
GtkWidget * create_PopUpMenu( void )
{
 GtkWidget * window1;
 GtkWidget * Menu = NULL;
 GtkWidget * SubMenu = NULL;
 GtkWidget * MenuItem = NULL;
 GtkWidget * H, * N, * D, * F;
 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
 int global_sub_size = mpctx_get_global_sub_size(guiIntfStruct.mpcontext);

 Menu=gtk_menu_new();
 gtk_widget_realize (Menu);
 window1 = gtk_widget_get_toplevel(Menu);


  AddMenuItem( window1, (const char*)ab_xpm, Menu,MSGTR_MENU_AboutMPlayer"     ", evAbout );
  AddSeparator( Menu );
   SubMenu=AddSubMenu( window1, (const char*)open_xpm, Menu,MSGTR_MENU_Open );
    AddMenuItem( window1, (const char*)file2_xpm, SubMenu,MSGTR_MENU_PlayFile"    ", evLoadPlay );
#ifdef HAVE_VCD
    AddMenuItem( window1, (const char*)playvcd_xpm, SubMenu,MSGTR_MENU_PlayVCD, evPlayVCD );
#endif
#ifdef USE_DVDREAD
    AddMenuItem( window1, (const char*)playdvd_xpm, SubMenu,MSGTR_MENU_PlayDVD, evPlayDVD );
#endif
    AddMenuItem( window1, (const char*)url_xpm, SubMenu,MSGTR_MENU_PlayURL, evSetURL );
    AddMenuItem( window1, (const char*)sub_xpm, SubMenu,MSGTR_MENU_LoadSubtitle"   ", evLoadSubtitle );
    AddMenuItem( window1, (const char*)delsub_xpm, SubMenu,MSGTR_MENU_DropSubtitle,evDropSubtitle );
    AddMenuItem( window1, (const char*)loadeaf_xpm, SubMenu,MSGTR_MENU_LoadExternAudioFile, evLoadAudioFile );
   SubMenu=AddSubMenu(window1, (const char*)play_xpm, Menu,MSGTR_MENU_Playing );
    AddMenuItem( window1, (const char*)play_xpm, SubMenu,MSGTR_MENU_Play"        ", evPlay );
    AddMenuItem( window1, (const char*)pause_xpm, SubMenu,MSGTR_MENU_Pause, evPause );
    AddMenuItem( window1, (const char*)stop2_xpm, SubMenu,MSGTR_MENU_Stop, evStop );
    AddMenuItem( window1, (const char*)next_xpm, SubMenu,MSGTR_MENU_NextStream, evNext );
    AddMenuItem( window1, (const char*)prev_xpm, SubMenu,MSGTR_MENU_PrevStream, evPrev );
//    AddSeparator( SubMenu );
//    AddMenuItem( SubMenu,"Back 10 sec", evBackward10sec );
//    AddMenuItem( SubMenu,"Fwd 10 sec", evForward10sec );
//    AddMenuItem( SubMenu,"Back 1 min", evBackward1min );
//    AddMenuItem( SubMenu,"Fwd 1 min", evForward1min );
//   SubMenu=AddSubMenu( Menu,MSGTR_MENU_Size );
//    AddMenuItem( SubMenu,MSGTR_MENU_NormalSize"      ", evNormalSize );
//    AddMenuItem( SubMenu,MSGTR_MENU_DoubleSize, evDoubleSize );
//    AddMenuItem( SubMenu,MSGTR_MENU_FullScreen, evFullScreen );
#ifdef HAVE_VCD
   VCDSubMenu=AddSubMenu( window1, (const char*)vcd_xpm, Menu,MSGTR_MENU_VCD );
    AddMenuItem( window1, (const char*)playvcd_xpm, VCDSubMenu,MSGTR_MENU_PlayDisc,evPlayVCD );
    AddSeparator( VCDSubMenu );
    VCDTitleMenu=AddSubMenu( window1, (const char*)title_xpm, VCDSubMenu,MSGTR_MENU_Titles );
    if ( guiIntfStruct.VCDTracks ) 
     {
      char tmp[32]; int i;
      for ( i=0;i < guiIntfStruct.VCDTracks;i++ )
       {
        snprintf( tmp,32,MSGTR_MENU_Title,i+1 );
    //AddMenuItem( VCDTitleMenu,tmp,( (i+1) << 16 ) + evSetVCDTrack );
        AddMenuItem(window1, (const char*)empty_xpm, VCDTitleMenu,tmp,( (i+1) << 16 ) + evSetVCDTrack );
       }
     }
     else
      {
       MenuItem=AddMenuItem( window1, (const char*)empty_xpm, VCDTitleMenu,MSGTR_MENU_None,evNone );
       gtk_widget_set_sensitive( MenuItem,FALSE );
      }
#endif
#ifdef USE_DVDREAD
   DVDSubMenu=AddSubMenu( window1, (const char*)dvd_xpm, Menu,MSGTR_MENU_DVD );
    AddMenuItem( window1, (const char*)playdvd_xpm, DVDSubMenu,MSGTR_MENU_PlayDisc"    ", evPlayDVD );
//    AddMenuItem( DVDSubMenu,MSGTR_MENU_ShowDVDMenu, evNone );
    AddSeparator( DVDSubMenu );
    DVDTitleMenu=AddSubMenu( window1, (const char*)title_xpm, DVDSubMenu,MSGTR_MENU_Titles );
     if ( guiIntfStruct.DVD.titles )
      {
       char tmp[32]; int i;
       for ( i=1 ; i<= guiIntfStruct.DVD.titles;i++ )
        {
         snprintf( tmp,32,MSGTR_MENU_Title,i);
         AddMenuCheckItem( window1, (const char*)empty1px_xpm, DVDTitleMenu,tmp,
			   guiIntfStruct.DVD.current_title == i,
			   (i << 16) + evSetDVDTitle );
        }
      }
      else
       {
        MenuItem=AddMenuItem( window1, (const char*)empty_xpm, DVDTitleMenu,MSGTR_MENU_None,evNone );
        gtk_widget_set_sensitive( MenuItem,FALSE );
       }
    DVDChapterMenu=AddSubMenu( window1, (const char*)chapter_xpm, DVDSubMenu,MSGTR_MENU_Chapters );
     if ( guiIntfStruct.DVD.chapters )
      {
       char tmp[32]; int i;
       for ( i=1;i <= guiIntfStruct.DVD.chapters;i++ )
        {
         snprintf( tmp,32,MSGTR_MENU_Chapter,i );
         AddMenuCheckItem( window1, (const char*)empty1px_xpm, DVDChapterMenu,tmp,guiIntfStruct.DVD.current_chapter == i,
			   ( i << 16 ) + evSetDVDChapter );
        }
      }
      else
       {
        MenuItem=AddMenuItem( window1, (const char*)empty_xpm, DVDChapterMenu,MSGTR_MENU_None,evNone );
        gtk_widget_set_sensitive( MenuItem,FALSE );
       }
    DVDAudioLanguageMenu=AddSubMenu( window1, (const char*)tongue_xpm, DVDSubMenu,MSGTR_MENU_AudioLanguages );
     if ( guiIntfStruct.DVD.nr_of_audio_channels )
      {
       char tmp[64]; int i, id = guiIntfStruct.demuxer ? ((demuxer_t *)guiIntfStruct.demuxer)->audio->id : audio_id;
       for ( i=0;i < guiIntfStruct.DVD.nr_of_audio_channels;i++ )
        {
	 snprintf( tmp,64,"%s - %s %s",GetLanguage( guiIntfStruct.DVD.audio_streams[i].language ),
	   ChannelTypes[ guiIntfStruct.DVD.audio_streams[i].type ],
	   ChannelNumbers[ guiIntfStruct.DVD.audio_streams[i].channels ] );
//	 if ( id == -1 ) id=audio_id; //guiIntfStruct.DVD.audio_streams[i].id;
         AddMenuCheckItem( window1, (const char*)dolby_xpm, DVDAudioLanguageMenu,tmp,
			   id == guiIntfStruct.DVD.audio_streams[i].id,
			   ( guiIntfStruct.DVD.audio_streams[i].id << 16 ) + evSetDVDAudio );
        }
      }
      else
       {
        MenuItem=AddMenuItem( window1, (const char*)empty_xpm, DVDAudioLanguageMenu,MSGTR_MENU_None,evNone );
        gtk_widget_set_sensitive( MenuItem,FALSE );
       }
    DVDSubtitleLanguageMenu=AddSubMenu( window1, (const char*)tonguebla_xpm, DVDSubMenu,MSGTR_MENU_SubtitleLanguages );
     if ( guiIntfStruct.DVD.nr_of_subtitles )
      {
       char tmp[64]; int i;
       AddMenuItem( window1, (const char*)empty1px_xpm, DVDSubtitleLanguageMenu,MSGTR_MENU_None,( (unsigned short)-1 << 16 ) + evSetDVDSubtitle );
       for ( i=0;i < guiIntfStruct.DVD.nr_of_subtitles;i++ )
        {
	 snprintf( tmp,64,"%s",GetLanguage( guiIntfStruct.DVD.subtitles[i].language ) );
         AddMenuCheckItem( window1, (const char*)empty1px_xpm, DVDSubtitleLanguageMenu,tmp,
			   dvdsub_id == guiIntfStruct.DVD.subtitles[i].id,
			   ( guiIntfStruct.DVD.subtitles[i].id << 16 ) + evSetDVDSubtitle );
        }
      }
      else
       {
        MenuItem=AddMenuItem( window1, (const char*)empty_xpm, DVDSubtitleLanguageMenu,MSGTR_MENU_None,evNone );
        gtk_widget_set_sensitive( MenuItem,FALSE );
       }
#endif

//  if ( guiIntfStruct.Playing )
   {
    AspectMenu=AddSubMenu( window1, (const char*)aspect_xpm, Menu,MSGTR_MENU_AspectRatio );
    AddMenuItem( window1, (const char*)a11_xpm, AspectMenu,MSGTR_MENU_Original,( 1 << 16 ) + evSetAspect );
    AddMenuItem( window1, (const char*)a169_xpm, AspectMenu,"16:9",( 2 << 16 ) + evSetAspect );
    AddMenuItem( window1, (const char*)a43_xpm, AspectMenu,"4:3",( 3 << 16 ) + evSetAspect );
    AddMenuItem( window1, (const char*)a235_xpm, AspectMenu,"2.35",( 4 << 16 ) + evSetAspect );
   }

  if ( guiIntfStruct.Playing && guiIntfStruct.demuxer && guiIntfStruct.StreamType != STREAMTYPE_DVD )
   {
    int i,c = 0;

    for ( i=0;i < MAX_A_STREAMS;i++ )
     if ( ((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i] ) c++;
    
    if ( c > 1 )
     {
      SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu,MSGTR_MENU_AudioTrack );
      for ( i=0;i < MAX_A_STREAMS;i++ )
       if ( ((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i] )
        {
         int aid = ((sh_audio_t *)((demuxer_t *)guiIntfStruct.demuxer)->a_streams[i])->aid;
         char tmp[32];
         snprintf( tmp,32,MSGTR_MENU_Track,aid );
         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( aid << 16 ) + evSetAudio );
        }
     }

    for ( c=0,i=0;i < MAX_V_STREAMS;i++ )
     if ( ((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i] ) c++;
    
    if ( c > 1 )
     {
      SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu,MSGTR_MENU_VideoTrack );
      for ( i=0;i < MAX_V_STREAMS;i++ )
       if ( ((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i] )
        {
         int vid = ((sh_video_t *)((demuxer_t *)guiIntfStruct.demuxer)->v_streams[i])->vid;
         char tmp[32];
         snprintf( tmp,32,MSGTR_MENU_Track,vid );
         AddMenuItem( window1, (const char*)empty_xpm, SubMenu,tmp,( vid << 16 ) + evSetVideo );
        }
     }
   }
  
  /* cheap subtitle switching for non-DVD streams */
  if ( global_sub_size && guiIntfStruct.StreamType != STREAMTYPE_DVD )
   {
    int i;
    SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu, MSGTR_MENU_Subtitles );
    AddMenuItem( window1, (const char*)empty_xpm, SubMenu, MSGTR_MENU_None, (-1 << 16) + evSetSubtitle );
    for ( i=0;i < global_sub_size;i++ )
     {
      char tmp[32];
      snprintf( tmp, 32, MSGTR_MENU_Track, i );
      AddMenuItem( window1,(const char*)empty_xpm,SubMenu,tmp,( i << 16 ) + evSetSubtitle );
     }
   }

  AddSeparator( Menu );
  MenuItem=AddMenuCheckItem( window1, (const char*)sound_xpm, Menu,MSGTR_MENU_Mute,mixer->muted,evMute );
  if ( !guiIntfStruct.AudioType ) gtk_widget_set_sensitive( MenuItem,FALSE );
  AddMenuItem( window1, (const char*)pl_xpm, Menu,MSGTR_MENU_PlayList, evPlayList );
  AddMenuItem( window1, (const char*)skin_xpm, Menu,MSGTR_MENU_SkinBrowser, evSkinBrowser );
  AddMenuItem( window1, (const char*)prefs_xpm, Menu,MSGTR_MENU_Preferences, evPreferences );
  AddMenuItem( window1, (const char*)eq_xpm, Menu,MSGTR_Equalizer, evEqualizer );

  if ( guiIntfStruct.NoWindow == False )
   {
    int b1 = 0, b2 = 0, b_half = 0;
    AddSeparator( Menu );
    if ( !appMPlayer.subWindow.isFullScreen && guiIntfStruct.Playing )
     {
      if ( ( appMPlayer.subWindow.Width == guiIntfStruct.MovieWidth * 2 )&& 
           ( appMPlayer.subWindow.Height == guiIntfStruct.MovieHeight * 2 ) ) b2=1;
      else if ( ( appMPlayer.subWindow.Width == guiIntfStruct.MovieWidth / 2 ) && 
                ( appMPlayer.subWindow.Height == guiIntfStruct.MovieHeight / 2 ) ) b_half=1;
      else b1=1;
     } else b1=!appMPlayer.subWindow.isFullScreen;
    H=AddMenuCheckItem( window1, (const char*)half_xpm, Menu,MSGTR_MENU_HalfSize,b_half,evHalfSize );
    N=AddMenuCheckItem( window1, (const char*)normal_xpm, Menu,MSGTR_MENU_NormalSize"      ",b1,evNormalSize );
    D=AddMenuCheckItem( window1, (const char*)double_xpm, Menu,MSGTR_MENU_DoubleSize,b2,evDoubleSize );
    F=AddMenuCheckItem( window1, (const char*)fs_xpm, Menu,MSGTR_MENU_FullScreen,appMPlayer.subWindow.isFullScreen,evFullScreen );
  if ( !gtkShowVideoWindow && !guiIntfStruct.Playing )
   {
    gtk_widget_set_sensitive( H,FALSE );
    gtk_widget_set_sensitive( N,FALSE );
    gtk_widget_set_sensitive( D,FALSE );
    gtk_widget_set_sensitive( F,FALSE );
   }
   }

  AddSeparator( Menu );
  AddMenuItem( window1, (const char*)exit_xpm, Menu,MSGTR_MENU_Exit, evExit );

 return Menu;
}
Example #16
0
bool wxTextCtrl::Create( wxWindow *parent,
                         wxWindowID id,
                         const wxString &value,
                         const wxPoint &pos,
                         const wxSize &size,
                         long style,
                         const wxValidator& validator,
                         const wxString &name )
{
    m_needParent = true;
    m_acceptsFocus = true;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxTextCtrl creation failed") );
        return false;
    }


    m_vScrollbarVisible = false;

    bool multi_line = (style & wxTE_MULTILINE) != 0;

    if (multi_line)
    {
        // create our control ...
        m_text = gtk_text_new( NULL, NULL );

        // ... and put into the upper left hand corner of the table
        bool bHasHScrollbar = false;
        m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
        GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
        gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
                      (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
                      (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
                       0, 0);

        // always wrap words
        gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );

        // finally, put the vertical scrollbar in the upper right corner
        m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
        GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
        gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
                     GTK_FILL,
                     (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
                     0, 0);
    }
    else
    {
        // a single-line text control: no need for scrollbars
        m_widget =
        m_text = gtk_entry_new();
    }

    m_parent->DoAddChild( this );

    m_focusWidget = m_text;

    PostCreation(size);

    if (multi_line)
        gtk_widget_show(m_text);

    if (multi_line)
    {
        gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
          (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );

        // only initialize gs_gtk_text_draw once, starting from the next the
        // klass::draw will already be wxgtk_text_draw
        if ( !gs_gtk_text_draw )
        {
            GtkDrawCallback&
                draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw;

            gs_gtk_text_draw = draw;

            draw = wxgtk_text_draw;
        }
    }

    if (!value.empty())
    {
#if !GTK_CHECK_VERSION(1, 2, 0)
        // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
        // gtk_editable_insert_text()
        gtk_widget_realize(m_text);
#endif // GTK 1.0

        gint tmp = 0;
#if wxUSE_UNICODE
        wxWX2MBbuf val = value.mbc_str();
        gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
#else
        gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &tmp );
#endif

        if (multi_line)
        {
            // Bring editable's cursor uptodate. Bug in GTK.
            SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
        }
    }

    if (style & wxTE_PASSWORD)
    {
        if (!multi_line)
            gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE );
    }

    if (style & wxTE_READONLY)
    {
        if (!multi_line)
            gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
    }
    else
    {
        if (multi_line)
            gtk_text_set_editable( GTK_TEXT(m_text), 1 );
    }

    // We want to be notified about text changes.
    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
        GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

    m_cursor = wxCursor( wxCURSOR_IBEAM );

    wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont());
    SetDefaultStyle( attrDef );

    return true;
}
Example #17
0
void Internet (void)
{
  if ((ifilestuff == 0) && ((biscomputer == 0) || (wiscomputer == 0))
    && (iyesno == 0) && (inet == 0))
  {
    connectwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (connectwindow), "Internet play");
    gtk_signal_connect (GTK_OBJECT (connectwindow), "delete_event",
      GTK_SIGNAL_FUNC (DestroyConnect), NULL);
    gtk_window_set_policy (GTK_WINDOW (connectwindow), 0, 0, 1);
    gtk_container_border_width (GTK_CONTAINER (connectwindow), 0);
    gtk_widget_realize (connectwindow);

    connectbox1 = gtk_vbox_new (FALSE, 0);
    gtk_container_border_width (GTK_CONTAINER (connectbox1), 0);
    gtk_container_add (GTK_CONTAINER (connectwindow), connectbox1);
    gtk_widget_show (connectbox1);
    connectbox2 = gtk_hbox_new (FALSE, 0);
    gtk_container_border_width (GTK_CONTAINER (connectbox2), 0);
    gtk_box_pack_start (GTK_BOX (connectbox1), connectbox2, FALSE, FALSE, 0);
    gtk_widget_show (connectbox2);
    connecttable1 = gtk_table_new (2, 4, FALSE);
    gtk_box_pack_start (GTK_BOX (connectbox2), connecttable1, TRUE, TRUE, 0);
    gtk_widget_show (connecttable1);

    entrylabel1 = gtk_label_new ("host:");
    gtk_label_set (GTK_LABEL (entrylabel1), "host:");
    gtk_label_set_justify (GTK_LABEL (entrylabel1), GTK_JUSTIFY_CENTER);
    gtk_table_attach (GTK_TABLE (connecttable1), entrylabel1, 0, 1, 0, 1,
      GTK_FILL, GTK_FILL, 10, 10);
    gtk_widget_show (entrylabel1);

    connectentry1 = gtk_entry_new_with_max_length (50);
    gtk_entry_set_text (GTK_ENTRY (connectentry1), "nngs.cosmic.org");
    gtk_entry_select_region (GTK_ENTRY (connectentry1), 0,
      GTK_ENTRY (connectentry1)->text_length);
    gtk_table_attach (GTK_TABLE (connecttable1), connectentry1, 1, 2, 0, 1,
      GTK_EXPAND, GTK_EXPAND, 0, 10);
    gtk_widget_grab_focus (connectentry1);
    gtk_widget_show (connectentry1);

    entrylabel2 = gtk_label_new ("port:");
    gtk_label_set (GTK_LABEL (entrylabel2), "port:");
    gtk_label_set_justify (GTK_LABEL (entrylabel2), GTK_JUSTIFY_CENTER);
    gtk_table_attach (GTK_TABLE (connecttable1), entrylabel2, 0, 1, 1, 2,
      GTK_FILL, GTK_FILL, 10, 10);
    gtk_widget_show (entrylabel2);

    connectentry2 = gtk_entry_new_with_max_length (5);
    gtk_entry_set_text (GTK_ENTRY (connectentry2), "9696");
    gtk_table_attach (GTK_TABLE (connecttable1), connectentry2, 1, 2, 1, 2,
      GTK_EXPAND, GTK_EXPAND, 0, 10);
    gtk_widget_show (connectentry2);

    connectsep = gtk_hseparator_new ();
    gtk_table_attach (GTK_TABLE (connecttable1), connectsep, 0, 2, 2, 3,
      GTK_FILL, GTK_FILL, 0, 0);
    gtk_widget_show (connectsep);

    connectbutton = gtk_button_new_with_label ("Connect");
    gtk_signal_connect (GTK_OBJECT (connectbutton), "clicked",
      GTK_SIGNAL_FUNC (InternetGo), NULL);
    GTK_WIDGET_SET_FLAGS (connectbutton, GTK_CAN_DEFAULT);
    gtk_window_set_default (GTK_WINDOW (connectwindow), connectbutton);
    gtk_table_attach (GTK_TABLE (connecttable1), connectbutton, 0, 2, 3, 4,
      GTK_FILL, GTK_FILL, 2, 2);
    gtk_widget_show (connectbutton);

    gtk_widget_show (connectwindow);
    iyesno = 1;
  }
}
Example #18
0
int
main(int argc, char **argv)
{
	GdkScreen *screen;
	GdkColormap *colormap;
	GtkWidget *window, *widget,*hbox = NULL, *scrollbar, *scrolled_window = NULL;
	VteTerminal *terminal;
	char *env_add[] = {
#ifdef VTE_DEBUG
		(char *) "FOO=BAR", (char *) "BOO=BIZ",
#endif
		NULL};
	const char *background = NULL;
	gboolean transparent = FALSE, audible = TRUE, blink = TRUE,
		 debug = FALSE, dingus = FALSE, dbuffer = TRUE,
		 console = FALSE, scroll = FALSE, keep = FALSE,
		 icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
		 cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE,
		 antialias = TRUE, use_scrolled_window = FALSE,
                 show_object_notifications = FALSE;
        char *geometry = NULL;
	gint lines = 100;
	const char *message = "Launching interactive shell...\r\n";
	const char *font = NULL;
	const char *termcap = NULL;
	const char *command = NULL;
	const char *working_directory = NULL;
	const char *output_file = NULL;
        char *pty_flags_string = NULL;
        char *cursor_shape_string = NULL;
        char *scrollbar_policy_string = NULL;
	GdkColor fore, back, tint, highlight, cursor;
	const GOptionEntry options[]={
		{
			"antialias", 'A', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &antialias,
			"Disable the use of anti-aliasing", NULL
		},
		{
			"background", 'B', 0,
			G_OPTION_ARG_FILENAME, &background,
			"Specify a background image", NULL
		},
		{
			"console", 'C', 0,
			G_OPTION_ARG_NONE, &console,
			"Watch /dev/console", NULL
		},
		{
			"dingus", 'D', 0,
			G_OPTION_ARG_NONE, &dingus,
			"Highlight URLs inside the terminal", NULL
		},
		{
			"shell", 'S', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &shell,
			"Disable spawning a shell inside the terminal", NULL
		},
		{
			"transparent", 'T', 0,
			G_OPTION_ARG_NONE, &transparent,
			"Enable the use of a transparent background", NULL
		},
		{
			"double-buffer", '2', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &dbuffer,
			"Disable double-buffering", NULL
		},
		{
			"audible", 'a', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &audible,
			"Use visible, instead of audible, terminal bell",
			NULL
		},
		{
			"blink", 'b', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &blink,
			"Disable the blinking cursor", NULL
		},
		{
			"command", 'c', 0,
			G_OPTION_ARG_STRING, &command,
			"Execute a command in the terminal", NULL
		},
		{
			"debug", 'd', 0,
			G_OPTION_ARG_NONE, &debug,
			"Enable various debugging checks", NULL
		},
		{
			"font", 'f', 0,
			G_OPTION_ARG_STRING, &font,
			"Specify a font to use", NULL
		},
		{
			"geometry", 'g', 0,
			G_OPTION_ARG_STRING, &geometry,
			"Set the size (in characters) and position", "GEOMETRY"
		},
		{
			"highlight", 'h', 0,
			G_OPTION_ARG_NONE, &highlight_set,
			"Enable the cursor highlighting", NULL
		},
		{
			"icon-title", 'i', 0,
			G_OPTION_ARG_NONE, &icon_title,
			"Enable the setting of the icon title", NULL
		},
		{
			"keep", 'k', 0,
			G_OPTION_ARG_NONE, &keep,
			"Live on after the window closes", NULL
		},
		{
			"scrollback-lines", 'n', 0,
			G_OPTION_ARG_INT, &lines,
			"Specify the number of scrollback-lines", NULL
		},
		{
			"color-cursor", 'r', 0,
			G_OPTION_ARG_NONE, &cursor_set,
			"Enable a colored cursor", NULL
		},
		{
			"cursor-shape", 0, 0,
			G_OPTION_ARG_STRING, &cursor_shape_string,
			"Set cursor shape (block|underline|ibeam)", NULL
		},
		{
			"scroll-background", 's', 0,
			G_OPTION_ARG_NONE, &scroll,
			"Enable a scrolling background", NULL
		},
		{
			"termcap", 't', 0,
			G_OPTION_ARG_STRING, &termcap,
			"Specify the terminal emulation to use", NULL
		},
		{
			"working-directory", 'w', 0,
			G_OPTION_ARG_FILENAME, &working_directory,
			"Specify the initial working directory of the terminal",
			NULL
		},
		{
			"reverse", 0, 0,
			G_OPTION_ARG_NONE, &reverse,
			"Reverse foreground/background colors", NULL
		},
		{
			"no-geometry-hints", 'G', G_OPTION_FLAG_REVERSE,
			G_OPTION_ARG_NONE, &use_geometry_hints,
			"Allow the terminal to be resized to any dimension, not constrained to fit to an integer multiple of characters",
			NULL
		},
		{
			"scrolled-window", 'W', 0,
			G_OPTION_ARG_NONE, &use_scrolled_window,
			"Use a GtkScrolledWindow as terminal container",
			NULL
		},
		{
			"scrollbar-policy", 'P', 0,
			G_OPTION_ARG_STRING, &scrollbar_policy_string,
			"Set the policy for the vertical scroolbar in the scrolled window (always|auto|never; default:always)",
			NULL
		},
		{
			"object-notifications", 'N', 0,
			G_OPTION_ARG_NONE, &show_object_notifications,
			"Print VteTerminal object notifications",
			NULL
		},
		{
			"output-file", 0, 0,
			G_OPTION_ARG_STRING, &output_file,
			"Save terminal contents to file at exit", NULL
		},
		{
			"pty-flags", 0, 0,
			G_OPTION_ARG_STRING, &pty_flags_string,
			"PTY flags set from default|no-utmp|no-wtmp|no-lastlog|no-helper|no-fallback", NULL
		},
		{ NULL }
	};
	GOptionContext *context;
	GError *error = NULL;
        VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
        GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
        VtePtyFlags pty_flags = VTE_PTY_DEFAULT;

	/* Have to do this early. */
	if (getenv("VTE_PROFILE_MEMORY")) {
		if (atol(getenv("VTE_PROFILE_MEMORY")) != 0) {
			g_mem_set_vtable(glib_mem_profiler_table);
		}
	}

	context = g_option_context_new (" - test VTE terminal emulation");
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free (context);
	if (error != NULL) {
		g_printerr ("Failed to parse command line arguments: %s\n",
				error->message);
		g_error_free (error);
		return 1;
	}

        if (cursor_shape_string) {
                cursor_shape = parse_enum(VTE_TYPE_TERMINAL_CURSOR_SHAPE, cursor_shape_string);
                g_free(cursor_shape_string);
        }
        if (scrollbar_policy_string) {
                scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string);
                g_free(scrollbar_policy_string);
        }
        if (pty_flags_string) {
                pty_flags |= parse_flags(VTE_TYPE_PTY_FLAGS, pty_flags_string);
                g_free(pty_flags_string);
        }

	if (!reverse) {
		back.red = back.green = back.blue = 0xffff;
		fore.red = fore.green = fore.blue = 0x0000;
	} else {
		back.red = back.green = back.blue = 0x0000;
		fore.red = fore.green = fore.blue = 0xffff;
	}

	highlight.red = highlight.green = highlight.blue = 0xc000;
	cursor.red = 0xffff;
	cursor.green = cursor.blue = 0x8000;
	tint.red = tint.green = tint.blue = 0;
	tint = back;

	gdk_window_set_debug_updates(debug);

	/* Create a window to hold the scrolling shell, and hook its
	 * delete event to the quit function.. */
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_container_set_resize_mode(GTK_CONTAINER(window),
				      GTK_RESIZE_IMMEDIATE);

	/* Set ARGB colormap */
	screen = gtk_widget_get_screen (window);
	colormap = gdk_screen_get_rgba_colormap (screen);
	if (colormap)
	    gtk_widget_set_colormap(window, colormap);

        if (use_scrolled_window) {
                scrolled_window = gtk_scrolled_window_new (NULL, NULL);
                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
                                               GTK_POLICY_NEVER, scrollbar_policy);
                gtk_container_add(GTK_CONTAINER(window), scrolled_window);
        } else {
                /* Create a box to hold everything. */
                hbox = gtk_hbox_new(0, FALSE);
                gtk_container_add(GTK_CONTAINER(window), hbox);
        }

	/* Create the terminal widget and add it to the scrolling shell. */
	widget = vte_terminal_new();
	terminal = VTE_TERMINAL (widget);
	if (!dbuffer) {
		gtk_widget_set_double_buffered(widget, dbuffer);
	}
        g_signal_connect(terminal, "child-exited", G_CALLBACK(child_exit_cb), NULL);
        if (show_object_notifications)
                g_signal_connect(terminal, "notify", G_CALLBACK(terminal_notify_cb), NULL);
        if (use_scrolled_window) {
                gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(terminal));
        } else {
                gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
        }

	/* Connect to the "char_size_changed" signal to set geometry hints
	 * whenever the font used by the terminal is changed. */
	if (use_geometry_hints) {
		char_size_changed(widget, 0, 0, window);
		g_signal_connect(widget, "char-size-changed",
				 G_CALLBACK(char_size_changed), window);
		g_signal_connect(widget, "realize",
				 G_CALLBACK(char_size_realized), window);
	}

	/* Connect to the "window_title_changed" signal to set the main
	 * window's title. */
	g_signal_connect(widget, "window-title-changed",
			 G_CALLBACK(window_title_changed), window);
	if (icon_title) {
		g_signal_connect(widget, "icon-title-changed",
				 G_CALLBACK(icon_title_changed), window);
	}

	/* Connect to the "status-line-changed" signal. */
	g_signal_connect(widget, "status-line-changed",
			 G_CALLBACK(status_line_changed), widget);

	/* Connect to the "button-press" event. */
	g_signal_connect(widget, "button-press-event",
			 G_CALLBACK(button_pressed), widget);

	/* Connect to application request signals. */
	g_signal_connect(widget, "iconify-window",
			 G_CALLBACK(iconify_window), window);
	g_signal_connect(widget, "deiconify-window",
			 G_CALLBACK(deiconify_window), window);
	g_signal_connect(widget, "raise-window",
			 G_CALLBACK(raise_window), window);
	g_signal_connect(widget, "lower-window",
			 G_CALLBACK(lower_window), window);
	g_signal_connect(widget, "maximize-window",
			 G_CALLBACK(maximize_window), window);
	g_signal_connect(widget, "restore-window",
			 G_CALLBACK(restore_window), window);
	g_signal_connect(widget, "refresh-window",
			 G_CALLBACK(refresh_window), window);
	g_signal_connect(widget, "resize-window",
			 G_CALLBACK(resize_window), window);
	g_signal_connect(widget, "move-window",
			 G_CALLBACK(move_window), window);

	/* Connect to font tweakage. */
	g_signal_connect(widget, "increase-font-size",
			 G_CALLBACK(increase_font_size), window);
	g_signal_connect(widget, "decrease-font-size",
			 G_CALLBACK(decrease_font_size), window);

        if (!use_scrolled_window) {
                /* Create the scrollbar for the widget. */
                scrollbar = gtk_vscrollbar_new(terminal->adjustment);
                gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0);
        }

	/* Set some defaults. */
	vte_terminal_set_audible_bell(terminal, audible);
	vte_terminal_set_visible_bell(terminal, !audible);
	vte_terminal_set_cursor_blink_mode(terminal, blink ? VTE_CURSOR_BLINK_SYSTEM : VTE_CURSOR_BLINK_OFF);
	vte_terminal_set_scroll_background(terminal, scroll);
	vte_terminal_set_scroll_on_output(terminal, FALSE);
	vte_terminal_set_scroll_on_keystroke(terminal, TRUE);
	vte_terminal_set_scrollback_lines(terminal, lines);
	vte_terminal_set_mouse_autohide(terminal, TRUE);
	if (background != NULL) {
		vte_terminal_set_background_image_file(terminal,
						       background);
	}
	if (transparent) {
		vte_terminal_set_background_transparent(terminal,
							TRUE);
	}
	vte_terminal_set_background_tint_color(terminal, &tint);
	vte_terminal_set_colors(terminal, &fore, &back, NULL, 0);
	vte_terminal_set_opacity(terminal, 0xdddd);
	if (highlight_set) {
		vte_terminal_set_color_highlight(terminal,
						 &highlight);
	}
	if (cursor_set) {
		vte_terminal_set_color_cursor(terminal, &cursor);
	}
	if (termcap != NULL) {
		vte_terminal_set_emulation(terminal, termcap);
	}
        vte_terminal_set_cursor_shape(terminal, cursor_shape);

	/* Set the default font. */
	vte_terminal_set_font_from_string_full(terminal, font,
					       antialias ? VTE_ANTI_ALIAS_USE_DEFAULT : VTE_ANTI_ALIAS_FORCE_DISABLE);

	/* Match "abcdefg". */
	if (dingus) {
		int id;
		GRegex *regex;
		regex = g_regex_new (DINGUS1, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_GUMBY);
		regex = g_regex_new (DINGUS2, 0, 0, NULL);
		id = vte_terminal_match_add_gregex(terminal, regex, 0);
		g_regex_unref (regex);
		vte_terminal_match_set_cursor_type(terminal,
						   id, GDK_HAND1);
	}

	if (console) {
		/* Open a "console" connection. */
		int consolefd = -1, yes = 1, watch;
		GIOChannel *channel;
		consolefd = open("/dev/console", O_RDONLY | O_NOCTTY);
		if (consolefd != -1) {
			/* Assume failure. */
			console = FALSE;
#ifdef TIOCCONS
			if (ioctl(consolefd, TIOCCONS, &yes) != -1) {
				/* Set up a listener. */
				channel = g_io_channel_unix_new(consolefd);
				watch = g_io_add_watch(channel,
						       G_IO_IN,
						       read_and_feed,
						       widget);
				g_signal_connect(widget,
						 "eof",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "child-exited",
						 G_CALLBACK(disconnect_watch),
						 GINT_TO_POINTER(watch));
				g_signal_connect(widget,
						 "realize",
						 G_CALLBACK(take_xconsole_ownership),
						 NULL);
#ifdef VTE_DEBUG
				vte_terminal_feed(terminal,
						  "Console log for ...\r\n",
						  -1);
#endif
				/* Record success. */
				console = TRUE;
			}
#endif
		} else {
			/* Bail back to normal mode. */
			g_warning(_("Could not open console.\n"));
			close(consolefd);
			console = FALSE;
		}
	}

	if (!console) {
		if (shell) {
                        GError *err = NULL;
                        char **command_argv = NULL;
                        int command_argc;
                        GPid pid = -1;

			_VTE_DEBUG_IF(VTE_DEBUG_MISC)
				vte_terminal_feed(terminal, message, -1);

                        if (command == NULL)
                                command = "/bin/sh"; // FIXMEchpe

                        if (command != NULL) {
                                if (!g_shell_parse_argv(command, &command_argc, &command_argv, &err) ||
                                    !vte_terminal_fork_command_full(terminal,
                                                                    pty_flags,
                                                                    NULL,
                                                                    command_argv,
                                                                    env_add,
                                                                    G_SPAWN_SEARCH_PATH,
                                                                    NULL, NULL,
                                                                    &pid,
                                                                    &err)) {
                                        g_warning("Failed to fork: %s\n", err->message);
                                        g_error_free(err);
                                } else {
                                        g_print("Fork succeeded, PID %d\n", pid);
                                }
                        }
                        g_strfreev(command_argv);
	#ifdef VTE_DEBUG
			if (command == NULL) {
				vte_terminal_feed_child(terminal,
							"pwd\n", -1);
			}
	#endif
		} else {
			long i;
			i = vte_terminal_forkpty(terminal,
						 env_add, working_directory,
						 TRUE, TRUE, TRUE);
			switch (i) {
			case -1:
				/* abnormal */
				g_warning("Error in vte_terminal_forkpty(): %s",
					  strerror(errno));
				break;
			case 0:
				/* child */
				for (i = 0; ; i++) {
					switch (i % 3) {
					case 0:
					case 1:
						g_print("%ld\n", i);
						break;
					case 2:
						g_printerr("%ld\n", i);
						break;
					}
					sleep(1);
				}
				_exit(0);
				break;
			default:
				g_print("Child PID is %ld (mine is %ld).\n",
					(long) i, (long) getpid());
				/* normal */
				break;
			}
		}
	}

	g_object_set_data (G_OBJECT (widget), "output_file", (gpointer) output_file);

	/* Go for it! */
	g_signal_connect(widget, "child-exited", G_CALLBACK(child_exited), window);
	g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), widget);

	add_weak_pointer(G_OBJECT(widget), &widget);
	add_weak_pointer(G_OBJECT(window), &window);

        gtk_widget_realize(widget);
        if (geometry) {
                if (!gtk_window_parse_geometry (GTK_WINDOW(window), geometry)) {
                        g_warning (_("Could not parse the geometry spec passed to --geometry"));
                }
        }

	gtk_widget_show_all(window);

	gtk_main();

	g_assert(widget == NULL);
	g_assert(window == NULL);

	if (keep) {
		while (TRUE) {
			sleep(60);
		}
	}

	return 0;
}
gboolean
mobile_helper_get_secrets (NMDeviceModemCapabilities capabilities,
                           SecretsRequest *req,
                           GError **error)
{
	MobileHelperSecretsInfo *info = (MobileHelperSecretsInfo *) req;
	GtkWidget *widget;
	GtkEntry *secret_entry = NULL;

	applet_secrets_request_set_free_func (req, free_secrets_info);

	if (!req->hints || !g_strv_length (req->hints)) {
		g_set_error (error,
		             NM_SECRET_AGENT_ERROR,
		             NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
		             "%s.%d (%s): missing secrets hints.",
		             __FILE__, __LINE__, __func__);
		return FALSE;
	}
	info->secret_name = g_strdup (req->hints[0]);

	/* Convert the input capabilities mask into a single value */
	if (capabilities & NM_DEVICE_MODEM_CAPABILITY_LTE)
		/* All LTE modems treated as GSM/UMTS for the settings */
		info->capability = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
	else if (capabilities & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS)
		info->capability = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
	else if (capabilities & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
		info->capability = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
	else {
		g_set_error (error,
		             NM_SECRET_AGENT_ERROR,
		             NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
		             "%s.%d (%s): unknown modem capabilities (0x%X).",
		             __FILE__, __LINE__, __func__, capabilities);
		return FALSE;
	}

	if (!strcmp (info->secret_name, NM_SETTING_GSM_PIN)) {
		widget = ask_for_pin (&secret_entry);
	} else if (!strcmp (info->secret_name, NM_SETTING_GSM_PASSWORD) ||
	           !strcmp (info->secret_name, NM_SETTING_CDMA_PASSWORD))
		widget = applet_mobile_password_dialog_new (req->connection, &secret_entry);
	else {
		g_set_error (error,
		             NM_SECRET_AGENT_ERROR,
		             NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
		             "%s.%d (%s): unknown secrets hint '%s'.",
		             __FILE__, __LINE__, __func__, info->secret_name);
		return FALSE;
	}
	info->dialog = widget;
	info->secret_entry = secret_entry;

	if (!widget || !secret_entry) {
		g_set_error (error,
		             NM_SECRET_AGENT_ERROR,
		             NM_SECRET_AGENT_ERROR_INTERNAL_ERROR,
		             "%s.%d (%s): error asking for mobile secrets.",
		             __FILE__, __LINE__, __func__);
		return FALSE;
	}

	g_signal_connect (widget, "response", G_CALLBACK (get_secrets_cb), info);

	gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ALWAYS);
	gtk_widget_realize (GTK_WIDGET (widget));
	gtk_window_present (GTK_WINDOW (widget));

	return TRUE;
}
Example #20
0
GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::string context)
{
	if (LLWindowSDL::ll_try_gtk_init())
	{
		GtkWidget *win = NULL;
		GtkFileChooserAction pickertype =
			is_save?
			(is_folder?
			 GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER :
			 GTK_FILE_CHOOSER_ACTION_SAVE) :
			(is_folder?
			 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER :
			 GTK_FILE_CHOOSER_ACTION_OPEN);

		win = gtk_file_chooser_dialog_new(NULL, NULL,
						  pickertype,
						  GTK_STOCK_CANCEL,
						   GTK_RESPONSE_CANCEL,
						  is_folder ?
						  GTK_STOCK_APPLY :
						  (is_save ? 
						   GTK_STOCK_SAVE :
						   GTK_STOCK_OPEN),
						   GTK_RESPONSE_ACCEPT,
						  (gchar *)NULL);
		mCurContextName = context;

		// get the default path for this usage context if it's been
		// seen before.
		std::map<std::string,std::string>::iterator
			this_path = mContextToPathMap.find(context);
		if (this_path != mContextToPathMap.end())
		{
			gtk_file_chooser_set_current_folder
				(GTK_FILE_CHOOSER(win),
				 this_path->second.c_str());
		}

#  if LL_X11
		// Make GTK tell the window manager to associate this
		// dialog with our non-GTK raw X11 window, which should try
		// to keep it on top etc.
		Window XWindowID = LLWindowSDL::get_SDL_XWindowID();
		if (None != XWindowID)
		{
			gtk_widget_realize(GTK_WIDGET(win)); // so we can get its gdkwin
			GdkWindow *gdkwin = gdk_window_foreign_new(XWindowID);
			gdk_window_set_transient_for(GTK_WIDGET(win)->window,
						     gdkwin);
		}
		else
		{
			llwarns << "Hmm, couldn't get xwid to use for transient." << llendl;
		}
#  endif //LL_X11

		g_signal_connect (GTK_FILE_CHOOSER(win),
				  "response",
				  G_CALLBACK(LLFilePicker::chooser_responder),
				  this);

		gtk_window_set_modal(GTK_WINDOW(win), TRUE);

		/* GTK 2.6: if (is_folder)
			gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(win),
			TRUE); */

		return GTK_WINDOW(win);
	}
	else
	{
		return NULL;
	}
}
Example #21
0
int   l_zarnah(int metka_rr, //0-ввод и корек. 1-выбор
iceb_u_str *kod,iceb_u_str *naim,GtkWidget *wpredok)
{
l_zarnah_data data;
char bros[512];
GdkColor color;

data.poisk.clear_data();
data.metka_rr=metka_rr;

data.window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(data.window),TRUE);

//gtk_window_set_default_size (GTK_WINDOW  (data.window),400,-1);
//gdk_color_parse("black",&color);
//gtk_widget_modify_bg(data.window,GTK_STATE_NORMAL,&color);


sprintf(bros,"%s %s",name_system,gettext("Список начислений"));

gtk_window_set_title (GTK_WINDOW (data.window),bros);
gtk_container_set_border_width (GTK_CONTAINER (data.window), 5);

gtk_signal_connect(GTK_OBJECT(data.window),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);


if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }

gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(l_zarnah_key_press),&data);
gtk_signal_connect_after(GTK_OBJECT(data.window),"key_release_event",GTK_SIGNAL_FUNC(iceb_key_release),&data.kl_shift);

GtkWidget *hbox = gtk_hbox_new (FALSE, 1);
gtk_container_add (GTK_CONTAINER (data.window), hbox);

GtkWidget *vbox1 = gtk_vbox_new (FALSE, 1);
GtkWidget *vbox2 = gtk_vbox_new (FALSE, 1);

gtk_box_pack_start (GTK_BOX (hbox), vbox1, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
gtk_widget_show(hbox);

data.label_kolstr=gtk_label_new (gettext("Список начислений"));
//gdk_color_parse("green",&color);
//gtk_widget_modify_fg(data.label_kolstr,GTK_STATE_NORMAL,&color);


gtk_box_pack_start (GTK_BOX (vbox2),data.label_kolstr,FALSE, FALSE, 0);

gtk_widget_show(vbox1);
gtk_widget_show(vbox2);

data.label_poisk=gtk_label_new ("");
gdk_color_parse("red",&color);
gtk_widget_modify_fg(data.label_poisk,GTK_STATE_NORMAL,&color);

gtk_box_pack_start (GTK_BOX (vbox2),data.label_poisk,FALSE, FALSE, 0);

data.sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_usize(GTK_WIDGET(data.sw),400,300);

gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (data.sw),GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (data.sw),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
//gtk_box_pack_start (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (vbox2), data.sw, TRUE, TRUE, 0);

//Кнопки
GtkTooltips *tooltips[KOL_F_KL];

sprintf(bros,"F2 %s",gettext("Запись"));
data.knopka[FK2]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK2], TRUE, TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK2]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
tooltips[FK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK2],data.knopka[FK2],gettext("Ввод новой записи"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK2]),(gpointer)FK2);
gtk_widget_show(data.knopka[FK2]);

sprintf(bros,"%sF2 %s",RFK,gettext("Корректировать"));
data.knopka[SFK2]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK2],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK2]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
tooltips[SFK2]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK2],data.knopka[SFK2],gettext("Корректировка выбранной записи"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK2]),(gpointer)SFK2);
gtk_widget_show(data.knopka[SFK2]);


sprintf(bros,"F3 %s",gettext("Удалить"));
data.knopka[FK3]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK3],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK3]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
tooltips[FK3]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK3],data.knopka[FK3],gettext("Удаление выбранной записи"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK3]),(gpointer)FK3);
gtk_widget_show(data.knopka[FK3]);

sprintf(bros,"%sF3 %s",RFK,gettext("Удалить"));
data.knopka[SFK3]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[SFK3],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[SFK3]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
tooltips[SFK3]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[SFK3],data.knopka[SFK3],gettext("Удалить неиспользуемые коды"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[SFK3]),(gpointer)SFK3);
gtk_widget_show(data.knopka[SFK3]);

sprintf(bros,"F4 %s",gettext("Поиск"));
data.knopka[FK4]=gtk_button_new_with_label(bros);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK4]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK4],TRUE,TRUE, 0);
tooltips[FK4]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK4],data.knopka[FK4],gettext("Поиск нужных записей"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK4]),(gpointer)FK4);
gtk_widget_show(data.knopka[FK4]);

sprintf(bros,"F5 %s",gettext("Печать"));
data.knopka[FK5]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1), data.knopka[FK5],TRUE,TRUE, 0);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK5]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
tooltips[FK5]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK5],data.knopka[FK5],gettext("Распечатка записей"),NULL);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK5]),(gpointer)FK5);
gtk_widget_show(data.knopka[FK5]);

sprintf(bros,"F10 %s",gettext("Выход"));
data.knopka[FK10]=gtk_button_new_with_label(bros);
gtk_box_pack_start(GTK_BOX(vbox1),data.knopka[FK10],TRUE,TRUE, 0);
tooltips[FK10]=gtk_tooltips_new();
gtk_tooltips_set_tip(tooltips[FK10],data.knopka[FK10],gettext("Завершение работы в этом окне"),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[FK10]), "clicked",GTK_SIGNAL_FUNC(l_zarnah_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[FK10]),(gpointer)FK10);
gtk_widget_show(data.knopka[FK10]);


gtk_widget_realize(data.window);
gdk_window_set_cursor(data.window->window,gdk_cursor_new(ICEB_CURSOR));

gtk_widget_grab_focus(data.knopka[FK10]);

l_zarnah_create_list(&data);

gtk_widget_show(data.window);
if(metka_rr == 0)
  gtk_window_maximize(GTK_WINDOW(data.window));
//gtk_window_fullscreen(GTK_WINDOW(data.window));


gtk_main();

if(data.metka_voz == 0)
 {
  kod->new_plus(data.kodv.ravno());
  naim->new_plus(data.naimv.ravno());
 }

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

return(data.metka_voz);

}
Example #22
0
gint main (gint argc, gchar *argv[])
{
    GtkWidget *area;
    gst_init (&argc, &argv);
    gtk_init (&argc, &argv);

    GstElement* pipeline = gst_pipeline_new ("pipeline");
    GstElement* videosrc  = gst_element_factory_make ("videotestsrc", "videotestsrc");
    GstElement* videosink = gst_element_factory_make ("glimagesink", "glimagesink");

    gst_bin_add_many (GST_BIN (pipeline), videosrc, videosink, NULL);

    gboolean link_ok = gst_element_link_many(videosrc, videosink, NULL) ;
    if(!link_ok)
    {
        g_warning("Failed to link an element!\n") ;
        return -1;
    }

    //set window id on this event
    GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    gst_bus_add_signal_watch (bus);
    g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline);
    g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline);
    g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline);

    gst_element_set_state(pipeline, GST_STATE_READY);

    area = gtk_drawing_area_new();
    gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL);
    gst_object_unref (bus);

    //window that contains an area where the video is drawn
    GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_size_request (window, 640, 480);
    gtk_window_move (GTK_WINDOW (window), 300, 10);
    gtk_window_set_title (GTK_WINDOW (window), "glimagesink implement the gstvideooverlay interface");
    GdkGeometry geometry;
    geometry.min_width = 1;
    geometry.min_height = 1;
    geometry.max_width = -1;
    geometry.max_height = -1;
    gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry, GDK_HINT_MIN_SIZE);

    //window to control the states
    GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    geometry.min_width = 1;
    geometry.min_height = 1;
    geometry.max_width = -1;
    geometry.max_height = -1;
    gtk_window_set_geometry_hints (GTK_WINDOW (window_control), window_control, &geometry, GDK_HINT_MIN_SIZE);
    gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE);
    gtk_window_move (GTK_WINDOW (window_control), 10, 10);
    GtkWidget* table = gtk_grid_new ();
    gtk_container_add (GTK_CONTAINER (window_control), table);

    //control state null
    GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL");
    g_signal_connect (G_OBJECT (button_state_null), "clicked",
        G_CALLBACK (button_state_null_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), button_state_null, 0, 0, 1, 1);
    gtk_widget_show (button_state_null);

    //control state ready
    GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY");
    g_signal_connect (G_OBJECT (button_state_ready), "clicked",
        G_CALLBACK (button_state_ready_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), button_state_ready, 0, 1, 1, 1);
    gtk_widget_show (button_state_ready);

    //control state paused
    GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED");
    g_signal_connect (G_OBJECT (button_state_paused), "clicked",
        G_CALLBACK (button_state_paused_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), button_state_paused, 0, 2, 1, 1);
    gtk_widget_show (button_state_paused);

    //control state playing
    GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING");
    g_signal_connect (G_OBJECT (button_state_playing), "clicked",
        G_CALLBACK (button_state_playing_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), button_state_playing, 0, 3, 1, 1);
    gtk_widget_show (button_state_playing);

    //change framerate
    GtkWidget* slider_fps = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL,
        1, 30, 2);
    g_signal_connect (G_OBJECT (slider_fps), "format-value",
        G_CALLBACK (slider_fps_cb), pipeline);
    gtk_grid_attach (GTK_GRID (table), slider_fps, 1, 0, 1, 4);
    gtk_widget_show (slider_fps);

    gtk_widget_show (table);
    gtk_widget_show (window_control);

    //configure the pipeline
    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline);

    //area where the video is drawn
    gtk_container_add (GTK_CONTAINER (window), area);

    gtk_widget_realize(area);

    //needed when being in GST_STATE_READY, GST_STATE_PAUSED
    //or resizing/obscuring the window
    g_signal_connect(area, "draw", G_CALLBACK(draw_cb), videosink);

    gtk_widget_show_all (window);

    gst_element_set_state(pipeline, GST_STATE_PLAYING);

    gtk_main();

    return 0;
}
Example #23
0
void ReallyReStart (GtkWidget *rrw, GtkFileSelection *rrfs)
{
  gfloat pvalue = 0;
  if ((ihistory > 0) && (isave == 1))
  {
    JudgeBoard ('w');
    Save ();
  }
  if (isavemes == 1)
  {
    Message (ssavemes, 2, 1);
  }

  x = 0;
  y = 0;
  iCapturedW = 0;
  iCapturedB = 0;
  ilimit = 0;
  ijustundo = 0;
  ifilestuff = 0;
  iduh = 0;
  iother = 0;
  isave = 1;
  iquit = 0;
  isavemes = 0;
  iiamblack = 0;
  ihistory = 0;
  imoves = 0;
  ilastmoveb = 1000;
  ilastmovew = 1000;
  StatusBar ();

  for (iPlace = 1; iPlace <= 361; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mme");
  }
  sprintf (Board[1], "%s", "lte");
  for (iPlace = 2; iPlace <= 18; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mte");
  }
  sprintf (Board[19], "%s", "rte");
  sprintf (Board[20], "%s", "lme");
  sprintf (Board[38], "%s", "rme");
  sprintf (Board[39], "%s", "lme");
  sprintf (Board[57], "%s", "rme");
  sprintf (Board[58], "%s", "lme");
  sprintf (Board[61], "%s", "mms");
  sprintf (Board[67], "%s", "mms");
  sprintf (Board[73], "%s", "mms");
  sprintf (Board[76], "%s", "rme");
  sprintf (Board[77], "%s", "lme");
  sprintf (Board[95], "%s", "rme");
  sprintf (Board[96], "%s", "lme");
  sprintf (Board[114], "%s", "rme");
  sprintf (Board[115], "%s", "lme");
  sprintf (Board[133], "%s", "rme");
  sprintf (Board[134], "%s", "lme");
  sprintf (Board[152], "%s", "rme");
  sprintf (Board[153], "%s", "lme");
  sprintf (Board[171], "%s", "rme");
  sprintf (Board[172], "%s", "lme");
  sprintf (Board[175], "%s", "mms");
  sprintf (Board[181], "%s", "mms");
  sprintf (Board[187], "%s", "mms");
  sprintf (Board[190], "%s", "rme");
  sprintf (Board[191], "%s", "lme");
  sprintf (Board[209], "%s", "rme");
  sprintf (Board[210], "%s", "lme");
  sprintf (Board[228], "%s", "rme");
  sprintf (Board[229], "%s", "lme");
  sprintf (Board[247], "%s", "rme");
  sprintf (Board[248], "%s", "lme");
  sprintf (Board[266], "%s", "rme");
  sprintf (Board[267], "%s", "lme");
  sprintf (Board[285], "%s", "rme");
  sprintf (Board[286], "%s", "lme");
  sprintf (Board[289], "%s", "mms");
  sprintf (Board[295], "%s", "mms");
  sprintf (Board[301], "%s", "mms");
  sprintf (Board[304], "%s", "rme");
  sprintf (Board[305], "%s", "lme");
  sprintf (Board[323], "%s", "rme");
  sprintf (Board[324], "%s", "lme");
  sprintf (Board[342], "%s", "rme");
  sprintf (Board[343], "%s", "lue");
  for (iPlace = 344; iPlace <= 360; iPlace++)
  {
    sprintf (Board[iPlace], "%s", "mue");
  }
  sprintf (Board[361], "%s", "rue");

  DoHandicap ();

  for (ibuttonrr = 1; ibuttonrr <= 361; ibuttonrr++)
  {
    sprintf (History[ihistory][ibuttonrr], "%s", Board[ibuttonrr]);
  }
  gtk_widget_hide (window1);

  loadingw = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_position (GTK_WINDOW (loadingw), GTK_WIN_POS_CENTER);
  gtk_window_set_title (GTK_WINDOW (loadingw), "loading...");
  gtk_signal_connect (GTK_OBJECT (loadingw), "delete_event",
    GTK_SIGNAL_FUNC (Quit), NULL);
  gtk_window_set_policy (GTK_WINDOW (loadingw), 0, 0, 1);
  gtk_container_border_width (GTK_CONTAINER (loadingw), 0);
  gtk_widget_realize (loadingw);

  lbox1 = gtk_vbox_new (FALSE, 0);
  gtk_container_border_width (GTK_CONTAINER (lbox1), 0);
  gtk_container_add (GTK_CONTAINER (loadingw), lbox1);
  gtk_widget_show (lbox1);
  lbox2 = gtk_hbox_new (FALSE, 0);
  gtk_container_border_width (GTK_CONTAINER (lbox2), 0);
  gtk_box_pack_start (GTK_BOX (lbox1), lbox2, FALSE, FALSE, 0);
  gtk_widget_show (lbox2);
  ltable1 = gtk_table_new (1, 2, FALSE);
  gtk_box_pack_start (GTK_BOX (lbox2), ltable1, TRUE, TRUE, 0);
  gtk_widget_show (ltable1);

#ifdef USE_GNOME
  im9 = gdk_imlib_load_image (PKGDATADIR"pix/gologog.png");
#else
  im9 = gdk_imlib_load_image (PKGDATADIR"pix/gologo.png");
#endif
  w9 = im9->rgb_width;
  h9 = im9->rgb_height;
  gdk_imlib_render (im9, w9, h9);
  lpixmap = gdk_imlib_move_image (im9);
  lpixmapwid = gtk_pixmap_new (lpixmap, NULL);
  gtk_table_attach (GTK_TABLE (ltable1), lpixmapwid, 0, 1, 0, 1,
    GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (lpixmapwid);
  gdk_flush ();

  lbar = gtk_progress_bar_new ();
  gtk_table_attach (GTK_TABLE (ltable1), lbar, 0, 1, 1, 2,
    GTK_FILL, GTK_FILL, 0, 0);
  gtk_widget_show (lbar);

  gtk_widget_show (loadingw);
  while (gtk_events_pending ())
  {
    gtk_main_iteration ();
  }

  for (ibuttonrr = 1; ibuttonrr <= 361; ibuttonrr++)
  {
    PixmapOnButton (ibuttonrr);
    pvalue = lprogress (pvalue);
  }
  gtk_widget_destroy (loadingw);
  if (itooltips == 0)
  {
    itooltips = 1;
    Tooltips ();
  }
  gtk_widget_show (window1);
}
Example #24
0
void iceb_aboutz(GtkWidget *wpredok)
{

class glmenu_data data;


data.window=gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_position( GTK_WINDOW(data.window),ICEB_POS_CENTER);

gtk_window_set_title(GTK_WINDOW(data.window),gettext("Разработчик"));

//Установка ширины окантовки внутренней области   
gtk_container_set_border_width(GTK_CONTAINER(data.window),10);
gtk_signal_connect(GTK_OBJECT(data.window),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);

gtk_signal_connect_after(GTK_OBJECT(data.window),"key_press_event",GTK_SIGNAL_FUNC(iceb_aboutz_key_press),&data);

if(wpredok != NULL)
 {
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR_GDITE));
  //Удерживать окно над породившем его окном всегда
  gtk_window_set_transient_for(GTK_WINDOW(data.window),GTK_WINDOW(wpredok));
  //Закрыть окно если окно предок удалено
  gtk_window_set_destroy_with_parent(GTK_WINDOW(data.window),TRUE);
 }

GtkWidget *vbox=gtk_vbox_new(FALSE,2);
gtk_container_add(GTK_CONTAINER(data.window),vbox);




//Установка ширины окантовки внутренней области   
gtk_container_set_border_width(GTK_CONTAINER(vbox),5);
gtk_widget_realize(data.window);
//gtk_widget_show(data.window);


//GtkStyle *style;
//GdkPixmap *pixmap;
//GdkBitmap *mask;
//GtkWidget *pixmapWidget;

//style = gtk_widget_get_style(data.window);
//pixmap=gdk_pixmap_create_from_xpm_d(data.window->window,&mask,&style->bg[GTK_STATE_NORMAL],
//                                    (gchar **)port_xpm);
//pixmapWidget=gtk_pixmap_new(pixmap,mask);
//gtk_container_add(GTK_CONTAINER(vbox),pixmapWidget);



//char bros[512];

//sprintf(bros,"%s:",gettext("LinuxBuh.RU"));
//sprintf(bros,"%s:",gettext(version));
//GtkWidget *name=gtk_label_new(iceb_u_toutf(bros));
//GtkWidget *version1=gtk_label_new(iceb_u_toutf(bros));
//name=gtk_label_new(gettext("Название программы"));
//gtk_box_pack_start((GtkBox*)vbox,name,TRUE,TRUE,0);
//version1=gtk_label_new(gettext("Версия программы"));
//gtk_box_pack_start((GtkBox*)vbox,version1,TRUE,TRUE,0);


printf("%s\n",__FUNCTION__);

GtkWidget *about=gtk_about_dialog_new();
gtk_signal_connect(GTK_OBJECT(about),"response",GTK_SIGNAL_FUNC(gtk_widget_destroy),NULL);
//g_signal_connect_swapped(about,"response",G_CALLBACK(gtk_widget_destroy),about);

gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(about),"iceBw");
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),version);
gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),"http://iceb.com.ua");
gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(about),gettext("Бухгалтерский учёт"));
//gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about),"Copyright \302\251 Aleksandr Belykh");
gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about),"Copyright © Aleksandr Belykh");



const gchar *avtor[]={"Aleksandr Belykh","<[email protected]>","http://www.iceb.vc.ukrtel.net","tel:+380676654526"};
 
gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about),avtor);


gtk_dialog_run(GTK_DIALOG(about));

gtk_box_pack_start((GtkBox*)vbox,about,TRUE,TRUE,0);

data.knopka[VIHOD]=gtk_button_new_with_label(gettext("Выход"));
//tooltips[VIHOD]=gtk_tooltips_new();
//gtk_tooltips_set_tip(tooltips[VIHOD],data.knopka[VIHOD],gettext("Завершение работы в этом окне."),NULL);
gtk_signal_connect(GTK_OBJECT(data.knopka[VIHOD]),"clicked",GTK_SIGNAL_FUNC(iceb_aboutz_knopka),&data);
gtk_object_set_user_data(GTK_OBJECT(data.knopka[VIHOD]),(gpointer)VIHOD);
gtk_box_pack_start(GTK_BOX(vbox), data.knopka[VIHOD], TRUE, TRUE,0);



gtk_widget_grab_focus(data.knopka[0]);

gtk_widget_show_all (data.window);


gtk_main();

if(wpredok != NULL)
  gdk_window_set_cursor(wpredok->window,gdk_cursor_new(ICEB_CURSOR));

}
Example #25
0
static gboolean
na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
                                   GdkScreen     *screen)
{
  GdkDisplay *display;
  Screen     *xscreen;
  GtkWidget  *invisible;
  GdkWindow  *window;
  char       *selection_atom_name;
  guint32     timestamp;

  g_return_val_if_fail (NA_IS_TRAY_MANAGER (manager), FALSE);
  g_return_val_if_fail (manager->screen == NULL, FALSE);

  /* If there's already a manager running on the screen
   * we can't create another one.
   */
#if 0
  if (na_tray_manager_check_running_screen_x11 (screen))
    return FALSE;
#endif

  manager->screen = screen;

  display = gdk_screen_get_display (screen);
  xscreen = GDK_SCREEN_XSCREEN (screen);

  invisible = gtk_invisible_new_for_screen (screen);
  gtk_widget_realize (invisible);

  gtk_widget_add_events (invisible,
                         GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);

  selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
                                         gdk_screen_get_number (screen));
  manager->selection_atom = gdk_atom_intern (selection_atom_name, FALSE);
  g_free (selection_atom_name);

  manager->invisible = invisible;
  g_object_ref (G_OBJECT (manager->invisible));

  na_tray_manager_set_orientation_property (manager);
  na_tray_manager_set_visual_property (manager);

  window = gtk_widget_get_window (invisible);

  timestamp = gdk_x11_get_server_time (window);

  /* Check if we could set the selection owner successfully */
  if (gdk_selection_owner_set_for_display (display,
                                           window,
                                           manager->selection_atom,
                                           timestamp,
                                           TRUE))
    {
      XClientMessageEvent xev;
      GdkAtom             opcode_atom;
      GdkAtom             message_data_atom;

      xev.type = ClientMessage;
      xev.window = RootWindowOfScreen (xscreen);
      xev.message_type = gdk_x11_get_xatom_by_name_for_display (display,
                                                                "MANAGER");

      xev.format = 32;
      xev.data.l[0] = timestamp;
      xev.data.l[1] = gdk_x11_atom_to_xatom_for_display (display,
                                                         manager->selection_atom);
      xev.data.l[2] = GDK_WINDOW_XWINDOW (window);
      xev.data.l[3] = 0;        /* manager specific data */
      xev.data.l[4] = 0;        /* manager specific data */

      XSendEvent (GDK_DISPLAY_XDISPLAY (display),
                  RootWindowOfScreen (xscreen),
                  False, StructureNotifyMask, (XEvent *)&xev);

      opcode_atom = gdk_atom_intern ("_NET_SYSTEM_TRAY_OPCODE", FALSE);
      manager->opcode_atom = gdk_x11_atom_to_xatom_for_display (display,
                                                                opcode_atom);

      message_data_atom = gdk_atom_intern ("_NET_SYSTEM_TRAY_MESSAGE_DATA",
                                           FALSE);

      /* Add a window filter */
#if 0
      /* This is for when we lose the selection of _NET_SYSTEM_TRAY_Sx */
      g_signal_connect (invisible, "selection-clear-event",
                        G_CALLBACK (na_tray_manager_selection_clear_event),
                        manager);
#endif
      /* This is for SYSTEM_TRAY_REQUEST_DOCK and SelectionClear */
      gdk_window_add_filter (window,
                             na_tray_manager_window_filter, manager);
      /* This is for SYSTEM_TRAY_BEGIN_MESSAGE and SYSTEM_TRAY_CANCEL_MESSAGE */
      gdk_display_add_client_message_filter (display, opcode_atom,
                                             na_tray_manager_handle_client_message_opcode,
                                             manager);
      /* This is for _NET_SYSTEM_TRAY_MESSAGE_DATA */
      gdk_display_add_client_message_filter (display, message_data_atom,
                                             na_tray_manager_handle_client_message_message_data,
                                             manager);
      return TRUE;
    }
  else
    {
      gtk_widget_destroy (invisible);
      g_object_unref (invisible);
      manager->invisible = NULL;

      manager->screen = NULL;

      return FALSE;
    }
}
Example #26
0
gboolean NewGLArea(GtkWidget* vboxwin)
{
	GtkWidget* frame;
  /*
	gchar *info_str;
  */
	GtkWidget* table; 
	GtkWidget* hboxtoolbar; 
	GtkWidget* vbox; 

#define DIMAL 13
	int k = 0;
	GdkGLConfig *glconfig;

	k = 0;
	/*
	if(openGLOptions.alphaSize!=0)
	{
		attrlist[k++] = GDK_GL_ALPHA_SIZE;
		attrlist[k++] = 1;
	}
	if(openGLOptions.depthSize!=0)
	{
		attrlist[k++] = GDK_GL_DEPTH_SIZE;
		attrlist[k++] = 1;
	}
	if(openGLOptions.doubleBuffer!=0) attrlist[k++] = GDK_GL_DOUBLEBUFFER;
	*/
	set_show_symbols(FALSE);
	set_show_distances(FALSE);
	trackball(Quat , 0.0, 0.0, 0.0, 0.0);

	frame = gtk_frame_new (NULL);
	gtk_container_set_border_width (GTK_CONTAINER (frame), 0);
  	gtk_frame_set_shadow_type( GTK_FRAME(frame),GTK_SHADOW_ETCHED_OUT);
	gtk_box_pack_start (GTK_BOX (vboxwin), frame, TRUE, TRUE, 0);
	gtk_widget_show (frame);

	table = gtk_table_new(2,2,FALSE);
	gtk_container_add(GTK_CONTAINER(frame),table);
	gtk_widget_show(GTK_WIDGET(table));

/*
	hboxtoolbar = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hboxtoolbar);
	gtk_table_attach(GTK_TABLE(table), hboxtoolbar,0,1,0,1, (GtkAttachOptions)(GTK_FILL | GTK_SHRINK  ), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND ), 0,0);
*/

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_table_attach(GTK_TABLE(table), vbox, 0,1, 0,1, GTK_FILL , GTK_FILL, 0, 0);
	gtk_widget_show(vbox);
	add_menu_button(PrincipalWindow, vbox);
	hboxtoolbar = gtk_hbox_new (FALSE, 0);
  	gtk_box_pack_start (GTK_BOX (vbox), hboxtoolbar, TRUE, TRUE, 0);	
	gtk_widget_show(hboxtoolbar);


	gtk_quit_add_destroy(1, GTK_OBJECT(PrincipalWindow));

	/* Create new OpenGL widget. */
	/* pthread_mutex_init (&theRender_mutex, NULL);*/
	GLArea = gtk_drawing_area_new ();
	gtk_drawing_area_size(GTK_DRAWING_AREA(GLArea),(gint)(ScreenHeight*0.2),(gint)(ScreenHeight*0.2));
	gtk_table_attach(GTK_TABLE(table),GLArea,1,2,0,1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND  ), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND ), 0,0);
	gtk_widget_show(GTK_WIDGET(GLArea));
	/* Events for widget must be set before X Window is created */
	gtk_widget_set_events(GLArea,
			GDK_EXPOSURE_MASK|
			GDK_BUTTON_PRESS_MASK|
			GDK_BUTTON_RELEASE_MASK|
			GDK_POINTER_MOTION_MASK|
			GDK_POINTER_MOTION_HINT_MASK |
			GDK_SCROLL_MASK
			);
	/* prepare GL */
	glconfig = configure_gl();
	if (!glconfig) { g_assert_not_reached (); }
	if (!gtk_widget_set_gl_capability (GLArea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) { g_assert_not_reached (); }

	g_signal_connect(G_OBJECT(GLArea), "realize", G_CALLBACK(init), NULL);
	g_signal_connect(G_OBJECT(GLArea), "configure_event", G_CALLBACK(reshape), NULL);
	g_signal_connect(G_OBJECT(GLArea), "expose_event", G_CALLBACK(draw), NULL);
	/*gtk_widget_set_size_request(GTK_WIDGET(GLArea ),(gint)(ScreenHeight*0.2),(gint)(ScreenHeight*0.2));*/
  

	gtk_widget_realize(GTK_WIDGET(PrincipalWindow));
	/*
	info_str = gdk_gl_get_info();
	Debug("%s\n",info_str);
	g_free(info_str);
	*/

	g_signal_connect (G_OBJECT(GLArea), "button_press_event", G_CALLBACK(glarea_button_press), NULL);
	g_signal_connect_after(G_OBJECT(GLArea), "button_press_event", G_CALLBACK(event_dispatcher), NULL);
	g_signal_connect_after(G_OBJECT(GLArea), "motion_notify_event", G_CALLBACK(glarea_motion_notify), NULL);
	g_signal_connect (G_OBJECT(GLArea), "button_release_event", G_CALLBACK(glarea_button_release), NULL);


	create_toolbar_and_popup_menu_GL(hboxtoolbar);
	g_signal_connect(G_OBJECT (PrincipalWindow), "key_press_event", (GCallback) set_key_press, GLArea);
	g_signal_connect(G_OBJECT (PrincipalWindow), "key_release_event", (GCallback) set_key_release, NULL);

 
	return TRUE;
}
Example #27
0
NS_IMETHODIMP
EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
			   const PRUnichar *aTipText)
{
  nsAutoString tipText ( aTipText );

  const char* tipString = ToNewUTF8String(tipText);

  if (sTipWindow)
    gtk_widget_destroy(sTipWindow);
  
  // get the root origin for this content window
  nsCOMPtr<nsIWidget> mainWidget;
  mBaseWindow->GetMainWidget(getter_AddRefs(mainWidget));
  GdkWindow *window;
  window = static_cast<GdkWindow *>(mainWidget->GetNativeData(NS_NATIVE_WINDOW));
  gint root_x, root_y;
  gdk_window_get_origin(window, &root_x, &root_y);

  // XXX work around until I can get pink to figure out why
  // tooltips vanish if they show up right at the origin of the
  // cursor.
  root_y += 10;
  
  sTipWindow = gtk_window_new(GTK_WINDOW_POPUP);
  gtk_widget_set_app_paintable(sTipWindow, TRUE);
  gtk_window_set_resizable(GTK_WINDOW(sTipWindow), TRUE);
  // needed to get colors + fonts etc correctly
  gtk_widget_set_name(sTipWindow, "gtk-tooltips");
  gtk_window_set_type_hint(GTK_WINDOW(sTipWindow), GDK_WINDOW_TYPE_HINT_TOOLTIP);
  
  // set up the popup window as a transient of the widget.
  GtkWidget *toplevel_window;
  toplevel_window = gtk_widget_get_toplevel(GTK_WIDGET(mOwner->mOwningWidget));
  if (!GTK_WINDOW(toplevel_window)) {
    NS_ERROR("no gtk window in hierarchy!\n");
    return NS_ERROR_FAILURE;
  }
  gtk_window_set_transient_for(GTK_WINDOW(sTipWindow),
			       GTK_WINDOW(toplevel_window));
  
  // realize the widget
  gtk_widget_realize(sTipWindow);

  g_signal_connect(G_OBJECT(sTipWindow), "expose_event",
                   G_CALLBACK(tooltips_paint_window), NULL);

  // set up the label for the tooltip
  GtkWidget *label = gtk_label_new(tipString);
  // wrap automatically
  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
  gtk_container_add(GTK_CONTAINER(sTipWindow), label);
  gtk_container_set_border_width(GTK_CONTAINER(sTipWindow), 4);
  // set the coords for the widget
  gtk_widget_set_uposition(sTipWindow, aXCoords + root_x,
			   aYCoords + root_y);

  // and show it.
  gtk_widget_show_all(sTipWindow);

  NS_Free( (void*)tipString );

  return NS_OK;
}
GtkWidget * create_PlayList( void )
{
  GtkWidget 	* vbox1;
  GtkWidget 	* hbox1;
  GtkWidget 	* scrolledwindow1;
  GtkWidget 	* vbox2;
  GtkWidget 	* scrolledwindow2;
  GtkWidget 	* scrolledwindow3;
  GtkWidget 	* hbuttonbox1;
  GtkAccelGroup * accel_group;
  GdkColor 	  transparent = { 0,0,0,0 };
  gchar 	* root = "/";
  gchar 	* dummy = "dummy";
  DirNodeType 	* DirNode;

  accel_group=gtk_accel_group_new();

  PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList );
  gtk_widget_set_usize( PlayList,512,384 );
  gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList );
  gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER );
//  gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE );
  gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" );

  gtk_widget_realize( PlayList );
  gtkAddIcon( PlayList );

  vbox1=AddVBox( AddDialogFrame( PlayList ),0 );
  hbox1=AddHBox( NULL,1 );
   gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 );

  scrolledwindow1=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow1 );
  gtk_container_add( GTK_CONTAINER(
    AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CTDirTree=gtk_ctree_new( 1,0 );
  gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 );
  gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 );
  gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree );
  gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE );
  gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 );
  gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE );
  gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID );
  gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE );

  if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm );
  if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,(gchar **)open2_xpm );

  parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE );
  DirNode=malloc( sizeof( DirNodeType ) );
  DirNode->scaned=0; DirNode->path=strdup( root );
  gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL );
  sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE );
  gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent );
  gtk_widget_show( CTDirTree );

  if ( fsHistory[0] ) old_path = g_filename_from_utf8( fsHistory[0], -1, NULL, NULL, NULL );

  gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0,
    AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 );

  vbox2=AddVBox(
    AddFrame( NULL,1,hbox1,1 ),0 );

  scrolledwindow2=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow2 );
  gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CLFiles=gtk_clist_new( 1 );
  gtk_widget_show( CLFiles );
  gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles );
  gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 );
  gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED );
  gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE );

  gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0,
    AddLabel( MSGTR_PLAYLIST_Files,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CLFiles ),0 );

  AddHSeparator( vbox2 );

  scrolledwindow3=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow3 );
  gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CLSelected=gtk_clist_new( 2 );
  gtk_widget_show( CLSelected );
  gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected );
  gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 );
  gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 );
  gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE );
  gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE );

  gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0,
    AddLabel( MSGTR_PLAYLIST_Selected,NULL ) );

  gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1,
    AddLabel( MSGTR_PLAYLIST_Path,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 );

  AddHSeparator( vbox1 );

  hbuttonbox1=AddHButtonBox( vbox1 );
    gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
    gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );

  Add=AddButton( MSGTR_Add,hbuttonbox1 );
  Remove=AddButton( MSGTR_Remove,hbuttonbox1 );
  Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
  Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );

  gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );

  gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList );

  gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 );
  sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 );
  sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 );
  sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 );
  gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 );

  gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 );
  gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 );
  gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 );
  gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 );
  gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 );
  gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 );
  gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 );
  gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 );

  gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group );

  return PlayList;
}
Example #29
0
int wxChoice::GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item)
{
    wxCHECK_MSG(pos<=m_clientList.GetCount(), -1, wxT("invalid index"));

    GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );

    size_t index;
    if ( m_strings )
    {
        // sorted control, need to insert at the correct index
        index = m_strings->Add(item);

        gtk_menu_insert( GTK_MENU(menu), menu_item, index );

        if ( index )
        {
            m_clientList.Insert( m_clientList.Item(index - 1),
                                 NULL );
        }
        else
        {
            m_clientList.Insert( NULL );
        }
    }
    else
    {
        // don't call wxChoice::GetCount() from here because it doesn't work
        // if we're called from ctor (and GtkMenuShell is still NULL)

        // normal control, just append
        if (pos == m_clientList.GetCount())
        {
            gtk_menu_append( GTK_MENU(menu), menu_item );
            m_clientList.Append( NULL );
            index = m_clientList.GetCount() - 1;
        }
        else
        {
            gtk_menu_insert( GTK_MENU(menu), menu_item, pos );
            m_clientList.Insert( pos, NULL );
            index = pos;
        }
    }

    if (GTK_WIDGET_REALIZED(m_widget))
    {
        gtk_widget_realize( menu_item );
        gtk_widget_realize( GTK_BIN(menu_item)->child );

        ApplyWidgetStyle();
    }

    // The best size of a wxChoice should probably
    // be changed everytime the control has been
    // changed, but at least after adding an item
    // it has to change. Adapted from Matt Ownby.
    InvalidateBestSize();

    gtk_signal_connect_after( GTK_OBJECT( menu_item ), "activate",
      GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );

    gtk_widget_show( menu_item );

    // return the index of the item in the control
    return index;
}
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *collection;
  GtkStyle *style;
  GError *err;
  clock_t start, end;
  GtkWidget *notebook;
  int i;
  
  bindtextdomain (GETTEXT_PACKAGE, MARCO_LOCALEDIR);
  textdomain(GETTEXT_PACKAGE);
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");

  run_position_expression_tests ();
#if 0
  run_position_expression_timings ();
#endif

  gtk_init (&argc, &argv);

  if (g_getenv ("MARCO_DEBUG") != NULL)
    {
      meta_set_debugging (TRUE);
      meta_set_verbose (TRUE);
    }
  
  start = clock ();
  err = NULL;
  if (argc == 1)
    global_theme = meta_theme_load ("ClearlooksRe", &err);
  else if (argc == 2)
    global_theme = meta_theme_load (argv[1], &err);
  else
    {
      g_printerr (_("Usage: marco-theme-viewer [THEMENAME]\n"));
      exit (1);
    }
  end = clock ();

  if (global_theme == NULL)
    {
      g_printerr (_("Error loading theme: %s\n"),
                  err->message);
      g_error_free (err);
      exit (1);
    }

  g_print (_("Loaded theme \"%s\" in %g seconds\n"),
           global_theme->name,
           (end - start) / (double) CLOCKS_PER_SEC);

  run_theme_benchmark ();
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 350, 350);

  if (strcmp (global_theme->name, global_theme->readable_name)==0)
    gtk_window_set_title (GTK_WINDOW (window),
                          global_theme->readable_name);
  else
    {
      /* The theme directory name is different from the name the theme
       * gives itself within its file.  Display both, directory name first.
       */
      gchar *title =  g_strconcat (global_theme->name, " - ",
                                   global_theme->readable_name,
                                   NULL);

      gtk_window_set_title (GTK_WINDOW (window),
                            title);

      g_free (title);
    }       

  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_realize (window);
  style = gtk_widget_get_style (window);

  g_assert (style);
  g_assert (style->font_desc);
  
  notebook = gtk_notebook_new ();
  gtk_container_add (GTK_CONTAINER (window), notebook);

  collection = preview_collection (FONT_SIZE_NORMAL,
                                   style->font_desc);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            collection,
                            gtk_label_new (_("Normal Title Font")));
  
  collection = preview_collection (FONT_SIZE_SMALL,
                                   style->font_desc);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            collection,
                            gtk_label_new (_("Small Title Font")));
  
  collection = preview_collection (FONT_SIZE_LARGE,
                                   style->font_desc);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            collection,
                            gtk_label_new (_("Large Title Font")));

  collection = previews_of_button_layouts ();
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            collection,
                            gtk_label_new (_("Button Layouts")));

  collection = benchmark_summary ();
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                            collection,
                            gtk_label_new (_("Benchmark")));
  
  i = 0;
  while (i < (int) G_N_ELEMENTS (previews))
    {
      /* preview widget likes to be realized before its size request.
       * it's lame that way.
       */
      gtk_widget_realize (previews[i]);

      ++i;
    }
  
  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}