Example #1
0
static void
animation_done_cb (GstyleSlidein *self)
{
  GstyleSlideinDirectionType animation_direction;

  g_assert (GSTYLE_IS_SLIDEIN (self));

  if (self->is_opening)
    {
      animate_stop (self);
      animation_direction = self->direction_type;
      self->revealed = TRUE;

      gtk_grab_add (GTK_WIDGET (self));
      gtk_event_box_set_above_child (GTK_EVENT_BOX (self), TRUE);
      gtk_widget_set_can_focus (self->overlay_child, TRUE);
      gtk_widget_grab_focus (self->overlay_child);
    }
  else if (self->is_closing)
    {
      animate_stop (self);
      animation_direction = self->direction_type_reverse;
      self->revealed = FALSE;

      gtk_event_box_set_above_child (GTK_EVENT_BOX (self), FALSE);
    }
  else
    g_assert_not_reached ();

  self->is_closing = self->is_opening = FALSE;
  self->offset = self->dst_offset;

  g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_REVEALED]);
  g_signal_emit (self, signals [REVEALED], 0, animation_direction, self->revealed);
}
Example #2
0
int main(int argc, char *argv[]){

	GtkWidget *window, *eventbox, *label;

	gtk_init (&argc,&argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (window), "Event Box");
	gtk_container_set_border_width (GTK_CONTAINER (window),10);
	gtk_widget_set_size_request (window, 200, 50);
		
	g_signal_connect (G_OBJECT (window),"destroy",
					  G_CALLBACK(destroy), NULL);

	eventbox = gtk_event_box_new();
	label = gtk_label_new ("Double-Click it!");
	
	/* Set the order in which the widgets will recieve notification of events. */
	gtk_event_box_set_above_child (GTK_EVENT_BOX (eventbox), FALSE);

	g_signal_connect (G_OBJECT (eventbox), "button_press_event", G_CALLBACK (button_pressed), (gpointer) label);
	
	gtk_container_add (GTK_CONTAINER (eventbox), label);
	gtk_container_add (GTK_CONTAINER (window), eventbox);

	/* ALlow the event box to catch button presses, realize the widget, and set the cursor that will be displayed when the mouse is over the event box*/
	gtk_widget_set_events (eventbox, GDK_BUTTON_PRESS_MASK);
	gtk_widget_realize(eventbox);
	gdk_window_set_cursor (eventbox->window, gdk_cursor_new (GDK_HAND1));
	gtk_widget_show_all (window);

	gtk_main();
	return 0;

}
Example #3
0
void ArticleView::append_data_res_attachment(
	const std::string& key, const std::string& mark,
	bool& loaded)
{
	if (for_float_win) {
		loaded = true;
		if(mark.empty())
			pango_view_->append_widget(NULL);
		else
			pango_view_->insert_widget(NULL, mark.c_str());
	} else {
		GtkWidget *widget = NULL;
		if (dict_index.type == InstantDictType_LOCAL) {
			StorageType type = gpAppFrame->oLibs.GetStorageType(dict_index.index);
			if (type == StorageType_DATABASE || type == StorageType_FILE) {
				ResData *pResData
					= new ResData(dict_index.index, key);
				GtkWidget *button = NULL;
				GtkWidget *image = NULL;
				image = gtk_image_new_from_pixbuf(get_impl(
					gpAppFrame->oAppSkin.attachment));
				button = gtk_button_new();
				/* We need an event box to associate a custom cursor with the
				 * button. */
				widget = gtk_event_box_new();
				g_object_ref_sink(G_OBJECT(widget));
				gtk_container_add(GTK_CONTAINER(button), image);
				gtk_container_add(GTK_CONTAINER(widget), button);
#ifdef DEBUG
				/* when the tooltip appears a number of gtk-warnings are generated:
				 * Gtk-WARNING **: IA__gtk_text_view_window_to_buffer_coords: 
				 * can't get coords for private windows */
				gtk_widget_set_tooltip_text(GTK_WIDGET(widget),
					pResData->get_key().c_str());
#endif
				gtk_event_box_set_above_child(GTK_EVENT_BOX(widget), FALSE);
				gtk_widget_show_all(widget);
				g_signal_connect(G_OBJECT(button), "destroy",
					G_CALLBACK(on_resource_button_destroy), (gpointer)pResData);
				g_signal_connect(G_OBJECT(button), "clicked",
					G_CALLBACK(on_attachment_button_clicked), (gpointer)pResData);
				g_signal_connect(G_OBJECT(button), "realize",
					G_CALLBACK(on_resource_button_realize), (gpointer)widget);
			}
		}
		if(widget) {
			loaded = true;
			if(mark.empty())
				pango_view_->append_widget(widget);
			else
				pango_view_->insert_widget(widget, mark.c_str());
			g_object_unref(widget);
		}
	}
}
Example #4
0
GtkWidget * MyEvent(char name[]){
		Widget eventBox;
		Widget childWidget;
		childWidget = gtk_image_new_from_file(name);
		eventBox = gtk_event_box_new();
		gtk_event_box_set_above_child(GTK_EVENT_BOX(eventBox), TRUE);
		gtk_widget_set_events(eventBox, GDK_BUTTON_PRESS_MASK);
		gtk_container_add(GTK_CONTAINER(eventBox), childWidget);	
		return eventBox;
	
}
Example #5
0
GtkWidget * initialiseEventBox( GtkWidget *childWidget){
	GtkWidget* eventBox;
	eventBox = gtk_event_box_new();
	//gdk_window_set_cursor ( eventBox->window, gdk_cursor_new (GDK_HAND1));

	gtk_event_box_set_above_child( GTK_EVENT_BOX(eventBox), FALSE);
	gtk_widget_set_events(eventBox, GDK_BUTTON_PRESS_MASK);
	gtk_container_add( GTK_CONTAINER(eventBox), childWidget);

	return eventBox;
}
Example #6
0
static GtkEventBox*
assign_cellbutton(UIMCandWinHorizontalGtk *horizontal_cwin,
		  gint cand_index, gint display_limit)
{
  struct index_button *idxbutton;
  int len;
  GPtrArray *buttons;

  buttons = horizontal_cwin->buttons;
  len = buttons->len;

  if (len <= cand_index) {
    GtkWidget *button;
    GtkWidget *label;

    button = gtk_event_box_new();
    gtk_event_box_set_above_child(GTK_EVENT_BOX(button), TRUE);
    label = gtk_label_new("");
    gtk_container_add(GTK_CONTAINER(button), label);
    scale_label(GTK_EVENT_BOX(button), PANGO_SCALE_LARGE);
    g_signal_connect(button, "button-press-event", G_CALLBACK(button_clicked), horizontal_cwin);
#if GTK_CHECK_VERSION(2, 90, 0)
    g_signal_connect_after(label, "draw", G_CALLBACK(label_draw), horizontal_cwin);
#else
    g_signal_connect_after(label, "expose-event", G_CALLBACK(label_exposed), horizontal_cwin);
#endif
#if GTK_CHECK_VERSION(3, 4, 0)
    gtk_widget_set_hexpand(button, TRUE);
    gtk_widget_set_vexpand(button, TRUE);
    gtk_grid_attach(GTK_GRID(UIM_CAND_WIN_GTK(horizontal_cwin)->view), button,
                    cand_index, 0, 1, 1);
#else
    gtk_table_attach_defaults(GTK_TABLE(UIM_CAND_WIN_GTK(horizontal_cwin)->view), button, cand_index, cand_index + 1, 0, 1);
#endif
    idxbutton = g_malloc(sizeof(struct index_button));
    if (idxbutton) {
      idxbutton->button = GTK_EVENT_BOX(button);
      clear_button(idxbutton, cand_index);
      idxbutton->cand_index_in_page = cand_index;
    }
    g_ptr_array_add(horizontal_cwin->buttons, idxbutton);
  } else {
    idxbutton = g_ptr_array_index(buttons, cand_index);
    idxbutton->cand_index_in_page = cand_index;
  }

  return idxbutton->button;
}
CCMCellExtension *
ccm_cell_extension_new (const gchar * path, int width)
{
    g_return_val_if_fail (path != NULL, NULL);

    CCMCellExtension *self = g_object_new (CCM_TYPE_CELL_EXTENSION, NULL);
    GtkWidget *vbox, *hbox, *button;

    self->priv->path = g_strdup (path);

    vbox = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (vbox);
    gtk_container_add (GTK_CONTAINER (self), vbox);

    // Name/description label
    self->priv->name = gtk_label_new ("\n");
    gtk_widget_set_size_request (self->priv->name, width - 4, -1);
    gtk_label_set_use_markup (GTK_LABEL (self->priv->name), TRUE);
    gtk_label_set_line_wrap (GTK_LABEL (self->priv->name), TRUE);
    gtk_widget_show (self->priv->name);
    gtk_box_pack_start (GTK_BOX (vbox), self->priv->name, TRUE, TRUE, 0);

    // Add activation line
    hbox = gtk_hbox_new (FALSE, 5);
    gtk_widget_show (hbox);
    gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

    self->priv->author = gtk_label_new ("");
    gtk_label_set_use_markup (GTK_LABEL (self->priv->author), TRUE);
    gtk_widget_show (self->priv->author);
    gtk_box_pack_start (GTK_BOX (hbox), self->priv->author, TRUE, TRUE, 0);

    self->priv->enable = gtk_label_new ("");
    gtk_label_set_use_markup (GTK_LABEL (self->priv->enable), TRUE);
    gtk_label_set_markup (GTK_LABEL (self->priv->enable), "<span size='small'>Enable</span>");
    gtk_widget_show (self->priv->enable);

    button = gtk_button_new ();
    gtk_widget_show (button);
    gtk_container_add (GTK_CONTAINER (button), self->priv->enable);
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

    gtk_event_box_set_above_child (GTK_EVENT_BOX (self), FALSE);
    gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), FALSE);

    return self;
}
Example #8
0
void create_launcher(t_launcher	*launcher)
{
	launcher->widget = g_object_ref(gtk_event_box_new());
	launcher->image = g_object_ref(gtk_image_new());
	launcher->tooltip = gtk_tooltips_new();
	gtk_container_set_border_width(GTK_CONTAINER (launcher->widget),
								(int)launcher->quicklauncher->icon_size/8);
	gtk_container_add (GTK_CONTAINER (launcher->widget), launcher->image);
	gtk_event_box_set_above_child(GTK_EVENT_BOX(launcher->widget), FALSE);

	launcher_update_icon(launcher, launcher->quicklauncher->icon_size);
	g_assert(!launcher->command_ids[0]);
	launcher_update_command(launcher) ;
	gtk_widget_show (launcher->image);
	gtk_widget_show (launcher->widget);
}
Example #9
0
File: grid.c Project: jtfrey/slurm
void _put_button_as_down(grid_button_t *grid_button, int state)
{
	GtkWidget *image = NULL;
/* 	GdkColor color; */

	if (GTK_IS_EVENT_BOX(grid_button->button)) {
		//gtk_widget_set_sensitive (grid_button->button, true);
		return;
	}

	gtk_widget_destroy(grid_button->button);
	grid_button->color = NULL;
	grid_button->color_inx = MAKE_DOWN;
	grid_button->button = gtk_event_box_new();
	gtk_widget_set_size_request(grid_button->button,
				    working_sview_config.button_size,
				    working_sview_config.button_size);
	gtk_event_box_set_above_child(GTK_EVENT_BOX(grid_button->button),
				      false);
	_add_button_signals(grid_button);

/* 	if (grid_button->frame) */
/* 		gtk_container_add(GTK_CONTAINER(grid_button->frame), */
/* 				  grid_button->button); */
	if (grid_button->table)
		gtk_table_attach(grid_button->table, grid_button->button,
				 grid_button->table_x,
				 (grid_button->table_x+1),
				 grid_button->table_y,
				 (grid_button->table_y+1),
				 GTK_SHRINK, GTK_SHRINK,
				 1, 1);

	//gdk_color_parse("black", &color);
	//sview_widget_modify_bg(grid_button->button, GTK_STATE_NORMAL, color);
	//gdk_color_parse(white_color, &color);
	//sview_widget_modify_bg(grid_button->button, GTK_STATE_ACTIVE, color);
	if (state == NODE_STATE_DRAIN)
		image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_ERROR,
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	else
		image = gtk_image_new_from_stock(GTK_STOCK_CANCEL,
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_container_add(GTK_CONTAINER(grid_button->button), image);
	gtk_widget_show_all(grid_button->button);
	return;
}
Example #10
0
G_MODULE_EXPORT GtkWidget *
mb_panel_applet_create (const char *id, GtkOrientation orientation)
{
  GtkWidget *box, *image;

  box = gtk_event_box_new ();
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (box), FALSE);
  gtk_event_box_set_above_child (GTK_EVENT_BOX (box), TRUE);
  gtk_widget_set_name (box, "MatchboxPanelKeyboard");

  image = mb_panel_scaling_image2_new (orientation, "matchbox-keyboard");
  gtk_container_add (GTK_CONTAINER (box), image);

  g_signal_connect (box, "button-release-event", G_CALLBACK (on_toggled), NULL);

  gtk_widget_show_all (box);

  return box;
}
static void 
hildon_caption_init                             (HildonCaption *caption)
{
    HildonCaptionPrivate *priv = NULL;

    /* Initialize startup state */
    priv = HILDON_CAPTION_GET_PRIVATE (caption);

    priv->status = HILDON_CAPTION_OPTIONAL;
    priv->icon = NULL;
    priv->group = NULL;
    priv->is_focused = FALSE;
    priv->text = NULL;

    priv->separator = g_strdup(_("ecdg_ti_caption_separator"));

    gtk_widget_push_composite_child();

    /* Create caption text */
    priv->caption_area = gtk_hbox_new (FALSE, HILDON_CAPTION_SPACING); 
    priv->label = gtk_label_new (NULL);
    priv->icon_align = gtk_alignment_new (0.5f, 0.5f, 0.0f, 0.0f);
    priv->icon_position = HILDON_CAPTION_POSITION_RIGHT;

    /* We want to receive button presses for child widget activation */
    gtk_event_box_set_above_child (GTK_EVENT_BOX (caption), FALSE);
    gtk_widget_add_events (GTK_WIDGET (caption), GDK_BUTTON_PRESS_MASK);

    /* Pack text label caption layout */
    gtk_box_pack_end (GTK_BOX (priv->caption_area), priv->icon_align, FALSE, FALSE, 0);
    gtk_box_pack_end (GTK_BOX (priv->caption_area), priv->label, FALSE, FALSE, 0);
    gtk_widget_set_parent (priv->caption_area, GTK_WIDGET (caption));

    gtk_widget_pop_composite_child ();

    hildon_caption_set_child_expand (caption, TRUE);

    gtk_widget_show_all (priv->caption_area);
}
Example #12
0
static void
gstyle_slidein_init (GstyleSlidein *self)
{
  GtkStyleContext *context;

  g_signal_connect_swapped (self,
                            "key-press-event",
                            G_CALLBACK (gstyle_slidein_event_box_key_pressed_cb),
                            self);

  gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (self), FALSE);
  gtk_event_box_set_above_child (GTK_EVENT_BOX (self), FALSE);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  self->default_provider = gstyle_css_provider_init_default (gtk_style_context_get_screen (context));

  self->direction_type = GSTYLE_SLIDEIN_DIRECTION_TYPE_RIGHT;
  self->direction_type_reverse = GSTYLE_SLIDEIN_DIRECTION_TYPE_LEFT;
  self->duration = 0.0;
  self->duration_set = TRUE;
}
Example #13
0
int main (int argc, 
          char *argv[])
{
  GtkWidget *window, *progress, *eventbox, *menu;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Accelerators");
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  gtk_widget_set_size_request (window, 250, -1);

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

  menu = gtk_menu_new ();
  eventbox = gtk_event_box_new ();
  progress = gtk_progress_bar_new ();
  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), "Nothing Yet Happened");
  create_popup_menu (menu, window, progress);
  
  gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (progress), 0.05);   
  gtk_event_box_set_above_child (GTK_EVENT_BOX (eventbox), FALSE);
  
  g_signal_connect (G_OBJECT (eventbox), "button_press_event",
                    G_CALLBACK (button_press_event),
                    (gpointer) menu);
  
  gtk_container_add (GTK_CONTAINER (eventbox), progress);
  gtk_container_add (GTK_CONTAINER (window), eventbox);
  
  gtk_widget_set_events (eventbox, GDK_BUTTON_PRESS_MASK);
  gtk_widget_realize (eventbox);

  gtk_widget_show_all (window);
  gtk_main ();
  return 0;
}
Example #14
0
static GtkWidget *
create_image (int frame_num)
{
  GtkWidget *image;
  GtkWidget *event_box;
  char *path;

  path =
      g_build_filename (DATADIR, "codecanalyzer", "pixmaps",
      "frame-thumbnail.png", NULL);
  image = gtk_image_new_from_file (path);
  g_free (path);

  event_box = gtk_event_box_new ();

  gtk_event_box_set_above_child (GTK_EVENT_BOX (event_box), TRUE);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);

  gtk_container_add (GTK_CONTAINER (event_box), image);

  g_signal_connect (G_OBJECT (event_box), "button_press_event",
      G_CALLBACK (callback_frame_thumbnail_press), (gpointer) frame_num);
  return event_box;
}
Example #15
0
File: grid.c Project: jtfrey/slurm
extern grid_button_t *create_grid_button_from_another(
	grid_button_t *grid_button, char *name, int color_inx)
{
	grid_button_t *send_grid_button = NULL;
	GdkColor color;
	uint16_t node_base_state;
	char *new_col = NULL;

	if (!grid_button || !name)
		return NULL;
	if (color_inx >= 0) {
		color_inx %= sview_colors_cnt;
		new_col = sview_colors[color_inx];
	} else if (color_inx == MAKE_BLACK)
		new_col = blank_color;
	else
		new_col = white_color;

	send_grid_button = xmalloc(sizeof(grid_button_t));
	memcpy(send_grid_button, grid_button, sizeof(grid_button_t));
	node_base_state = send_grid_button->state & NODE_STATE_BASE;
	send_grid_button->color_inx = color_inx;

	/* need to set the table to empty because we will want to fill
	   this into the new table later */
	send_grid_button->table = NULL;
	if (color_inx == MAKE_BLACK) {
		send_grid_button->button = gtk_button_new();
		//gtk_widget_set_sensitive (send_grid_button->button, false);
		gdk_color_parse(new_col, &color);
		send_grid_button->color = new_col;
		sview_widget_modify_bg(send_grid_button->button,
				       GTK_STATE_NORMAL, color);
/* 		sview_widget_modify_bg(send_grid_button->button,  */
/* 				       GTK_STATE_ACTIVE, color); */
	} else if ((color_inx >= 0) && node_base_state == NODE_STATE_DOWN) {
		GtkWidget *image = gtk_image_new_from_stock(
			GTK_STOCK_CANCEL,
			GTK_ICON_SIZE_SMALL_TOOLBAR);
		send_grid_button->button = gtk_event_box_new();
		gtk_event_box_set_above_child(
			GTK_EVENT_BOX(send_grid_button->button),
			false);
		gdk_color_parse("black", &color);
		sview_widget_modify_bg(send_grid_button->button,
				       GTK_STATE_NORMAL, color);
		//gdk_color_parse("white", &color);
/* 		sview_widget_modify_bg(send_grid_button->button,  */
/* 				     GTK_STATE_ACTIVE, color); */
		gtk_container_add(
			GTK_CONTAINER(send_grid_button->button),
			image);
	} else if ((color_inx >= 0)
		   && (send_grid_button->state & NODE_STATE_DRAIN)) {
		GtkWidget *image = gtk_image_new_from_stock(
			GTK_STOCK_DIALOG_ERROR,
			GTK_ICON_SIZE_SMALL_TOOLBAR);

		send_grid_button->button = gtk_event_box_new();
		gtk_event_box_set_above_child(
			GTK_EVENT_BOX(send_grid_button->button),
			false);
		gdk_color_parse("black", &color);
/* 		sview_widget_modify_bg(send_grid_button->button,  */
/* 				       GTK_STATE_NORMAL, color); */
		//gdk_color_parse("white", &color);
/* 		sview_widget_modify_bg(send_grid_button->button,  */
/* 				       GTK_STATE_ACTIVE, color); */
		gtk_container_add(
			GTK_CONTAINER(send_grid_button->button),
			image);
	} else {
		send_grid_button->button = gtk_button_new();
		send_grid_button->color = new_col;
		gdk_color_parse(new_col, &color);
		sview_widget_modify_bg(send_grid_button->button,
				       GTK_STATE_NORMAL, color);
/* 		sview_widget_modify_bg(send_grid_button->button,  */
/* 				       GTK_STATE_ACTIVE, color); */
	}
	gtk_widget_set_size_request(send_grid_button->button,
				    working_sview_config.button_size,
				    working_sview_config.button_size);

	send_grid_button->node_name = xstrdup(name);

	return send_grid_button;
}
Example #16
0
/**
 * Cette fonction est la boucle principale du programme.
 * Elle permet de rassembler toutes les autres fonctions dans un contenu reflétant
 * le fonctionnement du programme. Pour comprendre le fonctionnement d'un programme,
 * lire le main() devrait suffire.
 * Dans notre cas en revanche ce n'est pas tout à fait exact, car gtk implique
 * une execution évènementielle, c'est à dire une éxécution basée sur les
 * évènements. Le programme ne se lit donc plus du haut vers le bas, mais en
 * fonction des évènements liés à des fonctions dites de callback, dans le fichier
 * libGUI.c.
 */
int main(int argc, char ** argv)
{

    // Commençons par charger les préférences, si elles existent. On ouvre le fichier
    // en lecture pour charger la structure préférences :
    fichierPreferences = fopen(".olonoPrefs", "rb");
    if (fichierPreferences == NULL)
        erreur("Pas de fichier de préférences trouvé\n");
    else
    {
        // On lit 1 élément de donnée de longueur preferences depuis le fichier
        // fPreferences pour le stocker dans la variable prefs (de type preferences)
        fread(&prefs,sizeof(preferences),1,fichierPreferences);

        /// INIT 2 : Préférences globales (from file)
        couleurDepart = prefs.couleurDepart;
        allowIA       = prefs.allowIA;
        couleurIA     = prefs.couleurIA;
        affJouable    = prefs.affJouable;
        taillePlateau = prefs.taillePlateau;

        if (args.verbose)
            ecrire("Chargement de :\n\t couleurDepart: %d, allowIA      : %d\n\t couleurIA    : %d, taillePlateau: %d",couleurDepart,allowIA,couleurIA,taillePlateau);
    }



    /* On initialise les arguments à leur valeur par défaut */
    args.taillePlateau = 0;
    args.verbose       = 0;
    args.Tore          = 0;

    /* This is where the magic should happen | Attention, instant magique ... */
    argp_parse (&argp, argc, argv, 0, 0, &args);

    /// INIT 3 : Préférences globales (from)
    if (args.taillePlateau != 0)
        if (atoi((char*) args.taillePlateau) <= 25 && atoi((char*) args.taillePlateau) >= 4)
            taillePlateau = atoi((char*) args.taillePlateau);


    /// Les 3 priorités d'initialisation étant terminées, on peut désormais
    //  assigner la couleur de départ du jeton :
    jeton = couleurDepart;


/// ######################################################################## ///
/// ### On commence les choses sérieuses ici (cad le main) ################# ///
/// ######################################################################## ///

    gint    i=0,j=0,n=0;
    CASE    caseActuelle[625];

    wOlono = g_malloc(sizeof(window));

    plateau = createPlateau();
    initPlateau(plateau);
    tronc = initHistorique(plateau,couleurDepart);


/// ######################################################################## ///
/// ### On fait chauffer l'Interface Graphique ############################# ///
/// ######################################################################## ///
    GladeXML    *xml;

    /* Initialisation de la lib GTK+ */
    gtk_init(&argc, &argv);

    /* load the interface and complete it with the variable pieces */
    xml = glade_xml_new(DATADIR "/" GLADEDIR "/" GLADEFILE, NULL, NULL);

    /* connect the signals in the interface */
    glade_xml_signal_autoconnect(xml);

    /*    // timer up*/
    /*    wOlono->pIAClock = g_timer_new();*/
    /*    g_timer_start(wOlono->pIAClock);*/

    // get the main Window
    wOlono->pWindow     = glade_xml_get_widget(xml, "olonoWindow");
    gtk_window_set_title(GTK_WINDOW (wOlono->pWindow), "OloNO v" VERSION);

    // get checkBoxes, and set their values
    wOlono->pCheckAllowIA = glade_xml_get_widget(xml, "allowIA");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (wOlono->pCheckAllowIA),allowIA);
    wOlono->pCheckiaIsBlack = glade_xml_get_widget(xml, "iaIsBlack");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (wOlono->pCheckiaIsBlack),couleurIA);
    wOlono->pCheckAffJouable = glade_xml_get_widget(xml, "showPossibleMoves");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (wOlono->pCheckAffJouable),affJouable);
    wOlono->pCheckCouleurDeb = glade_xml_get_widget(xml, "whiteStart");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (wOlono->pCheckCouleurDeb),!couleurDepart);

    // also get the spin button and set the default value :
    wOlono->pSpinTT = glade_xml_get_widget(xml, "taillePlateau");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON (wOlono->pSpinTT),taillePlateau);

    // why not speak to the prefs window too ?
    wOlono->pPrefWindow = glade_xml_get_widget(xml, "olonoPreferences");

    // get the status bar :
    wOlono->pStatusBar  = glade_xml_get_widget(xml, "barreDesTaches");

    // creating context ids :
    wOlono->contextId01 = gtk_statusbar_get_context_id(GTK_STATUSBAR(wOlono->pStatusBar),
                          "MsgTour");
    wOlono->contextId02 = gtk_statusbar_get_context_id(GTK_STATUSBAR(wOlono->pStatusBar),
                          "MsgScore");

    // creating first blank message for contextId01 :
    gtk_statusbar_push (GTK_STATUSBAR (wOlono->pStatusBar),
                        GPOINTER_TO_INT(wOlono->contextId01),"Bienvenue - Youkoso");

    // On s'occupe de charger les images en mémoire :
    wOlono->imgVide     = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGVIDE,&wOlono->gerror);
    wOlono->imgBlanche  = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGBLANCHE,&wOlono->gerror);
    wOlono->imgNoire    = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGNOIRE,&wOlono->gerror);
    wOlono->imgJoker    = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGJOKER,&wOlono->gerror);

    // Puis on créé les dérivées transparentes :
    wOlono->imgTransBlanche = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGTBLANCHE,&wOlono->gerror);
    wOlono->imgTransNoire   = gdk_pixbuf_new_from_file(DATADIR "/" IMGDIR "/" IMGTNOIRE,&wOlono->gerror);


    // set the plateau.
    wOlono->pPlateau    = gtk_table_new(taillePlateau,taillePlateau,TRUE);

    for (i=0;i<taillePlateau;i++)
    {
        for (j=0;j<taillePlateau;j++)
        {
            n=i*taillePlateau+j;
            wOlono->pImage[n] = gtk_image_new();
            wOlono->pEvent[n] = gtk_event_box_new ();
            gtk_container_add (GTK_CONTAINER (wOlono->pEvent[n]), wOlono->pImage[n]);

            // Important : On place le gtk_event_box au dessus sinon on peut pas
            // recevoir des évènements, puisqu'il est caché par l'image.
            gtk_event_box_set_above_child (GTK_EVENT_BOX (wOlono->pEvent[n]),1);

            // On rempli caseActuelle :
            caseActuelle[n].x = i;
            caseActuelle[n].y = j;

            // On connecte chaque signal à la fonction callback :
            g_signal_connect (G_OBJECT (wOlono->pEvent[n]),
                              "button_press_event",
                              G_CALLBACK (on_case_clic),
                              &caseActuelle[n]);

            gtk_table_attach_defaults (GTK_TABLE (wOlono->pPlateau),
                                       wOlono->pEvent[n], i, i+1, j, j+1);
        }
    }

    /* Rafraichit le plateau (fait concorder celui en mémoire et celui affiché) */
    refreshBoard(plateau);

    wOlono->pContainer = glade_xml_get_widget(xml, "cadreAspect");
    gtk_container_add(GTK_CONTAINER(wOlono->pContainer), wOlono->pPlateau);

    /* For all the abandonned widgets ie plateau */
    gtk_widget_show_all (wOlono->pPlateau);

    /* start the event loop */
    gtk_main();

    return 0;
}
Example #17
0
RendererFuncs *renderer_clutter_new(PixbufRenderer *pr)
{
	RendererClutter *rc = g_new0(RendererClutter, 1);

	rc->pr = pr;

	rc->f.area_changed = rc_area_changed;
	rc->f.update_pixbuf = rc_update_pixbuf;
	rc->f.free = rc_free;
	rc->f.update_zoom = rc_update_zoom;
	rc->f.invalidate_region = rc_invalidate_region;
	rc->f.scroll = rc_scroll;
	rc->f.update_viewport = rc_update_viewport;


	rc->f.overlay_add = rc_overlay_add;
	rc->f.overlay_set = rc_overlay_set;
	rc->f.overlay_get = rc_overlay_get;

	rc->f.stereo_set = rc_stereo_set;


	rc->stereo_mode = 0;
	rc->stereo_off_x = 0;
	rc->stereo_off_y = 0;

	rc->idle_update = 0;
	rc->pending_updates = NULL;

	rc->widget = gtk_bin_get_child(GTK_BIN(rc->pr));

	if (rc->widget)
		{
		if (!GTK_CLUTTER_IS_EMBED(rc->widget))
			{
			g_free(rc);
			DEBUG_3("pixbuf renderer has a child of other type than gtk_clutter_embed");
			return NULL;
			}
		}
	else
		{
		rc->widget = gtk_clutter_embed_new();
		gtk_container_add(GTK_CONTAINER(rc->pr), rc->widget);
		}

	gtk_event_box_set_above_child (GTK_EVENT_BOX(rc->pr), TRUE);
	rc->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (rc->widget));

	rc->group = clutter_group_new();
	clutter_container_add_actor(CLUTTER_CONTAINER(rc->stage), rc->group);
	clutter_actor_set_clip_to_allocation(CLUTTER_ACTOR(rc->group), TRUE);

	rc->texture = clutter_texture_new ();
	clutter_container_add_actor(CLUTTER_CONTAINER(rc->group), rc->texture);

	renderer_clutter_init_checker_shader(rc);
	g_object_ref(G_OBJECT(rc->widget));

	gtk_widget_show(rc->widget);
	return (RendererFuncs *) rc;
}
Example #18
0
static void
uim_cand_win_horizontal_gtk_init (UIMCandWinHorizontalGtk *horizontal_cwin)
{
  gint col;
  GtkWidget *viewport;
  UIMCandWinGtk *cwin;

  cwin = UIM_CAND_WIN_GTK(horizontal_cwin);

  horizontal_cwin->buttons = g_ptr_array_new();
  horizontal_cwin->selected = NULL;

#if GTK_CHECK_VERSION(3, 4, 0)
  cwin->view = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(cwin->view), 10);
#else
  cwin->view = gtk_table_new(1, DEFAULT_NR_CELLS, FALSE);
  gtk_table_set_col_spacings(GTK_TABLE(cwin->view), 10);
#endif
  viewport = gtk_viewport_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), cwin->view);
  gtk_container_add(GTK_CONTAINER(cwin->scrolled_window), viewport);
  gtk_container_set_resize_mode(GTK_CONTAINER(viewport), GTK_RESIZE_PARENT);
  for (col = 0; col < DEFAULT_NR_CELLS; col++) {
    GtkWidget *button;
    GtkWidget *label;
    struct index_button *idxbutton;

    button = gtk_event_box_new();
    gtk_event_box_set_above_child(GTK_EVENT_BOX(button), TRUE);
    label = gtk_label_new("");
    gtk_container_add(GTK_CONTAINER(button), label);
    scale_label(GTK_EVENT_BOX(button), PANGO_SCALE_LARGE);
    g_signal_connect(button, "button-press-event", G_CALLBACK(button_clicked), horizontal_cwin);
#if GTK_CHECK_VERSION(2, 90, 0)
    g_signal_connect_after(label, "draw", G_CALLBACK(label_draw), horizontal_cwin);
#else
    g_signal_connect_after(label, "expose-event", G_CALLBACK(label_exposed), horizontal_cwin);
#endif
#if GTK_CHECK_VERSION(3, 4, 0)
    gtk_widget_set_hexpand(button, TRUE);
    gtk_widget_set_vexpand(button, TRUE);
    gtk_grid_attach(GTK_GRID(cwin->view), button, col, 0, 1, 1);
#else
    gtk_table_attach_defaults(GTK_TABLE(cwin->view), button, col, col + 1, 0, 1);
#endif
    idxbutton = g_malloc(sizeof(struct index_button));
    if (idxbutton) {
      idxbutton->button = GTK_EVENT_BOX(button);
      clear_button(idxbutton, col);
    }
    g_ptr_array_add(horizontal_cwin->buttons, idxbutton);
  }

  gtk_widget_show_all(cwin->view);
  gtk_widget_show(viewport);

  gtk_widget_set_size_request(cwin->num_label, DEFAULT_MIN_WINDOW_WIDTH, -1);
  gtk_window_set_default_size(GTK_WINDOW(cwin), DEFAULT_MIN_WINDOW_WIDTH, -1);
  gtk_window_set_resizable(GTK_WINDOW(cwin), FALSE);
}
static GtkWidget *
mnb_notification_gtk_create ()
{
  GtkWidget *widget = NULL;
  GtkWindow *window;
  GtkWidget *evbox;
  GdkPixbuf *pixbuf;

  img_normal = gtk_image_new_from_file (THEMEDIR
                                        "/notifiers/fscreen-notif-normal.png");

  if (img_normal)
    g_object_ref (img_normal);

  img_hover  = gtk_image_new_from_file (THEMEDIR
                                        "/notifiers/fscreen-notif-hover.png");

  if (img_hover)
    g_object_ref (img_hover);

  widget = gtk_window_new (GTK_WINDOW_POPUP);
  window = GTK_WINDOW (widget);

  pixbuf = gdk_pixbuf_new_from_file (THEMEDIR
                                     "/notifiers/fscreen-notif-normal.png",
                                     NULL);

  if (pixbuf)
    {
      gint width, height, rowstride, channels;
      guchar *pixels;
      gint x, y;

      GdkDrawable *mask;
      GdkGC *gc;

      rowstride = gdk_pixbuf_get_rowstride (pixbuf);
      pixels    = gdk_pixbuf_get_pixels (pixbuf);
      width     = gdk_pixbuf_get_width (pixbuf);
      height    = gdk_pixbuf_get_height (pixbuf);
      channels = gdk_pixbuf_get_n_channels (pixbuf);

      g_assert (channels == 4);

      mask = gdk_pixmap_new (NULL, width, height, 1);
      gc   = gdk_gc_new (mask);

      for (x = 0; x < width; ++x)
        for (y = 0; y < height; ++y)
          {
            GdkColor clr;
            guchar *p = pixels + y * rowstride + x * channels;

            if (p[3] == 0)
              clr.pixel = 0;
            else
              clr.pixel = 1;

            gdk_gc_set_foreground (gc, &clr);

            gdk_draw_point (mask, gc, x, y);
          }

      gtk_widget_shape_combine_mask (widget, mask, 0, 0);

      g_object_unref (mask);
      g_object_unref (pixbuf);
      g_object_unref (gc);
    }

  gtk_window_set_decorated (window, FALSE);
  gtk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);
  gtk_window_set_resizable (window, FALSE);
  gtk_window_set_title (window, "mnb-notification-gtk");
  gtk_window_set_accept_focus (window, FALSE);

  gtk_window_move (window, 20, 20);

  evbox = gtk_event_box_new ();
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (evbox), FALSE);
  gtk_event_box_set_above_child (GTK_EVENT_BOX (evbox), TRUE);

  if (!img_normal)
    {
      gtk_container_add (GTK_CONTAINER (evbox),
                         gtk_button_new_with_label ("Notifications"));
    }
  else
    {
      gtk_container_add (GTK_CONTAINER (evbox), img_normal);
    }

  gtk_container_add (GTK_CONTAINER (window), evbox);
  gtk_widget_show (evbox);

  g_signal_connect (evbox, "button-press-event",
                    G_CALLBACK(mnb_notification_gtk_click_cb),
                    NULL);

  if (img_normal && img_hover)
    {
      g_signal_connect (evbox, "enter-notify-event",
                        G_CALLBACK(mnb_notification_gtk_crossing_cb),
                        NULL);

      g_signal_connect (evbox, "leave-notify-event",
                        G_CALLBACK(mnb_notification_gtk_crossing_cb),
                        NULL);
    }

  return widget;
}
//TODO: response to screen-changed?
void deepin_workspace_overview_populate(DeepinWorkspaceOverview* self,
        MetaWorkspace* ws)
{
    DeepinWorkspaceOverviewPrivate* priv = self->priv;
    priv->workspace = ws;

    GdkScreen* screen = gdk_screen_get_default();
    priv->primary = gdk_screen_get_primary_monitor(screen);
    gint n_monitors = gdk_screen_get_n_monitors(screen);
    priv->monitors = g_ptr_array_new_full(n_monitors, monitor_data_destroy);
    for (int i = 0; i < n_monitors; i++) {
        MonitorData* md = monitor_data_new();
        g_ptr_array_add(priv->monitors, md);
        md->monitor = i;
        md->clones = g_ptr_array_new();
        gdk_screen_get_monitor_geometry(screen, i, (GdkRectangle*)&md->mon_rect);

        /**
         * gdk_screen_get_monitor_workarea fails to honor struts, so I have to use xinerama
         * to get correct workarea
         */

        const MetaXineramaScreenInfo* xinerama = meta_screen_get_xinerama_for_rect(ws->screen, &md->mon_rect);
        meta_workspace_get_work_area_for_xinerama(ws, xinerama->number, (GdkRectangle*)&md->mon_workarea);
    }

    GList* ls = meta_stack_list_windows(ws->screen->stack,
            priv->all_window_mode? NULL: ws);
    GList* l = ls;
    while (l) {
        MetaWindow* win = (MetaWindow*)l->data;
        if (win->type == META_WINDOW_NORMAL) {
            if (priv->present_xids && g_hash_table_size(priv->present_xids)) {
                if (g_hash_table_contains(priv->present_xids, GINT_TO_POINTER(win->xwindow))) {
                    _clone_window(self, win);
                }
            } else {
                _clone_window(self, win);
            }
        }

        l = l->next;
    }
    g_list_free(ls);

    {
        priv->close_button = gtk_event_box_new();
        gtk_event_box_set_above_child(GTK_EVENT_BOX(priv->close_button), FALSE);
        gtk_event_box_set_visible_window(GTK_EVENT_BOX(priv->close_button), FALSE);

        GtkWidget* image = gtk_image_new_from_file(METACITY_PKGDATADIR "/close.png");
        gtk_container_add(GTK_CONTAINER(priv->close_button), image);

        deepin_fixed_put(DEEPIN_FIXED(self), priv->close_button, 0, 0);
        gtk_widget_set_opacity(self->priv->close_button, 0.0);

        g_object_connect(G_OBJECT(priv->close_button), 
                "signal::leave-notify-event", on_close_button_leaved, self,
                "signal::button-release-event", on_close_button_clicked, self,
                NULL);
    }


    priv->dock_height = 0;
    MetaWindow *desktop_win = NULL, *dock_win = NULL;

    GList* windows = priv->workspace->mru_list;
    while (windows != NULL) {
        MetaWindow *w = (MetaWindow*)windows->data;
        if (w->type == META_WINDOW_DESKTOP) {
            desktop_win = w;
        }

        if (w->type == META_WINDOW_DOCK) {
            dock_win = w;
        }

        if (desktop_win && dock_win) break;
        windows = windows->next;
    }

    for (int i = 0; i < n_monitors; i++) {
        MonitorData* md = (MonitorData*)g_ptr_array_index(priv->monitors, i);
        if (i == priv->primary) {
            MetaRectangle r1 = {0, 0, 0, 0}, r2 = {0, 0, 0, 0};
            cairo_surface_t* aux1 = NULL, *aux2 = NULL;

            if (desktop_win) {
                meta_window_get_outer_rect(desktop_win, &r1);
                aux1 = deepin_window_surface_manager_get_surface(desktop_win, 1.0); 
                r1.x -= md->mon_rect.x;
                r1.y -= md->mon_rect.y;
                meta_verbose ("%s: desktop offset(%d, %d)\n", __func__, r1.x, r1.y);
            }

            if (dock_win) {
                meta_window_get_outer_rect(dock_win, &r2);
                aux2 = deepin_window_surface_manager_get_surface(dock_win, 1.0); 
                priv->dock_height = r2.height;
                r2.x -= md->mon_rect.x;
                r2.y -= md->mon_rect.y;
                meta_verbose ("%s: dock offset(%d, %d)\n", __func__, r2.x, r2.y);
            }
            md->desktop_surface = deepin_window_surface_manager_get_combined3(
                    deepin_background_cache_get_surface(md->monitor, 1.0), 
                    aux1, r1.x, r1.y,
                    aux2, r2.x, r2.y,
                    1.0);
        } else {
            md->desktop_surface = deepin_background_cache_get_surface(md->monitor, 1.0);
            cairo_surface_reference(md->desktop_surface);
        }
    }

    gtk_widget_queue_resize(GTK_WIDGET(self));
}