Example #1
0
static void serverstats_init(void)
{
	/** Get an allready exposed widgets to grab theme colors from. */
	GtkWidget *colw = (GtkWidget *) playlist3_get_category_tree_view();
	GtkWidget *label = NULL;
	GtkWidget *table = NULL;
	GtkWidget *hbox = NULL;
	GtkWidget *event = NULL;
	GtkWidget *serverstats_vbox = gtk_vbox_new(FALSE, 0);
	GtkWidget *serverstats_event;
	gchar *markup = NULL;
	int i = 0;

	serverstats_sw = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(serverstats_sw), GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(serverstats_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

	serverstats_event = gtk_event_box_new();
	gtk_event_box_set_visible_window(GTK_EVENT_BOX(serverstats_event), TRUE);
	gtk_container_add(GTK_CONTAINER(serverstats_event), serverstats_vbox);

	/* wrap in event box to set bg color */
	event = gtk_event_box_new();
	gtk_widget_set_app_paintable(event, TRUE);
	gtk_event_box_set_visible_window(GTK_EVENT_BOX(event), TRUE);
	gtk_widget_set_state(GTK_WIDGET(event), GTK_STATE_SELECTED);
	g_signal_connect(G_OBJECT(event), "expose-event", G_CALLBACK(misc_header_expose_event), NULL);

	gtk_widget_modify_bg(serverstats_event, GTK_STATE_NORMAL, &(colw->style->base[GTK_STATE_NORMAL]));
	g_signal_connect(G_OBJECT(serverstats_vbox), "style-set", G_CALLBACK(serverstats_header_style_changed),
					 serverstats_event);

	/* set label and padding */
	hbox = gtk_hbox_new(FALSE, 6);
	label = gtk_image_new_from_icon_name("mpd", GTK_ICON_SIZE_DND);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
	label = gtk_label_new("");
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	markup = g_markup_printf_escaped("<span size='xx-large' weight='bold'>%s</span>", _("Server Information"));
	gtk_label_set_markup(GTK_LABEL(label), markup);
	g_free(markup);
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(event), hbox);

	gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
	gtk_box_pack_start(GTK_BOX(serverstats_vbox), event, FALSE, TRUE, 0);
	gtk_widget_show_all(event);

	label = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(serverstats_vbox), label, FALSE, TRUE, 0);
	gtk_widget_show(label);
	/**
     * Data list 
     */
	table = gtk_table_new(SERVERSTATS_NUM_FIELDS + 2, 2, FALSE);
	gtk_table_set_col_spacings(GTK_TABLE(table), 6);
	gtk_table_set_row_spacings(GTK_TABLE(table), 6);
	gtk_container_set_border_width(GTK_CONTAINER(table), 12);

	/** Database */
	label = gtk_label_new("");
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
	markup = g_markup_printf_escaped("<span size='x-large' weight='bold'>%s</span>", _("Server"));
	gtk_label_set_markup(GTK_LABEL(label), markup);
	g_free(markup);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, 0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);

	i = 1;
	/** Mpd version */
	serverstats_add_entry(table, i++, _("Version"), SERVERSTATS_MPD_VERSION);

	serverstats_add_entry(table, i++, _("Uptime"), SERVERSTATS_MPD_UPTIME);
	serverstats_add_entry(table, i++, _("Time Playing"), SERVERSTATS_MPD_PLAYTIME);

	/** Database */
	label = gtk_label_new("");
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);

	markup = g_markup_printf_escaped("<span size='x-large' weight='bold'>%s</span>", _("Database"));
	gtk_label_set_markup(GTK_LABEL(label), markup);
	g_free(markup);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, i, i + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	i++;

	/** Mpd Playtime */
	serverstats_add_entry(table, i++, _("Total Playtime"), SERVERSTATS_MPD_DB_PLAYTIME);
	/** Mpd Artists*/
	serverstats_add_entry(table, i++, _("Number of artists"), SERVERSTATS_MPD_DB_ARTISTS);
	/** Mpd Albums */
	serverstats_add_entry(table, i++, _("Number of albums"), SERVERSTATS_MPD_DB_ALBUMS);
	/** Mpd Songs */
	serverstats_add_entry(table, i++, _("Number of songs"), SERVERSTATS_MPD_DB_SONGS);
	/** Mpd Songs */
	serverstats_add_entry(table, i++, _("URL Handlers"), SERVERSTATS_MPD_URLHANDLERS);
	/** Mpd Songs */
	serverstats_add_entry(table, i++, _("Tag Types"), SERVERSTATS_MPD_TAG_TYPES);
	/** Stats */
	label = gtk_label_new("");
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);

	markup = g_markup_printf_escaped("<span size='x-large' weight='bold'>%s</span>", _("Tag statistics"));
	gtk_label_set_markup(GTK_LABEL(label), markup);
	g_free(markup);
	gtk_table_attach(GTK_TABLE(table), label, 0, 2, i, i + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
	i++;
	gtk_widget_show_all(table);

	/**
     * Stats treeview
     */
	{
		GtkWidget *combo = NULL;
		GtkWidget *sw = NULL, *cancel;
		GtkListStore *store;
		GtkCellRenderer *renderer;
		GtkWidget *pb = gtk_progress_bar_new();
		combo = gtk_combo_box_new_text();
		for (i = 0; i < MPD_TAG_NUM_OF_ITEM_TYPES - 1; i++)
		{
			if (mpd_server_tag_supported(connection, i))
			{
				gtk_combo_box_append_text(GTK_COMBO_BOX(combo), mpdTagItemKeys[i]);
			}
		}

		gtk_table_attach(GTK_TABLE(table), combo, 0, 2, 12, 13, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
		gtk_widget_show(combo);

		hbox = gtk_hbox_new(FALSE, 6);
		cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
		g_signal_connect(G_OBJECT(cancel), "clicked", G_CALLBACK(cancel_clicked), NULL);
		gtk_box_pack_start(GTK_BOX(hbox), pb, TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, TRUE, 0);

		gtk_table_attach(GTK_TABLE(table), hbox, 0, 2, 13, 14, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
		g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(serverstats_combo_changed), pb);

		sw = gtk_scrolled_window_new(NULL, NULL);
		gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
		gtk_container_set_border_width(GTK_CONTAINER(sw), 6);

		store = gtk_list_store_new(4, G_TYPE_ULONG, G_TYPE_STRING, G_TYPE_ULONG, G_TYPE_STRING);
		gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), 0, GTK_SORT_DESCENDING);
		serverstats_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
		gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(serverstats_tree), FALSE);
		gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(serverstats_tree), TRUE);
		renderer = gtk_cell_renderer_text_new();
		g_object_set(G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, "width-chars", 30,
					 NULL);
		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(serverstats_tree), -1, "", renderer, "text", 1, NULL);
		renderer = gtk_cell_renderer_progress_new();
		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(serverstats_tree),
													-1, "", renderer, "value", 2, "text", 3, NULL);

		gtk_tree_view_set_search_column(GTK_TREE_VIEW(serverstats_tree), 1);

		gtk_container_add(GTK_CONTAINER(sw), serverstats_tree);

		gtk_table_attach(GTK_TABLE(table), sw, 0, 2, 14, 15, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
		gtk_widget_show_all(sw);
	}
	/**
     * Add table
     */
	gtk_box_pack_start(GTK_BOX(serverstats_vbox), table, TRUE, TRUE, 0);
	/* maintain my own reference to the widget, so it won't get destroyed removing 
	 * from view
	 */
	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(serverstats_sw), serverstats_event);
	gtk_widget_show(serverstats_vbox);
	gtk_widget_show(serverstats_event);
	gtk_widget_show(serverstats_sw);
	g_object_ref_sink(serverstats_sw);
}
Example #2
0
void
panel_start_gui(panel *p)
{
    Atom state[3];
    XWMHints wmhints;
    guint32 val;
 
    
    ENTER;

    // main toplevel window
    p->topgwin =  gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0);
    gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE);
    gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "fbpanel");
    gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel");
    gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_NONE);
    gtk_window_set_decorated(GTK_WINDOW(p->topgwin), FALSE);
    
    g_signal_connect(G_OBJECT(p->topgwin), "delete-event",
          G_CALLBACK(panel_delete_event), p);
    g_signal_connect(G_OBJECT(p->topgwin), "destroy-event",
          G_CALLBACK(panel_destroy_event), p);
    g_signal_connect (G_OBJECT (p->topgwin), "size-request",
          (GCallback) panel_size_req, p);
    g_signal_connect (G_OBJECT (p->topgwin), "size-allocate",
          (GCallback) panel_size_alloc, p);
    g_signal_connect (G_OBJECT (p->topgwin), "configure-event",
          (GCallback) panel_configure_event, p);
    g_signal_connect (G_OBJECT (p->topgwin), "realize",
          (GCallback) panel_realize, p);
    g_signal_connect (G_OBJECT (p->topgwin), "style-set",
          (GCallback) panel_style_set, p);
    
    gtk_widget_realize(p->topgwin);
    //gdk_window_set_decorations(p->topgwin->window, 0);
    gtk_widget_set_app_paintable(p->topgwin, TRUE);
    
    // background box all over toplevel
    p->bbox = gtk_bgbox_new();
    gtk_container_add(GTK_CONTAINER(p->topgwin), p->bbox);
    gtk_widget_show(p->bbox);
    gtk_container_set_border_width(GTK_CONTAINER(p->bbox), 0);
    if (p->transparent) {
        p->bg = fb_bg_get_for_display();
        gtk_bgbox_set_background(p->bbox, BG_ROOT, p->tintcolor, p->alpha);        
    }

    // main layout manager as a single child of background widget box
    p->lbox = p->my_box_new(FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0);
    gtk_container_add(GTK_CONTAINER(p->bbox), p->lbox);
    gtk_widget_show(p->lbox);
    if (p->round_corners)
        make_round_corners(p);
 
    p->box = p->my_box_new(FALSE, p->spacing); 
    gtk_container_set_border_width(GTK_CONTAINER(p->box), 0);
    gtk_box_pack_start(GTK_BOX(p->lbox), p->box, TRUE, TRUE, 0);
    gtk_widget_show(p->box);
      
    p->topxwin = GDK_WINDOW_XWINDOW(GTK_WIDGET(p->topgwin)->window);
    DBG("topxwin = %x\n", p->topxwin);

    /* the settings that should be done before window is mapped */
    wmhints.flags = InputHint;
    wmhints.input = 0;
    XSetWMHints (GDK_DISPLAY(), p->topxwin, &wmhints); 
#define WIN_HINTS_SKIP_FOCUS      (1<<0)	/* "alt-tab" skips this win */
    val = WIN_HINTS_SKIP_FOCUS;
    XChangeProperty(GDK_DISPLAY(), p->topxwin,
          XInternAtom(GDK_DISPLAY(), "_WIN_HINTS", False), XA_CARDINAL, 32,
          PropModeReplace, (unsigned char *) &val, 1);

    if (p->setdocktype) {
        state[0] = a_NET_WM_WINDOW_TYPE_DOCK;
        XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_WINDOW_TYPE, XA_ATOM,
              32, PropModeReplace, (unsigned char *) state, 1);
    }

    /* window mapping point */
    gtk_widget_show_all(p->topgwin);

    /* the settings that should be done after window is mapped */

    /* send it to running wm */
    Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0);
    /* and assign it ourself just for case when wm is not running */
    val = 0xFFFFFFFF;
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_DESKTOP, XA_CARDINAL, 32,
          PropModeReplace, (unsigned char *) &val, 1);

    state[0] = a_NET_WM_STATE_SKIP_PAGER;
    state[1] = a_NET_WM_STATE_SKIP_TASKBAR;
    state[2] = a_NET_WM_STATE_STICKY;
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STATE, XA_ATOM,
          32, PropModeReplace, (unsigned char *) state, 3);

    XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(), PropertyChangeMask);
    gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, p);

    calculate_position(p);
    gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah);
    if (p->setstrut)
        panel_set_wm_strut(p);
  
    RET();
}
GtkWidget *
do_toolpalette (GtkWidget *do_widget)
{
  GtkWidget *box = NULL;
  GtkWidget *hbox = NULL;
  GtkWidget *combo_orientation = NULL;
  GtkListStore *orientation_model = NULL;
  GtkWidget *combo_style = NULL;
  GtkListStore *style_model = NULL;
  GtkCellRenderer *cell_renderer = NULL;
  GtkTreeIter iter;
  GtkWidget *palette = NULL;
  GtkWidget *palette_scroller = NULL;
  GtkWidget *notebook = NULL;
  GtkWidget *contents = NULL;
  GtkWidget *contents_scroller = NULL;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Tool Palette");
      gtk_window_set_default_size (GTK_WINDOW (window), 200, 600);

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);
      gtk_container_set_border_width (GTK_CONTAINER (window), 8);

      /* Add widgets to control the ToolPalette appearance: */
      box = gtk_vbox_new (FALSE, 6);
      gtk_container_add (GTK_CONTAINER (window), box);

      /* Orientation combo box: */
      orientation_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
      gtk_list_store_append (orientation_model, &iter);
      gtk_list_store_set (orientation_model, &iter,
                          0, "Horizontal",
                          1, GTK_ORIENTATION_HORIZONTAL,
                          -1);
      gtk_list_store_append (orientation_model, &iter);
      gtk_list_store_set (orientation_model, &iter,
                          0, "Vertical",
                          1, GTK_ORIENTATION_VERTICAL,
                          -1);

      combo_orientation =
        gtk_combo_box_new_with_model (GTK_TREE_MODEL (orientation_model));
      cell_renderer = gtk_cell_renderer_text_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_orientation),
                                  cell_renderer,
                                  TRUE);
      gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_orientation),
                                      cell_renderer,
                                      "text", 0,
                                      NULL);
      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_orientation), &iter);
      gtk_box_pack_start (GTK_BOX (box), combo_orientation, FALSE, FALSE, 0);

      /* Style combo box: */
      style_model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
      gtk_list_store_append (style_model, &iter);
      gtk_list_store_set (style_model, &iter,
                          0, "Text",
                          1, GTK_TOOLBAR_TEXT,
                          -1);
      gtk_list_store_append (style_model, &iter);
      gtk_list_store_set (style_model, &iter,
                          0, "Both",
                          1, GTK_TOOLBAR_BOTH,
                          -1);
      gtk_list_store_append (style_model, &iter);
      gtk_list_store_set (style_model, &iter,
                          0, "Both: Horizontal",
                          1, GTK_TOOLBAR_BOTH_HORIZ,
                          -1);
      gtk_list_store_append (style_model, &iter);
      gtk_list_store_set (style_model, &iter,
                          0, "Icons",
                          1, GTK_TOOLBAR_ICONS,
                          -1);
      gtk_list_store_append (style_model, &iter);
      gtk_list_store_set (style_model, &iter,
                          0, "Default",
                          1, -1,  /* A custom meaning for this demo. */
                          -1);
      combo_style = gtk_combo_box_new_with_model (GTK_TREE_MODEL (style_model));
      cell_renderer = gtk_cell_renderer_text_new ();
      gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_style),
                                  cell_renderer,
                                  TRUE);
      gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_style),
                                      cell_renderer,
                                      "text", 0,
                                      NULL);
      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_style), &iter);
      gtk_box_pack_start (GTK_BOX (box), combo_style, FALSE, FALSE, 0);

      /* Add hbox */
      hbox = gtk_hbox_new (FALSE, 5);
      gtk_box_pack_start (GTK_BOX (box), hbox, TRUE, TRUE, 0);

      /* Add and fill the ToolPalette: */
      palette = gtk_tool_palette_new ();

      load_stock_items (GTK_TOOL_PALETTE (palette));
      load_toggle_items (GTK_TOOL_PALETTE (palette));
      load_special_items (GTK_TOOL_PALETTE (palette));

      palette_scroller = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (palette_scroller),
                                      GTK_POLICY_NEVER,
                                      GTK_POLICY_AUTOMATIC);
      gtk_container_set_border_width (GTK_CONTAINER (palette_scroller), 6);

      gtk_container_add (GTK_CONTAINER (palette_scroller), palette);
      gtk_container_add (GTK_CONTAINER (hbox), palette_scroller);

      gtk_widget_show_all (box);

      /* Connect signals: */
      g_signal_connect (combo_orientation, "changed",
                        G_CALLBACK (on_combo_orientation_changed), palette);
      g_signal_connect (combo_style, "changed",
                        G_CALLBACK (on_combo_style_changed), palette);

      /* Keep the widgets in sync: */
      on_combo_orientation_changed (GTK_COMBO_BOX (combo_orientation), palette);

      /* ===== notebook ===== */

      notebook = gtk_notebook_new ();
      gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
      gtk_box_pack_end (GTK_BOX(hbox), notebook, FALSE, FALSE, 0);

      /* ===== DnD for tool items ===== */

      g_signal_connect (palette, "drag-data-received",
                        G_CALLBACK (palette_drag_data_received), NULL);

      gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette),
                                      palette,
                                      GTK_DEST_DEFAULT_ALL,
                                      GTK_TOOL_PALETTE_DRAG_ITEMS |
                                      GTK_TOOL_PALETTE_DRAG_GROUPS,
                                      GDK_ACTION_MOVE);

      /* ===== passive DnD dest ===== */

      contents = gtk_drawing_area_new ();
      gtk_widget_set_app_paintable (contents, TRUE);

      g_object_connect (contents,
                        "signal::expose-event", canvas_expose_event, NULL,
                        "signal::drag-data-received", passive_canvas_drag_data_received, NULL,
                        NULL);

      gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette),
                                      contents,
                                      GTK_DEST_DEFAULT_ALL,
                                      GTK_TOOL_PALETTE_DRAG_ITEMS,
                                      GDK_ACTION_COPY);

      contents_scroller = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (contents_scroller),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_ALWAYS);
      gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (contents_scroller),
                                             contents);
      gtk_container_set_border_width (GTK_CONTAINER (contents_scroller), 6);

      gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                                contents_scroller,
                                gtk_label_new ("Passive DnD Mode"));

      /* ===== interactive DnD dest ===== */

      contents = gtk_drawing_area_new ();
      gtk_widget_set_app_paintable (contents, TRUE);

      g_object_connect (contents,
                        "signal::expose-event", canvas_expose_event, NULL,
                        "signal::drag-motion", interactive_canvas_drag_motion, NULL,
                        "signal::drag-data-received", interactive_canvas_drag_data_received, NULL,
                        "signal::drag-leave", interactive_canvas_drag_leave, NULL,
                        "signal::drag-drop", interactive_canvas_drag_drop, NULL,
                        NULL);

      gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette),
                                      contents,
                                      GTK_DEST_DEFAULT_HIGHLIGHT,
                                      GTK_TOOL_PALETTE_DRAG_ITEMS,
                                      GDK_ACTION_COPY);

      contents_scroller = gtk_scrolled_window_new (NULL, NULL);
      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (contents_scroller),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_ALWAYS);
      gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (contents_scroller),
                                             contents);
      gtk_container_set_border_width (GTK_CONTAINER (contents_scroller), 6);

      gtk_notebook_append_page (GTK_NOTEBOOK (notebook), contents_scroller,
                                gtk_label_new ("Interactive DnD Mode"));
    }

  if (!gtk_widget_get_visible (window))
    {
      gtk_widget_show_all (window);
    }
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
CairoDesklet *cairo_dock_create_desklet (Icon *pIcon, GtkWidget *pInteractiveWidget, gboolean bOnWidgetLayer)
{
  cd_message ("%s ()", __func__);
  CairoDesklet *pDesklet = g_new0(CairoDesklet, 1);
  pDesklet->iType = CAIRO_DOCK_TYPE_DESKLET;
  pDesklet->bIsHorizontal = TRUE;
  pDesklet->bDirectionUp = TRUE;
  GtkWidget* pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	if (bOnWidgetLayer)
		gtk_window_set_type_hint (GTK_WINDOW (pWindow), GDK_WINDOW_TYPE_HINT_UTILITY);
  pDesklet->pWidget = pWindow;
  pDesklet->pIcon = pIcon;

  if (g_bSticky)
	  gtk_window_stick(GTK_WINDOW(pWindow));
  gtk_window_set_skip_pager_hint(GTK_WINDOW(pWindow), TRUE);
  gtk_window_set_skip_taskbar_hint(GTK_WINDOW(pWindow), TRUE);
  cairo_dock_set_colormap_for_window(pWindow);
  gtk_widget_set_app_paintable(pWindow, TRUE);
  gtk_window_set_decorated(GTK_WINDOW(pWindow), FALSE);
  gtk_window_set_resizable(GTK_WINDOW(pWindow), TRUE);
  gtk_window_set_title(GTK_WINDOW(pWindow), "cairo-dock-desklet");  /// distinguer titre et classe ?...
  gtk_widget_add_events(pWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_FOCUS_CHANGE_MASK);
  //the border is were cairo paint
  gtk_container_set_border_width(GTK_CONTAINER(pWindow), g_iDockRadius/2);  /// re-utiliser la formule des dialogues...
  gtk_window_set_default_size(GTK_WINDOW(pWindow), 2*g_iDockRadius+1, 2*g_iDockRadius+1);

	g_signal_connect (G_OBJECT (pWindow),
		"expose-event",
		G_CALLBACK (on_expose_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"configure-event",
		G_CALLBACK (on_configure_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"motion-notify-event",
		G_CALLBACK (on_motion_notify_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"button-press-event",
		G_CALLBACK (on_button_press_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"button-release-event",
		G_CALLBACK (on_button_press_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"focus-in-event",
		G_CALLBACK (cd_desklet_on_focus_in_out),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"focus-out-event",
		G_CALLBACK (cd_desklet_on_focus_in_out),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"enter-notify-event",
		G_CALLBACK (on_enter_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"leave-notify-event",
		G_CALLBACK (on_leave_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"delete-event",
		G_CALLBACK (on_delete_desklet),
		pDesklet);
	g_signal_connect (G_OBJECT (pWindow),
		"scroll-event",
		G_CALLBACK (on_scroll_desklet),
		pDesklet);
	cairo_dock_allow_widget_to_receive_data (pWindow, G_CALLBACK (on_drag_data_received_desklet), pDesklet);

  //user widget
  if (pInteractiveWidget != NULL)
  {
    cd_message ("ref = %d", pInteractiveWidget->object.parent_instance.ref_count);
    gtk_container_add (GTK_CONTAINER (pDesklet->pWidget), pInteractiveWidget);
    cd_message ("pack -> ref = %d", pInteractiveWidget->object.parent_instance.ref_count);
  }

  gtk_widget_show_all(pWindow);

  return pDesklet;
}
Example #5
0
console_t *uimon_window_open(void)
{
    GtkWidget *scrollbar, *horizontal_container;
    GdkGeometry hints;

    if (fixed.window == NULL) {
        fixed.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(fixed.window), "VICE monitor");
        gtk_window_set_position(GTK_WINDOW(fixed.window), GTK_WIN_POS_CENTER);
        gtk_widget_set_app_paintable(fixed.window, TRUE);
        gtk_window_set_deletable(GTK_WINDOW(fixed.window), TRUE);
        fixed.term = vte_terminal_new();
        vte_terminal_set_scrollback_lines (VTE_TERMINAL(fixed.term), 1000);
        vte_terminal_set_scroll_on_output (VTE_TERMINAL(fixed.term), TRUE);

        /* allowed window widths are base_width + width_inc * N
         * allowed window heights are base_height + height_inc * N
         */
        hints.width_inc = vte_terminal_get_char_width (VTE_TERMINAL(fixed.term));
        hints.height_inc = vte_terminal_get_char_height (VTE_TERMINAL(fixed.term));
        /* min size should be multiple of .._inc, else we get funky effects */
        hints.min_width = hints.width_inc;
        hints.min_height = hints.height_inc;
        /* base size should be multiple of .._inc, else we get funky effects */
        hints.base_width = hints.width_inc;
        hints.base_height = hints.height_inc;
        gtk_window_set_geometry_hints (GTK_WINDOW (fixed.window),
                                     fixed.term,
                                     &hints,
                                     GDK_HINT_RESIZE_INC |
                                     GDK_HINT_MIN_SIZE |
                                     GDK_HINT_BASE_SIZE);
#if GTK_CHECK_VERSION (2, 91, 1)
        {
            glong width, height;
            get_terminal_size_in_chars(VTE_TERMINAL(fixed.term), &width, &height);
            gtk_window_resize_to_geometry (GTK_WINDOW (fixed.window), width, height);
        }
#endif
        scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment (VTE_TERMINAL(fixed.term)));
        horizontal_container = gtk_hbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(fixed.window), horizontal_container);
        gtk_container_add(GTK_CONTAINER(horizontal_container), fixed.term);
        gtk_container_add(GTK_CONTAINER(horizontal_container), scrollbar);

        g_signal_connect(G_OBJECT(fixed.window), "delete-event",
            G_CALLBACK(close_window), &fixed.input_buffer);

        g_signal_connect(G_OBJECT(fixed.term), "key-press-event", 
            G_CALLBACK(key_press_event), &fixed.input_buffer);

        g_signal_connect(G_OBJECT(fixed.term), "button-press-event", 
            G_CALLBACK(button_press_event), &fixed.input_buffer);

        g_signal_connect (fixed.term, "text-modified",
            G_CALLBACK (screen_resize_window_cb), NULL);

        vte_console.console_can_stay_open = 1;
    }
    return uimon_window_resume();
}
Example #6
0
static void
gdaui_bar_init (GdauiBar *bar)
{
	GtkWidget *widget = GTK_WIDGET (bar);
	GtkWidget *content_area;
	GtkWidget *action_area;

	bar->priv = g_new0 (GdauiBarPrivate, 1);

	content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (content_area);
	gtk_box_pack_start (GTK_BOX (bar), content_area, TRUE, TRUE, 0);

	action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_widget_show (action_area);
	gtk_box_pack_start (GTK_BOX (bar), action_area, FALSE, TRUE, 0);

	gtk_widget_set_app_paintable (widget, TRUE);
	gtk_widget_set_redraw_on_allocate (widget, TRUE);

	bar->priv->content_area = content_area;
	bar->priv->action_area = action_area;

	/* set default spacings */
	gtk_box_set_spacing (GTK_BOX (bar->priv->action_area), ACTION_AREA_DEFAULT_SPACING);
	gtk_container_set_border_width (GTK_CONTAINER (bar->priv->action_area), ACTION_AREA_DEFAULT_BORDER);
	gtk_box_set_spacing (GTK_BOX (bar->priv->content_area), CONTENT_AREA_DEFAULT_SPACING);
	gtk_container_set_border_width (GTK_CONTAINER (bar->priv->content_area), CONTENT_AREA_DEFAULT_BORDER);

	bar->priv->show_icon = FALSE;
	bar->priv->icon = gtk_image_new ();
        gtk_misc_set_alignment (GTK_MISC (bar->priv->icon), 1., 0.5);
        gtk_widget_hide (bar->priv->icon);
        gtk_box_pack_end (GTK_BOX (bar->priv->content_area), bar->priv->icon,
			  FALSE, TRUE, 0);

	bar->priv->label = gtk_label_new ("");
        gtk_label_set_selectable (GTK_LABEL (bar->priv->label), FALSE);
        gtk_misc_set_alignment (GTK_MISC (bar->priv->label), 0., 0.5);
        gtk_box_pack_end (GTK_BOX (bar->priv->content_area), bar->priv->label,
                          TRUE, TRUE, 0);
        gtk_widget_show (bar->priv->label);

	/* CSS theming */
	GtkStyleContext *context;
	if (!css_provider) {
#define CSS ".gdauibar {\n"				\
			"background-color: #b3b3b3;\n"	\
			"padding: 5px;\n"		\
			"}"				\
			".gdauibar_button {\n"			\
			"-GtkButton-default-border : 0px;\n"	\
			"-GtkButton-default-outside-border : 0px;\n"	\
			"-GtkWidget-focus-line-width : 0px;\n"		\
			"-GtkWidget-focus-padding : 0px;\n"		\
			"padding: 0px;\n"				\
			"-GtkButtonBox-child-internal-pad-x : 1px;\n"	\
			"-GtkButtonBox-child-min-width : 0px;\n"	\
			"border-style: none;\n"				\
			"}"						\
			".gdauibar_entry {\n"				\
			"-GtkWidget-focus-line-width : 0px;\n"		\
			"-GtkWidget-focus-padding : 0px;\n"		\
			"padding: 1px;\n"				\
			"-GtkButtonBox-child-internal-pad-x : 1px;\n"	\
			"-GtkButtonBox-child-min-width : 0px;\n"	\
			"border-style: solid;\n"			\
			"border-radius: 5px;\n"				\
			"}"
		css_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
		gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (css_provider), CSS, -1, NULL);
	}
	context = gtk_widget_get_style_context (GTK_WIDGET (bar));
	gtk_style_context_add_provider (context, css_provider, G_MAXUINT);
	gtk_style_context_add_class (context, "gdauibar");
}
Example #7
0
void Create_system_NB(GtkWidget *parent)
{
	GtkWidget* model_notebook;
	GtkWidget* model_label;
	GtkWidget* fixed;
	GtkWidget *eventbox;
	gchar* markup;
	static GtkWidget *label;
	int i = 0;
	int len = 0;

	int pos_x = 125;
	int pos_y = 220;

	GdkPixbuf *pixbuf_active;
	system_notebook = gtk_notebook_new();
	gtk_notebook_set_tab_pos((GtkNotebook *)(system_notebook),GTK_POS_TOP);
	gtk_notebook_set_tab_border((GtkNotebook *)(system_notebook),2);
	gtk_widget_set_usize((GtkWidget *)system_notebook,550,450);
	gtk_container_set_border_width (GTK_CONTAINER (system_notebook), 10);
	gtk_notebook_set_show_border((GtkNotebook *)system_notebook,1);


	systoplabel = gtk_label_new(N_("System"));
	markup = g_markup_printf_escaped (MENUTITLESTYLE, \
		N_("System"));
	gtk_label_set_markup (GTK_LABEL (systoplabel), markup);
	g_free (markup);
	gtk_widget_set_usize (systoplabel, 100, 80);
	gtk_notebook_append_page (GTK_NOTEBOOK (parent), system_notebook, systoplabel);



#if 1

	//fixed = gtk_fixed_new();
	//gtk_widget_set_usize((GtkWidget *)fixed,550,450);
	//label = gtk_label_new ("Function");
	//markup = g_markup_printf_escaped (BTNPARASTYLE, \
	//	"Function");
	//gtk_label_set_markup (GTK_LABEL (label), markup);
	//gtk_widget_set_usize (label, 95, 80);
	//gtk_notebook_append_page (GTK_NOTEBOOK (system_notebook), fixed, label);


	//eventbox = gtk_event_box_new ();
	//gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	//gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	//set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	//gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	//gtk_widget_set_uposition(eventbox,pos_x,pos_y);


	syslabel[0] = gtk_label_new(N_("Language"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Language"));
	gtk_label_set_markup (GTK_LABEL (syslabel[0]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[0]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[1] = gtk_label_new(_("Desktop"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		_("Desktop"));
	gtk_label_set_markup (GTK_LABEL (syslabel[1]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[1]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}



	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[2] = gtk_label_new(N_("Zoom"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Zoom"));
	gtk_label_set_markup (GTK_LABEL (syslabel[2]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[2]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[3] = gtk_label_new(N_("Report"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Report"));
	gtk_label_set_markup (GTK_LABEL (syslabel[3]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[3]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}

	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[4] = gtk_label_new(N_("iTouch"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("iTouch"));
	gtk_label_set_markup (GTK_LABEL (syslabel[4]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[4]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[5] = gtk_label_new(N_("Patient"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Patient"));
	gtk_label_set_markup (GTK_LABEL (syslabel[5]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[5]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}



	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[6] = gtk_label_new(N_("Preset"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Preset"));
	gtk_label_set_markup (GTK_LABEL (syslabel[6]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[6]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	syslabel[7] = gtk_label_new(N_("Probe"));
	markup = g_markup_printf_escaped (BTNPARASTYLE, \
		N_("Probe"));
	gtk_label_set_markup (GTK_LABEL (syslabel[7]), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), syslabel[7]);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+20;
	}
	else
	{
		pos_x = 125;
		pos_y += TP2EVENTBOX_H+20;
	}
#endif
}
Example #8
0
static void
gtk_tooltip_init (GtkTooltip *tooltip)
{
  GtkStyleContext *context;
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *image;
  GtkWidget *label;
  GdkScreen *screen;
  GdkVisual *visual;

  tooltip->timeout_id = 0;
  tooltip->browse_mode_timeout_id = 0;

  tooltip->browse_mode_enabled = FALSE;
  tooltip->keyboard_mode_enabled = FALSE;

  tooltip->current_window = NULL;
  tooltip->keyboard_widget = NULL;

  tooltip->tooltip_widget = NULL;
  tooltip->toplevel_window = NULL;

  tooltip->last_window = NULL;

  window = gtk_window_new (GTK_WINDOW_POPUP);
  screen = gtk_widget_get_screen (window);
  visual = gdk_screen_get_rgba_visual (screen);

  if (visual != NULL)
    gtk_widget_set_visual (window, visual);

  gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
  gtk_widget_set_app_paintable (window, TRUE);
  gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
  gtk_widget_set_name (window, "gtk-tooltip");
  g_signal_connect (window, "hide",
                    G_CALLBACK (gtk_tooltip_window_hide), tooltip);

  context = gtk_widget_get_style_context (window);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLTIP);

  g_signal_connect_swapped (window, "draw",
                            G_CALLBACK (gtk_tooltip_paint_window), tooltip);
  g_signal_connect_swapped (window, "realize",
                            G_CALLBACK (gtk_tooltip_realize_window), tooltip);
  g_signal_connect_swapped (window, "composited-changed",
                            G_CALLBACK (gtk_tooltip_composited_changed), tooltip);

  /* FIXME: don't hardcode the padding */
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_widget_set_margin_left (box, 6);
  gtk_widget_set_margin_right (box, 6);
  gtk_widget_set_margin_top (box, 6);
  gtk_widget_set_margin_bottom (box, 6);
  gtk_container_add (GTK_CONTAINER (window), box);
  gtk_widget_show (box);

  image = gtk_image_new ();
  gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);

  label = gtk_label_new ("");
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);

  tooltip->window = window;
  tooltip->box = box;
  tooltip->image = image;
  tooltip->label = label;
  tooltip->custom_widget = NULL;
}
Example #9
0
static GtkWidget *
create_label_window (MateRRLabeler *labeler, MateRROutputInfo *output, GdkColor *color)
#endif
{
	GtkWidget *window;
	GtkWidget *widget;
	char *str;
	const char *display_name;
#if GTK_CHECK_VERSION (3, 0, 0)
	GdkRGBA black = { 0., 0., 0., 1. };
#else
	GdkColor black = { 0, 0, 0, 0 };
#endif
	int x,y;

	window = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_widget_set_app_paintable (window, TRUE);

	gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);

	/* This is semi-dangerous.  The color is part of the labeler->palette
	 * array.  Note that in mate_rr_labeler_finalize(), we are careful to
	 * free the palette only after we free the windows.
	 */
	g_object_set_data (G_OBJECT (window), "color", color);

#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect (window, "draw",
			  G_CALLBACK (label_window_draw_event_cb), labeler);
#else
	g_signal_connect (window, "expose-event",
			  G_CALLBACK (label_window_expose_event_cb), labeler);
#endif

	if (mate_rr_config_get_clone (labeler->priv->config)) {
		/* Keep this string in sync with mate-control-center/capplets/display/xrandr-capplet.c:get_display_name() */

		/* Translators:  this is the feature where what you see on your laptop's
		 * screen is the same as your external monitor.  Here, "Mirror" is being
		 * used as an adjective, not as a verb.  For example, the Spanish
		 * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
		 */
		display_name = g_strdup_printf (_("Mirror Screens"));
		str = g_strdup_printf ("<b>%s</b>", display_name);
	} else {
		display_name = g_strdup_printf ("<b>%s</b>\n<small>%s</small>", mate_rr_output_info_get_display_name (output), mate_rr_output_info_get_name (output));
		str = g_strdup_printf ("%s", display_name);
	}
	g_free (display_name);

	widget = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (widget), str);
	g_free (str);

	/* Make the label explicitly black.  We don't want it to follow the
	 * theme's colors, since the label is always shown against a light
	 * pastel background.  See bgo#556050
	 */
#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_override_color(widget, gtk_widget_get_state_flags (widget), &black);
#else
	gtk_widget_modify_fg (widget, gtk_widget_get_state (widget), &black);
#endif

	gtk_container_add (GTK_CONTAINER (window), widget);

	/* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
	mate_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
	position_window (labeler, window, x, y);

	gtk_widget_show_all (window);

	return window;
}
static GtkWidget *
create_label_window (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba)
{
	GtkWidget *window;
	GtkWidget *widget;
	char *str;
	const char *display_name;
	GdkRGBA black = { 0, 0, 0, 1.0 };
	int x, y;
	GdkScreen *screen;
	GdkVisual *visual;

	window = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
	gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
	gtk_widget_set_app_paintable (window, TRUE);
	screen = gtk_widget_get_screen (window);
	visual = gdk_screen_get_rgba_visual (screen);

	if (visual != NULL)
		gtk_widget_set_visual (window, visual);

	gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);

	/* This is semi-dangerous.  The color is part of the labeler->palette
	 * array.  Note that in cc_rr_labeler_finalize(), we are careful to
	 * free the palette only after we free the windows.
	 */
	g_object_set_data (G_OBJECT (window), "rgba", rgba);

	g_signal_connect (window, "draw",
			  G_CALLBACK (label_window_draw_event_cb), labeler);
	g_signal_connect (window, "realize",
			  G_CALLBACK (label_window_realize_cb), labeler);
	g_signal_connect (window, "composited-changed",
			  G_CALLBACK (label_window_composited_changed_cb), labeler);

	if (gnome_rr_config_get_clone (labeler->priv->config)) {
		/* Keep this string in sync with gnome-control-center/capplets/display/xrandr-capplet.c:get_display_name() */

		/* Translators:  this is the feature where what you see on your
		 * laptop's screen is the same as your external projector.
		 * Here, "Mirrored" is being used as an adjective.  For example,
		 * the Spanish translation could be "Pantallas en Espejo".
		 */
		display_name = _("Mirrored Displays");
	} else
		display_name = gnome_rr_output_info_get_display_name (output);

	str = g_strdup_printf ("<b>%s</b>", display_name);
	widget = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (widget), str);
	g_free (str);

	/* Make the label explicitly black.  We don't want it to follow the
	 * theme's colors, since the label is always shown against a light
	 * pastel background.  See bgo#556050
	 */
	gtk_widget_override_color (widget,
				   gtk_widget_get_state_flags (widget),
				   &black);

	gtk_container_add (GTK_CONTAINER (window), widget);

	/* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
	gnome_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
	position_window (labeler, window, x, y);

	gtk_widget_show_all (window);

	return window;
}
Example #11
0
static void
egg_tray_manager_handle_dock_request(EggTrayManager *manager,
    XClientMessageEvent  *xevent)
{
    GtkWidget *socket;
    Window *window;

    ENTER;
    socket = gtk_socket_new ();
    gtk_widget_set_app_paintable (socket, TRUE);
    gtk_widget_set_double_buffered (socket, FALSE);
    gtk_widget_add_events (socket, GDK_EXPOSURE_MASK);
    
    g_signal_connect (socket, "realize",
          G_CALLBACK (egg_tray_manager_make_socket_transparent), NULL);
    g_signal_connect (socket, "expose_event",
          G_CALLBACK (egg_tray_manager_socket_exposed), NULL);
    g_signal_connect_after (socket, "style_set",
          G_CALLBACK (egg_tray_manager_socket_style_set), NULL);
    gtk_widget_show (socket);


    /* We need to set the child window here
     * so that the client can call _get functions
     * in the signal handler
     */
    window = g_new (Window, 1);
    *window = xevent->data.l[2];
    DBG("plug window %lx\n", *window);
    g_object_set_data_full (G_OBJECT (socket), "egg-tray-child-window",
        window, g_free);
    g_signal_emit(manager, manager_signals[TRAY_ICON_ADDED], 0,
        socket);
    /* Add the socket only if it's been attached */
    if (GTK_IS_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(socket)))) {
        GtkRequisition req;
        XWindowAttributes wa;
        
        DBG("socket has window. going on\n");
        gtk_socket_add_id(GTK_SOCKET (socket), xevent->data.l[2]);
        g_signal_connect(socket, "plug_removed",
              G_CALLBACK(egg_tray_manager_plug_removed), manager);

        gdk_error_trap_push();
        XGetWindowAttributes(GDK_DISPLAY(), *window, &wa);
        if (gdk_error_trap_pop()) {
            ERR("can't embed window %lx\n", xevent->data.l[2]);
            goto error;
        }
        g_hash_table_insert(manager->socket_table,
            GINT_TO_POINTER(xevent->data.l[2]), socket);
        req.width = req.height = 1;
        gtk_widget_size_request(socket, &req);
        RET();
    }
error:    
    DBG("socket has NO window. destroy it\n");
    g_signal_emit(manager, manager_signals[TRAY_ICON_REMOVED], 0,
        socket);
    gtk_widget_destroy(socket);
    RET();
}
Example #12
0
static void
gtk_tooltip_init (GtkTooltip *tooltip)
{
  tooltip->timeout_id = 0;
  tooltip->browse_mode_timeout_id = 0;

  tooltip->browse_mode_enabled = FALSE;
  tooltip->keyboard_mode_enabled = FALSE;

  tooltip->current_window = NULL;
  tooltip->keyboard_widget = NULL;

  tooltip->tooltip_widget = NULL;
  tooltip->toplevel_window = NULL;

  tooltip->last_window = NULL;

  tooltip->window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP));

  on_screen_changed (tooltip->window, NULL, tooltip);

  gtk_window_set_type_hint (GTK_WINDOW (tooltip->window),
			    GDK_WINDOW_TYPE_HINT_TOOLTIP);

  gtk_widget_set_app_paintable (tooltip->window, TRUE);
  gtk_window_set_resizable (GTK_WINDOW (tooltip->window), FALSE);
  gtk_widget_set_name (tooltip->window, "gtk-tooltip");
  g_signal_connect (tooltip->window, "hide",
		    G_CALLBACK (gtk_tooltip_window_hide), tooltip);

  tooltip->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
  gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
			     tooltip->window->style->ythickness,
			     tooltip->window->style->ythickness,
			     tooltip->window->style->xthickness,
			     tooltip->window->style->xthickness);
  gtk_container_add (GTK_CONTAINER (tooltip->window), tooltip->alignment);
  gtk_widget_show (tooltip->alignment);

  g_signal_connect_swapped (tooltip->window, "style-set",
			    G_CALLBACK (gtk_tooltip_window_style_set), tooltip);
  g_signal_connect_swapped (tooltip->window, "expose-event",
			    G_CALLBACK (gtk_tooltip_paint_window), tooltip);

  tooltip->box = gtk_hbox_new (FALSE, tooltip->window->style->xthickness);
  gtk_container_add (GTK_CONTAINER (tooltip->alignment), tooltip->box);
  gtk_widget_show (tooltip->box);

  tooltip->image = gtk_image_new ();
  gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->image,
		      FALSE, FALSE, 0);

  tooltip->label = gtk_label_new ("");
  gtk_label_set_line_wrap (GTK_LABEL (tooltip->label), TRUE);
  gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->label,
		      FALSE, FALSE, 0);

  g_signal_connect (tooltip->window, "composited-changed",
                    G_CALLBACK (on_composited_changed), tooltip);
  g_signal_connect (tooltip->window, "screen-changed",
                    G_CALLBACK (on_screen_changed), tooltip);
  g_signal_connect (tooltip->window, "realize",
                    G_CALLBACK (on_realized), tooltip);

  tooltip->custom_widget = NULL;
}
Example #13
0
void
CReciteWord::create ()
{
	init ();

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


	gtk_widget_set_events(window,GDK_SCROLL_MASK);
	gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
	gtk_widget_set_app_paintable(window,TRUE);
	gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
	gtk_widget_set_size_request (window, Skin->reciteword.width, Skin->reciteword.height);
	gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (window), _("ReciteWord"));

	gtk_widget_realize(window);
	skin_load_reciteword (window);
	skin_load_face (window);

	gtk_window_set_icon (GTK_WINDOW(window),Skin->face.icon.p[0]);
	
	tooltips = gtk_tooltips_new ();
	
	fixed = gtk_fixed_new ();
	//gtk_fixed_set_has_window(GTK_FIXED(fixed),TRUE);
	gtk_container_add (GTK_CONTAINER (window), fixed);
	gtk_widget_show (fixed);
	SetBackPixmap (fixed, Skin->face.face.p[0]);

	help_button.create (fixed, Skin->face.help_button.x[0],
			    Skin->face.help_button.y[0], Skin->face.help_button.p[0],
			    Skin->face.help_button.p[1],
			    Skin->face.help_button.p[2], PopupHelp, NULL);
	record_button.create (fixed, Skin->face.record_button.x[0],
			      Skin->face.record_button.y[0],
			      Skin->face.record_button.p[0],
			      Skin->face.record_button.p[1],
			      Skin->face.record_button.p[2], PopupRecord, NULL);
	option_button.create (fixed, Skin->face.option_button.x[0],
			     Skin->face.option_button.y[0],
			     Skin->face.option_button.p[0],
			     Skin->face.option_button.p[1],
			     Skin->face.option_button.p[2], PopupOption, NULL);
	dict_button.create (fixed, Skin->face.dict_button.x[0],
			    Skin->face.dict_button.y[0], Skin->face.dict_button.p[0],
			    Skin->face.dict_button.p[1],
			    Skin->face.dict_button.p[2], PopupDict, NULL);
	about_button.create (fixed, Skin->face.about_button.x[0],
			     Skin->face.about_button.y[0],
			     Skin->face.about_button.p[0],
			     Skin->face.about_button.p[1],
			     Skin->face.about_button.p[2], PopupAbout, NULL);

	GtkWidget *event_box = gtk_event_box_new ();
	gtk_fixed_put (GTK_FIXED (fixed), event_box, Skin->face.menubar.x[0],
		       Skin->face.menubar.y[0]);
	GtkWidget *pixmap_widget = gtk_image_new_from_pixmap (Skin->face.menubar.p[0], NULL);
	gtk_container_add (GTK_CONTAINER (event_box), pixmap_widget);
	gtk_widget_show (pixmap_widget);
	gtk_widget_show (event_box);

	g_signal_connect (G_OBJECT (event_box), "enter_notify_event",
			  G_CALLBACK (on_menu_bar_enter_notify), this);
	g_signal_connect (G_OBJECT (window), "enter_notify_event",
			  G_CALLBACK (on_window_enter_notify), this);

	g_signal_connect (G_OBJECT (window), "button_press_event",
			  G_CALLBACK (on_mainwnd_button_press), this);
	g_signal_connect (G_OBJECT (window), "scroll_event",
			  G_CALLBACK (on_mainwnd_scroll), this);
	g_signal_connect (G_OBJECT (window), "delete_event",
			  G_CALLBACK (on_mainwnd_delete_event), this);
	gtk_widget_show (window);
	gdk_threads_enter();
	gtk_main ();
	gdk_threads_leave();
}
Example #14
0
int
main (int    argc,
      char** argv)
{
	GtkWidget* window;
	guint      pointer_update_id;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	if (!window)
		return 0;

	gtk_window_set_type_hint (GTK_WINDOW (window),
				  GDK_WINDOW_TYPE_HINT_DOCK);

	gtk_widget_add_events (window,
			       GDK_POINTER_MOTION_MASK |
			       GDK_BUTTON_PRESS_MASK |
			       GDK_BUTTON_RELEASE_MASK);

	// hook up input/event handlers to window
	g_signal_connect (G_OBJECT (window),
			  "screen-changed",
			  G_CALLBACK (screen_changed_handler),
			  NULL);
	g_signal_connect (G_OBJECT (window),
			  "composited-changed",
			  G_CALLBACK (composited_changed_handler),
			  NULL);

	gtk_window_move (GTK_WINDOW (window), POS_X, POS_Y);

	// make sure the window opens with a RGBA-visual
	screen_changed_handler (window, NULL, NULL);
	gtk_widget_realize (window);
	gdk_window_set_back_pixmap (gtk_widget_get_window (window), NULL, FALSE);

	// hook up window-event handlers to window
	g_signal_connect (G_OBJECT (window),
			  "expose-event",
			  G_CALLBACK (expose_handler),
			  NULL);       

	// FIXME: read out current mouse-pointer position every 1/25 second
        pointer_update_id = g_timeout_add (1000/40,
					   (GSourceFunc) pointer_update,
					   (gpointer) window);

	g_timeout_add (10000,
		       (GSourceFunc) quit,
		       NULL);

	g_timeout_add (1000/40,
		       (GSourceFunc) grow,
		       (gpointer) window);

	// "clear" input-mask, set title/icon/attributes
	gtk_widget_set_app_paintable (window, TRUE);
	gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
	gtk_window_set_keep_above (GTK_WINDOW (window), TRUE);
	gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
	gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
	gtk_window_set_opacity (GTK_WINDOW (window), 1.0f);
	gtk_widget_set_size_request (window,
				     (gint) (BUBBLE_WIDTH + 2.0f *
					     BUBBLE_SHADOW_SIZE),
				     (gint) (BUBBLE_HEIGHT + 2.0f *
					     BUBBLE_SHADOW_SIZE));
	gtk_widget_show (window);

	g_composited = gdk_screen_is_composited(gtk_widget_get_screen (window));

	update_input_shape (window, 1, 1);
	update_shape (window,
		      (gint) CORNER_RADIUS,
		      (gint) BUBBLE_SHADOW_SIZE);

	set_bg_blur (window, TRUE);

	setup_tile ((gint) (BUBBLE_WIDTH + 2.0f * BUBBLE_SHADOW_SIZE),
		    (gint) (BUBBLE_HEIGHT + 2.0f * BUBBLE_SHADOW_SIZE));

	g_print ("This test will run for 10 seconds and then quit.\n");

	gtk_main ();

	tile_destroy (g_tile);

	return 0;
}
Example #15
0
void
meta_fixed_tip_show (Display *xdisplay, int screen_number,
                     int root_x, int root_y,
                     const char *markup_text)
{
  int w, h;
  
  if (tip == NULL)
    {      
      tip = gtk_window_new (GTK_WINDOW_POPUP);
      gtk_window_set_type_hint (GTK_WINDOW(tip), GDK_WINDOW_TYPE_HINT_TOOLTIP);

      {
        GdkScreen *gdk_screen;
	GdkRectangle monitor;
	gint mon_num;

        gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
                                             screen_number);
        gtk_window_set_screen (GTK_WINDOW (tip),
                               gdk_screen);
	mon_num = gdk_screen_get_monitor_at_point (gdk_screen, root_x, root_y);
	gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor);
	screen_right_edge = monitor.x + monitor.width;
	screen_bottom_edge = monitor.y + monitor.height;
      }
      
      gtk_widget_set_app_paintable (tip, TRUE);
      gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
      gtk_widget_set_name (tip, "gtk-tooltips");
      gtk_container_set_border_width (GTK_CONTAINER (tip), 4);

      #if GTK_CHECK_VERSION(3, 0, 0)
      g_signal_connect (tip, "draw",
                        G_CALLBACK (draw_handler), NULL);      
      #else
      g_signal_connect_swapped (tip, "expose_event",
				 G_CALLBACK (expose_handler), NULL);
      #endif

      label = gtk_label_new (NULL);
      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
      gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
      gtk_widget_show (label);
      
      gtk_container_add (GTK_CONTAINER (tip), label);

      g_signal_connect (tip, "destroy",
			G_CALLBACK (gtk_widget_destroyed), &tip);
    }

  gtk_label_set_markup (GTK_LABEL (label), markup_text);
  
  gtk_window_get_size (GTK_WINDOW (tip), &w, &h);

  if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
      root_x = MAX(0, root_x - w);

  if ((root_x + w) > screen_right_edge)
    root_x -= (root_x + w) - screen_right_edge;
  
  gtk_window_move (GTK_WINDOW (tip), root_x, root_y);

  gtk_widget_show (tip);
}
Example #16
0
void init_ui(int *argcp, char ***argvp)
{
	GtkWidget *win;
	GtkWidget *notebook;
	GtkWidget *dive_info;
	GtkWidget *dive_list;
	GtkWidget *equipment;
	GtkWidget *stats;
	GtkWidget *menubar;
	GtkWidget *vbox;
	GdkScreen *screen;
	GtkIconTheme *icon_theme=NULL;
	GtkSettings *settings;

	gtk_init(argcp, argvp);
	settings = gtk_settings_get_default();
	gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "subsurface setting");

	g_type_init();

	subsurface_open_conf();
	if (subsurface_get_conf("feet", PREF_BOOL))
		output_units.length = FEET;
	if (subsurface_get_conf("psi", PREF_BOOL))
		output_units.pressure = PSI;
	if (subsurface_get_conf("cuft", PREF_BOOL))
		output_units.volume = CUFT;
	if (subsurface_get_conf("fahrenheit", PREF_BOOL))
		output_units.temperature = FAHRENHEIT;
	/* an unset key is FALSE - all these are hidden by default */
	visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL));
	visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL));
	visible_cols.nitrox = PTR_TO_BOOL(subsurface_get_conf("NITROX", PREF_BOOL));
	visible_cols.otu = PTR_TO_BOOL(subsurface_get_conf("OTU", PREF_BOOL));
	visible_cols.sac = PTR_TO_BOOL(subsurface_get_conf("SAC", PREF_BOOL));

	divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);

	if (!divelist_font)
		divelist_font = DIVELIST_DEFAULT_FONT;

	error_info_bar = NULL;
	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_set_application_name ("subsurface");
	/* Let's check if the subsurface icon has been installed or if
	 * we need to try to load it from the current directory */
	screen = gdk_screen_get_default();
	if (screen)
		icon_theme = gtk_icon_theme_get_for_screen(screen);
	if (icon_theme) {
		if (gtk_icon_theme_has_icon(icon_theme, "subsurface")) {
			need_icon = FALSE;
			gtk_window_set_default_icon_name ("subsurface");
		}
	}
	if (need_icon)
#if defined __linux__ || defined __APPLE__
		gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.svg", NULL);
#elif defined WIN32
		gtk_window_set_icon_from_file(GTK_WINDOW(win), "subsurface.ico", NULL);
#endif
	g_signal_connect(G_OBJECT(win), "delete-event", G_CALLBACK(on_delete), NULL);
	g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
	main_window = win;

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(win), vbox);
	main_vbox = vbox;

	menubar = get_menubar_menu(win);
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);

	vpane = gtk_vpaned_new();
	gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 3);

	hpane = gtk_hpaned_new();
	gtk_paned_add1(GTK_PANED(vpane), hpane);

	/* Notebook for dive info vs profile vs .. */
	notebook = gtk_notebook_new();
	gtk_paned_add1(GTK_PANED(hpane), notebook);
	g_signal_connect(notebook, "switch-page", G_CALLBACK(switch_page), NULL);

	/* Create the actual divelist */
	dive_list = dive_list_create();
	gtk_widget_set_name(dive_list, "Dive List");
	gtk_paned_add2(GTK_PANED(vpane), dive_list);

	/* Frame for dive profile */
	dive_profile = dive_profile_widget();
	gtk_widget_set_name(dive_profile, "Dive Profile");
	gtk_paned_add2(GTK_PANED(hpane), dive_profile);

	/* Frame for extended dive info */
	dive_info = extended_dive_info_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_info, gtk_label_new("Dive Notes"));

	/* Frame for dive equipment */
	equipment = equipment_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), equipment, gtk_label_new("Equipment"));

	/* Frame for dive statistics */
	stats = stats_widget();
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), stats, gtk_label_new("Info & Stats"));

	gtk_widget_set_app_paintable(win, TRUE);
	gtk_widget_show_all(win);

	return;
}
Example #17
0
void create_preferences_window(void)
{
    GError *error = NULL;
    GtkWidget *pl3_win = playlist3_get_window();
    GtkWidget *dialog;
    GtkCellRenderer *renderer;
    GtkTreeViewColumn *column;
    GtkWidget *label;
    int i = 0;
    char *string = NULL;

    if (running)
    {
        if (xml_preferences_window == NULL)
        {
            running = 0;
        } else
        {
            dialog = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "preferences_window");
            gtk_window_present(GTK_WINDOW(dialog));
            return;
        }
    }
    plugin_last = -1;
    string = gmpc_get_full_glade_path("preferences.ui");
    xml_preferences_window = gtk_builder_new();
    gtk_builder_add_from_file(xml_preferences_window, string, &error);
    q_free(string);
    if (error)
    {
        g_log(LOG_DOMAIN, G_LOG_LEVEL_ERROR, "Failed to load preferences.ui: %s", error->message);
        g_error_free(error);
    }
    /* set info from struct */
    /* hostname */
    dialog = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "preferences_window");
    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pl3_win));
    gtk_widget_show_all(GTK_WIDGET(dialog));
    running = 1;

    plugin_store_unfiltered = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
    /* Create a filtered list that hides the disabled plugins */
    plugin_store = gtk_tree_model_filter_new(GTK_TREE_MODEL(plugin_store_unfiltered), NULL);

    gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(plugin_store),
            pref_model_filter_func, NULL, NULL);

    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column, _("Plugins"));
    renderer = gtk_cell_renderer_text_new();
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
    gtk_tree_view_column_set_attributes(column, renderer, "markup", 1, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")), column);

    g_signal_connect(G_OBJECT
        (gtk_tree_view_get_selection
        (GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")))), "changed",
        G_CALLBACK(pref_plugin_changed), NULL);
    gtk_tree_view_set_model(GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")),
        GTK_TREE_MODEL(plugin_store));

    /* internals */
    for (i = 0; i < num_plugins; i++)
    {
        if (gmpc_plugin_has_preferences(plugins[i]))
        {
            if (gmpc_plugin_is_internal(plugins[i]))
            {
                GtkTreeIter iter;
                gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter);
                gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, i,
                    #if defined(ENABLE_NLS) &&  GLIB_CHECK_VERSION(2,18,0)
                    1, _(gmpc_plugin_get_name(plugins[i])),
                    #else
                    1, gmpc_plugin_get_name(plugins[i]),
                    #endif
                    -1);
            }
        }
    }
    // Select the first row
    // TODO: Move this outside the loop.
    if (gtk_tree_selection_count_selected_rows
            (gtk_tree_view_get_selection
                    (GTK_TREE_VIEW(gtk_builder_get_object(xml_preferences_window, "plugin_tree")))) == 0)
    {
        GtkTreeIter iter;
        if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(plugin_store), &iter))
        {
            gtk_tree_selection_select_iter(gtk_tree_view_get_selection
                    (GTK_TREE_VIEW
                     (gtk_builder_get_object(xml_preferences_window, "plugin_tree"))),
                    &iter);
        }
    }
    /* plugins */
    {
        GtkTreeIter iter;
        gchar *value = g_markup_printf_escaped("<b>%s:</b>", _("Plugins"));

        gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter);
        gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, PLUGIN_STATS, 1, value, -1);
        g_free(value);
        for (i = 0; i < num_plugins; i++)
        {
            if (gmpc_plugin_has_preferences(plugins[i]) && !gmpc_plugin_is_internal(plugins[i]))
            {
                const gchar *translation_domain = gmpc_plugin_get_translation_domain(plugins[i]);
                gtk_list_store_append(GTK_LIST_STORE(plugin_store_unfiltered), &iter);
                gtk_list_store_set(GTK_LIST_STORE(plugin_store_unfiltered), &iter, 0, i,
                    #if defined(ENABLE_NLS) &&  GLIB_CHECK_VERSION(2,18,0)
                    1, g_dgettext(translation_domain, gmpc_plugin_get_name(plugins[i])),
                    #else
                    1, gmpc_plugin_get_name(plugins[i]),
                    #endif
                    -1);
            }
        }
    }
    {

        GtkWidget *widget = (GtkWidget *) gtk_builder_get_object(xml_preferences_window,
            "eventbox_background");

        gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &(dialog->style->base[GTK_STATE_NORMAL]));
    }

    label = (GtkWidget *) gtk_builder_get_object(xml_preferences_window, "plugin_label_box");
    gtk_widget_set_app_paintable(label, TRUE);
    g_signal_connect(G_OBJECT(label), "expose-event", G_CALLBACK(misc_header_expose_event), NULL);
    gtk_widget_set_state(GTK_WIDGET(label), GTK_STATE_SELECTED);

    gtk_widget_show(dialog);
    gtk_builder_connect_signals(xml_preferences_window, NULL);
}
static void
gs_theme_window_init (GSThemeWindow *window)
{
	gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
}
Example #19
0
void Create_system_NB_T( void *parent )
{
	GtkWidget* pageSystemEventBox;
	GtkWidget* model_label;
	GtkWidget* fixed_pageSystem, *fixed;
	GtkWidget *eventbox;
	gchar* markup;
	static GtkWidget *label;
	int i = 0;
	int len = 0;

	int pos_x = 30;
	int pos_y = 15;



	pageSystemEventBox = gtk_event_box_new();
	gtk_widget_set_usize((GtkWidget *)pageSystemEventBox,88,57);
	label = gtk_label_new(_("System"));
	markup = g_markup_printf_escaped (MENUTITLESTYLE,\
		_("System"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (pageSystemEventBox), label);
	fixed_pageSystem = gtk_fixed_new();
	gtk_fixed_set_has_window((GtkFixed *)fixed_pageSystem,1);
	gtk_widget_set_usize((GtkWidget *)fixed_pageSystem,783,358);
	
	set_widget_bc_pixmap((GtkWidget *)fixed_pageSystem,TP2_TAB_CONTANT_BG_IMG,NULL,NULL);
	ZJ_TabView_append_page((TABVIEW*)parent,fixed_pageSystem,pageSystemEventBox);


#if 1

	fixed = fixed_pageSystem;



	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	gtk_container_add (GTK_CONTAINER (fixed_pageSystem), eventbox);
	label = gtk_label_new(_("Language"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		g_locale_to_utf8(_("Language"), -1, NULL, NULL, NULL));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), SYS_LANGUAGE);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Desktop"));
	//markup = g_markup_printf_escaped (BTNPARASTYLE,
	//	g_locale_to_utf8(_("Desktop"), -1, NULL, NULL, NULL));
	markup = g_markup_printf_escaped (BTNPARASTYLE,
		_("Desktop"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), SYS_RETURN2DESKTOP);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}



	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Zoom"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("Zoom"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Report"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("Report"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}

	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("iTouch"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("iTouch"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Patient"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("Patient"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}



	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Preset"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("Preset"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}


	eventbox = gtk_event_box_new ();
	gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE);
	gtk_container_add (GTK_CONTAINER (fixed), eventbox);
	set_widget_bc_pixmap((GtkWidget*)eventbox,TP2_MENUBUTTON_IMG,NULL,NULL);	
	gtk_widget_set_size_request (GTK_WIDGET (eventbox), TP2EVENTBOX_W, TP2EVENTBOX_H);
	gtk_widget_set_uposition(eventbox,pos_x,pos_y);

	label = gtk_label_new(_("Probe"));
	markup = g_markup_printf_escaped (UNACTBTNPARASTYLE, \
		_("Probe"));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_container_add (GTK_CONTAINER (eventbox), label);

	g_signal_connect (G_OBJECT (eventbox), "enter-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "leave-notify-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-press-event",G_CALLBACK (mouse_event_handle), NULL);
	g_signal_connect (G_OBJECT (eventbox), "button-release-event",G_CALLBACK (mouse_event_handle), NULL);
	if(pos_x<550)
	{
		pos_x+=TP2EVENTBOX_W+30;
	}
	else
	{
		pos_x = 30;
		pos_y += TP2EVENTBOX_H+16;
	}
#endif
}
Example #20
0
_HYPlatformWindow::_HYPlatformWindow(unsigned char windowFlag,_String windowTitle,bool windowVisibility, Ptr theParent)
{
    lastWW = lastWH = 0;
    last_H_Position = 0.0;
    last_V_Position = -1.0;

    if (windowFlag & HY_WINDOW_SHEET)
        windowFlag |= HY_WINDOW_DLOG;

    theWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    // debug color set here
    /*_HYColor red = {255,0,0};
    GdkColor redGDK = HYColorToGDKColor(red);
    gtk_widget_modify_bg (theWindow, GTK_STATE_NORMAL, &redGDK);*/

    gtk_window_set_title (GTK_WINDOW (theWindow), windowTitle.sData);
    gtk_container_set_border_width (GTK_CONTAINER (theWindow), 0);

    gtk_window_set_default_size (GTK_WINDOW(theWindow),300,250);
    gtk_window_set_resizable	(GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_SIZE);
    gtk_widget_set_events		(theWindow,GDK_ALL_EVENTS_MASK-GDK_POINTER_MOTION_HINT_MASK);
    //gtk_widget_set_events		(theWindow,GDK_POINTER_MOTION_MASK);

    g_signal_connect (G_OBJECT (theWindow), "event",			G_CALLBACK (window_event_callback),		(_HYWindow*)this);
    g_signal_connect (G_OBJECT (theWindow), "activate-default",	G_CALLBACK (activate_window_callback),	(_HYWindow*)this);
    //g_signal_connect (G_OBJECT (theWindow), "expose-event",		G_CALLBACK (window_expose_callback),	(_HYWindow*)this);
    // a(and other menu user UI events)

    if (theParent)
    {
        gtk_window_set_transient_for (GTK_WINDOW(theWindow), GTK_WINDOW((GtkWidget*)((_HYWindow*)theParent)->theWindow));
        gtk_window_set_destroy_with_parent (GTK_WINDOW(theWindow),true);
    }

    windowContent = gtk_fixed_new ();
    g_signal_connect (G_OBJECT (windowContent), "expose-event",	G_CALLBACK (window_expose_callback),	(_HYWindow*)this);
    //g_signal_connect (G_OBJECT (windowContent), "window-state-event",	G_CALLBACK (null_window_state), nil);
    gtk_widget_set_app_paintable(windowContent,TRUE);
    gtk_container_set_resize_mode (GTK_CONTAINER(windowContent),GTK_RESIZE_IMMEDIATE);

    menu_items = nil;

    if (windowFlag & HY_WINDOW_DLOG)
        windowMB = nil;
    else
    {
        windowMB = theWindow;
        ((_HYWindow*)this)->_SetMenuBar  ();
    }

    gtk_widget_show (windowContent);

    if ((windowFlag&HY_WINDOW_SCROLL)&&(windowFlag&HY_WINDOW_SIZE))
    {
        vbox = gtk_vbox_new (FALSE, 0);
        hbox = gtk_hbox_new (FALSE, 0);

        GtkObject
        *v_adj = gtk_adjustment_new(0,0,MAX_CONTROL_VALUE,MAX_CONTROL_VALUE/100.0,MAX_CONTROL_VALUE/10.0,MAX_CONTROL_VALUE/5.0),
         *h_adj = gtk_adjustment_new(0,0,MAX_CONTROL_VALUE,MAX_CONTROL_VALUE/100.0,MAX_CONTROL_VALUE/10.0,MAX_CONTROL_VALUE/5.0);

        vScroll = gtk_vscrollbar_new  ((GtkAdjustment*)v_adj),
        hScroll = gtk_hscrollbar_new  ((GtkAdjustment*)h_adj);

        /*GtkWidget * tScroll = gtk_vscrollbar_new ((GtkAdjustment*)t_adj);
        gtk_widget_set_size_request(tScroll,20,100);

        gtk_fixed_put (GTK_FIXED(windowContent), tScroll, 30,40);
        gtk_widget_show (tScroll);*/

        gtk_widget_show (hScroll);
        gtk_widget_show (vScroll);
        gtk_widget_show (hbox);
        gtk_widget_show (vbox);

        g_signal_connect (G_OBJECT (vScroll), "value-changed",G_CALLBACK (v_scroll_bar_callback_window), (gpointer)((_HYWindow*)this));
        g_signal_connect (G_OBJECT (hScroll), "value-changed",G_CALLBACK (h_scroll_bar_callback_window), (gpointer)((_HYWindow*)this));

        gtk_box_pack_start (GTK_BOX (hbox), windowContent, TRUE, TRUE, 0);
        gtk_box_pack_end   (GTK_BOX (hbox), vScroll, FALSE, FALSE, 0);

        if (windowMB)
        {
            gtk_box_pack_start (GTK_BOX (vbox), windowMB, FALSE, FALSE, 0);
        }
        gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
        gtk_box_pack_end (GTK_BOX (vbox), hScroll, FALSE, FALSE, 0);
        gtk_container_add (GTK_CONTAINER (theWindow), vbox);
    }
    else
    {
        if (windowMB)
        {
            hScroll = vScroll = hbox = nil;
            vbox = gtk_vbox_new (FALSE, 0);
            gtk_box_pack_start   (GTK_BOX (vbox), windowMB, FALSE, FALSE, 0);
            gtk_box_pack_end (GTK_BOX (vbox), windowContent, TRUE, TRUE, 0);
            gtk_widget_show (vbox);
            gtk_container_add (GTK_CONTAINER (theWindow), vbox);
        }
        else
        {
            hScroll = vScroll = hbox = vbox = nil;
            windowFlag &= 123;
            gtk_container_add (GTK_CONTAINER (theWindow), windowContent);
        }
    }

    windowPtrs   << (long)theWindow;
    windowObjects<< (long)this;

    gtk_window_set_type_hint (GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_DLOG ? GDK_WINDOW_TYPE_HINT_DIALOG : GDK_WINDOW_TYPE_HINT_NORMAL);
    gtk_window_set_modal		(GTK_WINDOW(theWindow),windowFlag & HY_WINDOW_DLOG);
    if (windowVisibility)
        gtk_widget_show(theWindow);

    flags = windowFlag;

    g_signal_connect (G_OBJECT (theWindow), "size-allocate",	G_CALLBACK (window_resize_callback),    (_HYWindow*)this);
}
Example #21
0
/* Main program. */
int main(int argc, char * argv[])
{
#ifdef ENABLE_NLS
    setlocale(LC_ALL, "");
    bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);
#endif

    /* Initialize GTK (via g_option_context_parse) and parse command line arguments. */
    GOptionContext * context = g_option_context_new("");
    g_option_context_add_main_entries(context, opt_entries, GETTEXT_PACKAGE);
    g_option_context_add_group(context, gtk_get_option_group(TRUE));
    GError * err = NULL;
    if ( ! g_option_context_parse(context, &argc, &argv, &err))
    {
        g_print(_("Error: %s\n"), err->message);
        g_error_free(err);
        return 1;
    }
    g_option_context_free(context);

    HandlerContext handler_context;
    memset(&handler_context, 0, sizeof(handler_context));

    /* Get the lxsession PID. */
    const char * p = g_getenv("_LXSESSION_PID");
    if (p != NULL) handler_context.lxsession_pid = atoi(p);

    /* Initialize capabilities of the systemd mechanism. */
    if (dbus_systemd_CanPowerOff())
    {
        handler_context.shutdown_available = TRUE;
        handler_context.shutdown_systemd = TRUE;
    }
    if (dbus_systemd_CanReboot())
    {
        handler_context.reboot_available = TRUE;
        handler_context.reboot_systemd = TRUE;
    }
    if (dbus_systemd_CanSuspend())
    {
        handler_context.suspend_available = TRUE;
        handler_context.suspend_systemd = TRUE;
    }
    if (dbus_systemd_CanHibernate())
    {
        handler_context.hibernate_available = TRUE;
        handler_context.hibernate_systemd = TRUE;
    }

    /* Initialize capabilities of the ConsoleKit mechanism. */
    if (!handler_context.shutdown_available && dbus_ConsoleKit_CanStop())
    {
        handler_context.shutdown_available = TRUE;
        handler_context.shutdown_ConsoleKit = TRUE;
    }
    if (!handler_context.reboot_available && dbus_ConsoleKit_CanRestart())
    {
        handler_context.reboot_available = TRUE;
        handler_context.reboot_ConsoleKit = TRUE;
    }

    /* Initialize capabilities of the UPower mechanism. */
    if (!handler_context.suspend_available && dbus_UPower_CanSuspend())
    {
        handler_context.suspend_available = TRUE;
        handler_context.suspend_UPower = TRUE;
    }
    if (!handler_context.hibernate_available && dbus_UPower_CanHibernate())
    {
        handler_context.hibernate_available = TRUE;
        handler_context.hibernate_UPower = TRUE;
    }

    /* If we are under GDM, its "Switch User" is available. */
    if (verify_running("gdm", "gdmflexiserver"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_GDM = TRUE;
    }

    /* If we are under GDM3, its "Switch User" is available. */
    if (verify_running("gdm3", "gdmflexiserver"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_GDM = TRUE;
    }

    /* lightdm also use gdmflexiserver */
    if (verify_running("lightdm", "gdmflexiserver"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_GDM = TRUE;
    }

    /* lightdm also use gdmflexiserver */
    if (verify_running("lightdm", "gdmflexiserver"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_GDM = TRUE;
    }

    /* lightdm can also be find by the env */
    if (g_getenv("XDG_SEAT_PATH"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_LIGHTDM = TRUE;
    }

    /* If we are under KDM, its "Switch User" is available. */
    if (verify_running("kdm", "kdmctl"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_KDM = TRUE;
    }

    if (verify_running("lxdm", "lxdm-binary"))
    {
        handler_context.switch_user_available = TRUE;
        handler_context.switch_user_LXDM = TRUE;
    }

    /* LTSP support */
    if (g_getenv("LTSP_CLIENT"))
    {
        handler_context.ltsp = TRUE;
        handler_context.shutdown_available = TRUE;
        handler_context.reboot_available = TRUE;
    }

    /* Lock screen */
    const gchar* very_lock_screen = determine_lock_screen();
    if (very_lock_screen)
    {
        handler_context.lock_screen = TRUE;
    }

    /* Make the button images accessible. */
    gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/lxsession/images");

    /* Get the background pixbuf. */
    GdkPixbuf * pixbuf = get_background_pixbuf();

    /* Create the toplevel window. */
    GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
    gtk_window_fullscreen(GTK_WINDOW(window));
    GdkScreen* screen = gtk_widget_get_screen(window);
    gtk_window_set_default_size(GTK_WINDOW(window), gdk_screen_get_width(screen), gdk_screen_get_height(screen));
    gtk_widget_set_app_paintable(window, TRUE);
    g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(expose_event), pixbuf);

    /* Toplevel container */
    GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
    gtk_container_add(GTK_CONTAINER(window), alignment);

    GtkWidget* center_area = gtk_event_box_new();
    gtk_container_add(GTK_CONTAINER(alignment), center_area);

    GtkWidget* center_vbox = gtk_vbox_new(FALSE, 6);
    gtk_container_set_border_width(GTK_CONTAINER(center_vbox), 12);
    gtk_container_add(GTK_CONTAINER(center_area), center_vbox);

    GtkWidget* controls = gtk_vbox_new(FALSE, 6);

    /* If specified, apply a user-specified banner image. */
    if (banner_path != NULL)
    {
        GtkWidget * banner_image = gtk_image_new_from_file(banner_path);
        GtkPositionType banner_position = get_banner_position();

        switch (banner_position)
        {
            case GTK_POS_LEFT:
            case GTK_POS_RIGHT:
                {
                /* Create a horizontal box to contain the image and the controls. */
                GtkWidget * box = gtk_hbox_new(FALSE, 2);
                gtk_box_pack_start(GTK_BOX(center_vbox), box, FALSE, FALSE, 0);

                /* Pack the image and a separator. */
                gtk_misc_set_alignment(GTK_MISC(banner_image), 0.5, 0.0);
                if (banner_position == GTK_POS_LEFT)
                {
                    gtk_box_pack_start(GTK_BOX(box), banner_image, FALSE, FALSE, 2);
                    gtk_box_pack_start(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2);
                    gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2);
                }
                else
                {
                    gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2);
                    gtk_box_pack_end(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2);
                    gtk_box_pack_end(GTK_BOX(box), banner_image, FALSE, FALSE, 2);
                }
                }
                break;

            case GTK_POS_TOP:
                gtk_box_pack_start(GTK_BOX(controls), banner_image, FALSE, FALSE, 2);
                gtk_box_pack_start(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2);
                gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0);
                break;

            case GTK_POS_BOTTOM:
                gtk_box_pack_end(GTK_BOX(controls), banner_image, FALSE, FALSE, 2);
                gtk_box_pack_end(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2);
                gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0);
                break;
        }
    }
    else
        gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0);

    /* Create the label. */
    GtkWidget * label = gtk_label_new("");
    if (prompt == NULL)
    {
        const char * session_name = g_getenv("DESKTOP_SESSION");
        if (session_name == NULL)
            session_name = "LXDE";

        const gchar *command_line = "lsb_release -r -s";
        gchar *output = NULL;
        GError *error;

        if (!g_spawn_command_line_sync( command_line,
                                        &output,
                                        NULL,
                                        NULL,
                                        &error))
        {

            fprintf (stderr, "Error: %s\n", error->message);
            g_error_free (error);

        }

        if (output == NULL)
        {
            output = "";
        }
        else
        {
            output[strlen ( output ) - 1] = '\0';
        }

        prompt = g_strdup_printf(_("<b><big>Logout %s %s session ?</big></b>"), session_name, output);
    }
    gtk_label_set_markup(GTK_LABEL(label), prompt);
    gtk_box_pack_start(GTK_BOX(controls), label, FALSE, FALSE, 4);

    /* Create the Shutdown button. */
    if (handler_context.shutdown_available)
    {
        GtkWidget * shutdown_button = gtk_button_new_with_mnemonic(_("Sh_utdown"));
        GtkWidget * image = gtk_image_new_from_icon_name("system-shutdown", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(shutdown_button), image);
        gtk_button_set_alignment(GTK_BUTTON(shutdown_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(shutdown_button), "clicked", G_CALLBACK(shutdown_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), shutdown_button, FALSE, FALSE, 4);
    }

    /* Create the Reboot button. */
    if (handler_context.reboot_available)
    {
        GtkWidget * reboot_button = gtk_button_new_with_mnemonic(_("_Reboot"));
        GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-reboot", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(reboot_button), image);
        gtk_button_set_alignment(GTK_BUTTON(reboot_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(reboot_button), "clicked", G_CALLBACK(reboot_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), reboot_button, FALSE, FALSE, 4);
    }

    /* Create the Suspend button. */
    if (handler_context.suspend_available && !handler_context.ltsp)
    {
        GtkWidget * suspend_button = gtk_button_new_with_mnemonic(_("_Suspend"));
        GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-suspend", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(suspend_button), image);
        gtk_button_set_alignment(GTK_BUTTON(suspend_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(suspend_button), "clicked", G_CALLBACK(suspend_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), suspend_button, FALSE, FALSE, 4);
    }

    /* Create the Hibernate button. */
    if (handler_context.hibernate_available && !handler_context.ltsp)
    {
        GtkWidget * hibernate_button = gtk_button_new_with_mnemonic(_("_Hibernate"));
        GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-hibernate", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(hibernate_button), image);
        gtk_button_set_alignment(GTK_BUTTON(hibernate_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(hibernate_button), "clicked", G_CALLBACK(hibernate_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), hibernate_button, FALSE, FALSE, 4);
    }

    /* Create the Switch User button. */
    if (handler_context.switch_user_available && !handler_context.ltsp)
    {
        GtkWidget * switch_user_button = gtk_button_new_with_mnemonic(_("S_witch User"));
        GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-switch", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(switch_user_button), image);
        gtk_button_set_alignment(GTK_BUTTON(switch_user_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(switch_user_button), "clicked", G_CALLBACK(switch_user_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), switch_user_button, FALSE, FALSE, 4);
    }

    /* Create the Lock Screen button. */
    if (handler_context.lock_screen && !handler_context.ltsp)
    {
        GtkWidget * lock_screen_button = gtk_button_new_with_mnemonic(_("L_ock Screen"));
        GtkWidget * image = gtk_image_new_from_icon_name("system-lock-screen", GTK_ICON_SIZE_BUTTON);
        gtk_button_set_image(GTK_BUTTON(lock_screen_button), image);
        gtk_button_set_alignment(GTK_BUTTON(lock_screen_button), 0.0, 0.5);
        g_signal_connect(G_OBJECT(lock_screen_button), "clicked", G_CALLBACK(lock_screen_clicked), &handler_context);
        gtk_box_pack_start(GTK_BOX(controls), lock_screen_button, FALSE, FALSE, 4);
    }

    /* Create the Logout button. */
    GtkWidget * logout_button = gtk_button_new_with_mnemonic(_("_Logout"));
    GtkWidget * image = gtk_image_new_from_icon_name("system-log-out", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_image(GTK_BUTTON(logout_button), image);
    gtk_button_set_alignment(GTK_BUTTON(logout_button), 0.0, 0.5);
    g_signal_connect(G_OBJECT(logout_button), "clicked", G_CALLBACK(logout_clicked), &handler_context);
    gtk_box_pack_start(GTK_BOX(controls), logout_button, FALSE, FALSE, 4);

    /* Create the Cancel button. */
    GtkWidget * cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_button_set_alignment(GTK_BUTTON(cancel_button), 0.0, 0.5);
    g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(cancel_clicked), NULL);
    gtk_box_pack_start(GTK_BOX(controls), cancel_button, FALSE, FALSE, 4);

    /* Create the error text. */
    handler_context.error_label = gtk_label_new("");
    gtk_label_set_justify(GTK_LABEL(handler_context.error_label), GTK_JUSTIFY_CENTER);
    gtk_box_pack_start(GTK_BOX(controls), handler_context.error_label, FALSE, FALSE, 4);

    /* Show everything. */
    gtk_widget_show_all(window);

    /* Run the main event loop. */
    gtk_main();

    /* Return. */
    return 0;
}
Example #22
0
int main(int argc, char *argv[])
{
    GtkWidget *window;
    char title[64] = {0};
    char appId[XS_MAX_PATH] = {0};
    xsStrCpy(appId, "file:////home/lewis/git/xs-new/app.xpk");

    // parser arguments
    gtk_init(&argc, &argv);

    // load title and orientation from main app
    xsSysEvent evt = {0};

    evt.type = XS_EVT_LOAD;
    evt.data.app.uri = appId;
    if (xsSysEventHandler(&evt) == XS_EC_OK)
    {   // get app properties
        if (evt.data.app.name != NULL)
            xsTcsCpy(title, evt.data.app.name);
        if (evt.data.app.orient != XS_APP_ORIENT_DEFAULT)
        {
            int tempWidth = g_nScreenWidth;
            // exchange width and height if required
            if ((evt.data.app.orient == XS_APP_ORIENT_LANDSCAPE && g_nScreenWidth < g_nScreenHeight) ||
                    (evt.data.app.orient == XS_APP_ORIENT_PORTRAIT && g_nScreenWidth > g_nScreenHeight))
            {
                g_nScreenWidth = g_nScreenHeight;
                g_nScreenHeight = tempWidth;
            }
        }
    }
    else
    {
        return -1;
    }

    // create window
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), title);
    gtk_window_set_default_size(GTK_WINDOW(window), g_nScreenWidth,
                                g_nScreenHeight);
    gtk_widget_set_app_paintable(window, TRUE);

    // set border width
    gtk_container_border_width(GTK_CONTAINER (window), 10);

    // set event filter
    gtk_widget_set_events(window, GDK_EXPOSURE_MASK
                          | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK
                          | GDK_BUTTON_PRESS_MASK	| GDK_BUTTON_RELEASE_MASK
                          | GDK_BUTTON_MOTION_MASK
                          | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK
                          | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
                          | GDK_EXPOSURE_MASK | GDK_FOCUS_CHANGE_MASK);

    // set expose callback
    g_signal_connect(G_OBJECT(window), "expose-event",
                     G_CALLBACK(on_expose), NULL);

    // set key callback
    g_signal_connect(G_OBJECT(window), "key-press-event",
                     G_CALLBACK(on_key_press), NULL);
    g_signal_connect(G_OBJECT(window), "key-release-event",
                     G_CALLBACK(on_key_release), NULL);

    // set mouse callback
    g_signal_connect(G_OBJECT(window), "button-press-event",
                     G_CALLBACK(on_button_press), NULL);
    g_signal_connect(G_OBJECT(window), "button-release-event",
                     G_CALLBACK(on_button_release), NULL);
    g_signal_connect(G_OBJECT(window), "motion-notify-event",
                     G_CALLBACK(on_motion_notify), NULL);

    // set destroy callback
    g_signal_connect(GTK_OBJECT(window), "destroy",
                     GTK_SIGNAL_FUNC(on_destroy),
                     NULL);

    // show window
    gtk_widget_show(window);

    // initial graphics interface
    PalGiInit(window->window);

    // start application
    evt.type = XS_EVT_START;
    xsSysEventHandler(&evt);

    // enter main loop
    gtk_main();

    // destroy graphics interface
    PalGiUninit();

    return 0;
}
Example #23
0
void initGui( JunoControl* _junoControl, 
	      Settings* _settings, 
	      MidiInput* _midiInput, 
	      int numVoices)
{
    junoControl = _junoControl;
    settings    = _settings;
    midiInput   = _midiInput;

    keyboard = new JunoKeyboard(numVoices);
    
    mainMenu = gtk_item_factory_new(GTK_TYPE_MENU, "<Main>", NULL);
    gtk_item_factory_create_items(mainMenu, mainwin_general_menu_entry_count,
				  mainwin_general_menu_entries, NULL);
    GtkStyle* menuStyle = gtk_style_new(); // a default style
    gtk_widget_set_style( mainMenu->widget, menuStyle );

    GtkWidget* mainContainer;

    mainWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );

    gtk_widget_add_events( GTK_WIDGET( mainWindow ), 
			   GDK_BUTTON_RELEASE_MASK |
			   GDK_POINTER_MOTION_MASK | 
			   GDK_POINTER_MOTION_HINT_MASK |
			   GDK_ENTER_NOTIFY_MASK | 
			   GDK_LEAVE_NOTIFY_MASK | 
			   GDK_KEY_PRESS_MASK | 
			   GDK_KEY_RELEASE_MASK	);

    gtk_window_set_default_size( GTK_WINDOW( mainWindow ), 940, 224 );
    gtk_window_set_policy(GTK_WINDOW(mainWindow), FALSE, FALSE, TRUE);

    gtk_widget_realize( mainWindow );
    gdk_window_set_decorations( mainWindow->window, (GdkWMDecoration)0 );
    gtk_widget_set_app_paintable(mainWindow, TRUE);

    gtk_signal_connect(GTK_OBJECT(mainWindow), "button_press_event", 
		       GTK_SIGNAL_FUNC(mainWindow_press), NULL);
    gtk_signal_connect(GTK_OBJECT(mainWindow), "button_release_event", 
		       GTK_SIGNAL_FUNC(mainWindow_release), NULL);
    gtk_signal_connect(GTK_OBJECT(mainWindow), "motion_notify_event", 
		       GTK_SIGNAL_FUNC(mainWindow_motion), NULL);
    gtk_signal_connect(GTK_OBJECT(mainWindow), "enter_notify_event",
		       GTK_SIGNAL_FUNC(mainWindow_enter), NULL);
    gtk_signal_connect(GTK_OBJECT(mainWindow), "leave_notify_event",
		       GTK_SIGNAL_FUNC(mainWindow_leave), NULL);

    mainContainer = gtk_fixed_new();

    gtk_widget_show( mainWindow );
    gtk_widget_show( mainContainer );

    GdkPixmap* image = gdk_pixmap_create_from_xpm_d( mainWindow->window, 
						     NULL, 
						     NULL, 
						     juno_background_data );
    GtkWidget* pixmap = gtk_pixmap_new( image, NULL );
    gtk_widget_show( pixmap );
    gtk_fixed_put( GTK_FIXED( mainContainer ), pixmap, 0, 0 );

    gtk_container_add( GTK_CONTAINER( mainWindow ), mainContainer );

    init();
    layout( GTK_FIXED( mainContainer ) );

    GdkBitmap* mask = gdk_bitmap_create_from_data( mainWindow->window, 
						   juno_background_mask_bits,
						   juno_background_mask_width,
						   juno_background_mask_height );

    gtk_widget_shape_combine_mask( mainWindow, mask, 0, 0 );
}
Example #24
0
int main(int argn, char **argv)
{
    config = config_init(argn, argv);

	gtk_init(0, NULL);
    //GtkWidget * window = gtk_offscreen_window_new();
    GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 900, 600);
    GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(window));
    GdkVisual* rgba_visual = gdk_screen_get_rgba_visual(screen);
    WebKitSettings * setting;
    WebKitWebView *webView;
    if (rgba_visual) {
        gtk_widget_set_visual(window, rgba_visual);
    }
    gtk_widget_set_app_paintable(window, TRUE);

	WebKitWebContext* context = webkit_web_context_get_default();
	//webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
	//webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
	//webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_WEB_BROWSER);
    webkit_web_context_set_disk_cache_directory(context, "/tmp/cache");
    webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
	webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
	webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_IGNORE);

    webkit_web_context_clear_cache(context);

	webView = WEBKIT_WEB_VIEW(
            webkit_web_view_new_with_user_content_manager(webkit_user_content_manager_new()));
    //webView =WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(context));
    setting = webkit_web_view_get_settings(webView);
    webkit_settings_set_enable_page_cache(setting, false);
    webkit_settings_set_enable_javascript(setting, true);
    webkit_settings_set_enable_offline_web_application_cache(setting, false);
	//webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_settings(setting));
    g_object_set(setting,
	//	"enable-private-browsing", NanBooleanOptionValue(opts, H("private"), false),
		"enable-plugins", FALSE,
		"print-backgrounds", TRUE,
		"enable-javascript", TRUE,
		"enable-html5-database", FALSE,
		"enable-html5-local-storage", FALSE,
		"enable-java", FALSE,
		"enable-page-cache", FALSE,
		"enable-write-console-messages-to-stdout", TRUE,
		"enable-offline-web-application-cache", FALSE,
	//	"auto-load-images", NanBooleanOptionValue(opts, H("images"), true),
		"zoom-text-only", FALSE,
		"media-playback-requires-user-gesture", FALSE, // effectively disables media playback ?
	//	"user-agent", ua,
        NULL
	);

	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
	g_signal_connect(webView, "ready-to-show", G_CALLBACK(ready_to_show), NULL);
	g_signal_connect(webView, "load-changed", G_CALLBACK(web_view_load_changed), NULL);
	g_signal_connect(webView, "web-view-ready", G_CALLBACK(ready_to_show), NULL);

    g_signal_connect(webView, "resource-load-started", G_CALLBACK(resource_started), window);

    g_signal_connect(window, "destroy", G_CALLBACK(destroyWindowCb), NULL);
    g_signal_connect(webView, "close-web-view", G_CALLBACK(closeWebViewCb), window);

    webkit_web_view_load_uri(webView, config->url);
	//gtk_widget_show_all(window);

    gtk_main();

    return 0;
}
Example #25
0
gboolean
mc_show_history (GtkWidget      *event_box, 
                         GdkEventButton *event,
		 MCData    *mc)
{
     GtkWidget *window;
     GtkWidget *scrolled_window;
     GtkListStore *store;
     GtkTreeIter iter;
     GtkTreeModel *model;
     GtkWidget    *treeview;
     GtkCellRenderer *cell_renderer;
     GtkTreeViewColumn *column;
     GtkRequisition  req;
     gchar *command_list[1];
     int i, j;
     gint win_x, win_y, width, height;
     gint entry_h, entry_x, entry_y, applet_x, applet_y;

     /* count commands stored in history list */
     for(i = 0, j = 0; i < MC_HISTORY_LIST_LENGTH; i++)
	 if(exists_history_entry(i))
	     j++;

     window = gtk_window_new(GTK_WINDOW_POPUP); 
     gtk_window_set_screen (GTK_WINDOW (window),
			    gtk_widget_get_screen (GTK_WIDGET (mc->applet)));
     gtk_window_set_policy(GTK_WINDOW(window), 0, 0, 1);
     gtk_widget_set_app_paintable (window, TRUE);
     gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_COMBO);
     /* cb */
     g_signal_connect_after(GTK_OBJECT(window),
			      "button_press_event",
			      GTK_SIGNAL_FUNC(history_popup_clicked_cb),
			      NULL);
     g_signal_connect_after (G_OBJECT (window), "key_press_event",
     		       G_CALLBACK (history_key_press_cb), NULL);

     gdk_window_get_geometry (GTK_WIDGET (mc->applet_box)->window, NULL, NULL,
         &width, &height, NULL);
     gdk_window_get_origin (mc->applet_box->window, &applet_x, &applet_y);
     gdk_window_get_position (mc->entry->window, &entry_x, &entry_y);
     gdk_drawable_get_size (mc->entry->window, NULL, &entry_h);

      win_x=applet_x + entry_x-1;
      win_y=applet_y + entry_y;

      /* size */
      gtk_widget_set_usize(GTK_WIDGET(window), width-2*(entry_x-1), 350);
     /* scrollbars */
     /* create scrolled window to put the Gtk_list widget inside */
     scrolled_window=gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
				    GTK_POLICY_AUTOMATIC,
				    GTK_POLICY_AUTOMATIC);
     g_signal_connect(GTK_OBJECT(scrolled_window),
			"button_release_event",
			GTK_SIGNAL_FUNC(history_popup_clicked_inside_cb),
			NULL);
     gtk_container_add(GTK_CONTAINER(window), scrolled_window);
     gtk_container_set_border_width (GTK_CONTAINER(scrolled_window), 1);
     gtk_widget_show(scrolled_window);
          
     store = gtk_list_store_new (1, G_TYPE_STRING);

     /* add history entries to list */
     if (j == 0) {
          gtk_list_store_append (store, &iter);
          gtk_list_store_set (store, &iter,0, _("No items in history"), -1);
     }
     else {	
          for(i = 0; i < MC_HISTORY_LIST_LENGTH; i++)
	      {
     	     if(exists_history_entry(i))
	     	 {
     		      command_list[0] = get_history_entry(i);
                      gtk_list_store_prepend (store, &iter);
                      gtk_list_store_set (store, &iter,0,command_list[0],-1);
		 }
	      }
     } 
     model = GTK_TREE_MODEL(store);
     treeview = gtk_tree_view_new_with_model (model);
     g_object_set_data (G_OBJECT (mc->applet), "tree", treeview);
     cell_renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (NULL, cell_renderer,
                                                       "text", 0, NULL);
     gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
     if (j == 0) {
          gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection
                                (GTK_TREE_VIEW (treeview)),
                                 GTK_SELECTION_NONE);
     }
     else {
          gtk_tree_selection_set_mode( (GtkTreeSelection *)gtk_tree_view_get_selection
                                (GTK_TREE_VIEW (treeview)),
                                 GTK_SELECTION_SINGLE);
          g_signal_connect (G_OBJECT (treeview), "button_press_event",
     		       G_CALLBACK (history_list_button_press_cb), mc);
          g_signal_connect (G_OBJECT (treeview), "key_press_event",
     		       G_CALLBACK (history_list_key_press_cb), mc);
     }
   
     g_object_unref (G_OBJECT (model));
     gtk_container_add(GTK_CONTAINER(scrolled_window),treeview);
     gtk_widget_show (treeview); 
     
     gtk_widget_size_request (window, &req);

   
     switch (panel_applet_get_orient (mc->applet)) {
        case PANEL_APPLET_ORIENT_RIGHT:
        case PANEL_APPLET_ORIENT_LEFT:
     case PANEL_APPLET_ORIENT_DOWN:
            win_y += (entry_h+BORDER-1);
     	break;
        
     case PANEL_APPLET_ORIENT_UP:
            win_y -= (req.height+BORDER-1);
	break;
     }

     gtk_window_move (GTK_WINDOW (window), win_x, win_y);
     g_signal_connect ((gpointer) window, "expose_event",
                    G_CALLBACK (history_window_expose_event),
                    NULL);
     gtk_widget_show(window);

     /* grab focus */
     gdk_pointer_grab (window->window,
		       TRUE,
		       GDK_BUTTON_PRESS_MASK
		       | GDK_BUTTON_RELEASE_MASK
		       | GDK_ENTER_NOTIFY_MASK
		       | GDK_LEAVE_NOTIFY_MASK 
		       | GDK_POINTER_MOTION_MASK,
		       NULL,
		       NULL,
		       GDK_CURRENT_TIME); 
     gdk_keyboard_grab (window->window, TRUE, GDK_CURRENT_TIME);
     gtk_grab_add(window);
     gtk_widget_grab_focus (treeview);
 
     return FALSE;
}
Example #26
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;
}
Example #27
0
void
panel_start_gui(panel *p)
{
    ENTER;
    //gtk_rc_parse_string(transparent_rc);
    p->topgwin      = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0);
    gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE);
    gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "trayer");
    gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel");
    gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_CENTER);
    g_signal_connect ( G_OBJECT(p->topgwin) , "delete-event" , G_CALLBACK(panel_delete_event) , p);
    g_signal_connect ( G_OBJECT(p->topgwin) , "destroy-event", G_CALLBACK(panel_destroy_event), p);
    g_signal_connect ( G_OBJECT (p->topgwin), "size-request" , G_CALLBACK(panel_size_req)  , p);
    g_signal_connect ( G_OBJECT (p->topgwin), "size-allocate", G_CALLBACK(panel_size_alloc), p);

    if (p->transparent) {
      g_signal_connect (G_OBJECT (p->topgwin), "configure-event", G_CALLBACK(panel_configure_event), p);
      g_signal_connect (G_OBJECT (p->topgwin), "style-set", G_CALLBACK( panel_style_set), p);
    }

    if (p->on_primary) {
        GdkDisplay *display = gdk_display_get_default ();
        GdkScreen *screen = gdk_display_get_screen(display, 0);
        g_signal_connect ( screen, "monitors-changed", G_CALLBACK(panel_monitors_changed), (gpointer)p );
        p->monitor = gdk_screen_get_primary_monitor(screen);

    }
    gtk_widget_realize(p->topgwin);
    gdk_window_set_decorations(p->topgwin->window, 0);
    gtk_widget_set_app_paintable(p->topgwin, TRUE);

    p->lbox = p->my_box_new(FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0);
    gtk_container_add(GTK_CONTAINER(p->topgwin), p->lbox);
    gtk_widget_show(p->lbox);

    if (p->allign == ALLIGN_RIGHT) {
        GtkWidget * expander = p->my_box_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(p->lbox), expander, TRUE, TRUE, 0);
        gtk_widget_show(expander);
    }

    p->box = p->my_box_new(FALSE, 1);
    gtk_container_set_border_width(GTK_CONTAINER(p->box), 1);
    gtk_box_pack_start(GTK_BOX(p->lbox), p->box, FALSE, TRUE, padding);
    gtk_widget_show(p->box);

    // get properties on topgwin
    p->topGdkWindow = gtk_widget_get_window(p->topgwin);
    p->topxwin = GDK_WINDOW_XWINDOW(GTK_WIDGET(p->topgwin)->window);

    bg_init(gdk_helper_display());

    /* make our window unfocusable */
    gdk_window_set_accept_focus(p->topGdkWindow,False);

    if (p->setdocktype) {
        gdk_window_set_type_hint(p->topGdkWindow,GDK_WINDOW_TYPE_HINT_DOCK);
    }

    Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0);

    /************************/
    /* Window Mapping Point */
    gtk_widget_show_all(p->topgwin);
    Xclimsg(p->topxwin, a_NET_WM_DESKTOP, 0xFFFFFFFF, 0, 0, 0, 0);

    gdk_window_stick                 ( p->topGdkWindow);
    gdk_window_set_skip_pager_hint   ( p->topGdkWindow, True );
    gdk_window_set_skip_taskbar_hint ( p->topGdkWindow, True );

    XSelectInput (gdk_helper_display(), GDK_ROOT_WINDOW(), PropertyChangeMask);
    XSelectInput (gdk_helper_display(), p->topxwin, PropertyChangeMask | FocusChangeMask | StructureNotifyMask);
    gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_wm_events, p);

    calculate_position(p, distance,distancefrom);
    gdk_window_move_resize(p->topgwin->window, p->ax, p->ay, p->aw, p->ah);
    if (p->setstrut)
        panel_set_wm_strut(p);
    if (p->lower)
        XLowerWindow(gdk_helper_display(), p->topxwin);

    RET();
}
Example #28
0
int main(int argc, char **argv)
{
    if (initDecoderWithFile(filename))
        return -1;

    init_queue(&video_pkt_queue); //初始化视频数据包队列
    init_queue(&video_pic_queue); //初始化视频图像队列
    init_queue(&audio_pkt_queue);
    init_queue(&audio_sam_queue);
    
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);//设置线程分离属性

    //文件处理线程
    if (0 != pthread_create(&file_tid, &attr, demux, (void*)filename))
        printf("create file handler thread failed!\n");

    //视频解码线程
    if (0 != pthread_create(&dec_tid, &attr, video_decoder, NULL))
        printf("create decode thread failed!\n");

    if (0 != pthread_create(&audio_dec_tid, &attr, audio_decoder, NULL))
        printf("create audio decode thread failed!\n");

    if (0 != pthread_create(&audio_render_tid, &attr, audio_player, NULL))
        printf("create audio render thread failed!\n");

    /*以下是Gtk界面相关代码*/
    if (!g_thread_supported())
        g_thread_init(NULL);

    gdk_threads_init();
    gdk_threads_enter();

    GtkWidget *main_win;//主窗口
    //GtkWidget *drawable;//图像绘制区域
    gtk_init(&argc, &argv);

    char win_title[100];
    sprintf(win_title, "AniPlayer--by Excalibur : %s", filename);
    main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(main_win), win_title);
    GtkWidget *drawable = gtk_drawing_area_new();

    gtk_container_add(GTK_CONTAINER(main_win), drawable);
    g_signal_connect(G_OBJECT(main_win), "delete-event", G_CALLBACK(exit_clean), NULL);
    //gtk_signal_connect(GTK_OBJECT(drawable), "expose-event", G_CALLBACK(on_darea_expose), NULL);

    gtk_widget_show_all(main_win);

    gtk_widget_set_size_request(drawable, g_player_ctx->width, g_player_ctx->height);

    //关闭自动刷新和双缓冲
    gtk_widget_set_app_paintable(drawable, TRUE);
    gtk_widget_set_double_buffered(drawable, FALSE);//此乃大坑,之前没disable掉一直刷白屏

    time_out = gtk_timeout_add(40, GSourceFunc(on_timer), drawable);

    gtk_main();

    gdk_threads_leave();
    
    _CrtDumpMemoryLeaks();

    //getchar();
    return 0;
}
GtkWindow* create_notification(UrlClickedCb url_clicked)
{
	GtkWidget* win;
	GtkWidget* main_vbox;
	GtkWidget* vbox;
	GtkWidget* close_button;
	GtkWidget* image;
	GtkWidget* alignment;
	AtkObject* atkobj;
	GtkRcStyle* rcstyle;
	WindowData* windata;
	#ifdef USE_COMPOSITE
		GdkColormap* colormap;
		GdkScreen* screen;
	#endif

	windata = g_new0(WindowData, 1);
	windata->urgency = URGENCY_NORMAL;
	windata->url_clicked = url_clicked;

	win = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
	gtk_widget_set_app_paintable(win, TRUE);
	g_signal_connect(G_OBJECT(win), "style-set", G_CALLBACK(on_style_set), windata);
	g_signal_connect(G_OBJECT(win), "map-event", G_CALLBACK(on_window_map), windata);
	g_signal_connect(G_OBJECT(win), "expose-event", G_CALLBACK(on_window_expose), windata);
	g_signal_connect(G_OBJECT(win), "realize", G_CALLBACK(on_window_realize), windata);

	windata->win = win;

	windata->composited = FALSE;

	#ifdef USE_COMPOSITE
		screen = gtk_window_get_screen(GTK_WINDOW(win));
		colormap = gdk_screen_get_rgba_colormap(screen);

		if (colormap != NULL)
		{
			gtk_widget_set_colormap(win, colormap);

			if (gdk_screen_is_composited(screen))
			{
				windata->composited = TRUE;
			}
		}

		g_signal_connect(win, "composited-changed", G_CALLBACK(on_composited_changed), windata);
	#endif

	gtk_window_set_title(GTK_WINDOW(win), "Notification");
	gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_NOTIFICATION);
	gtk_widget_add_events(win, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);

	g_object_set_data_full(G_OBJECT(win), "windata", windata, (GDestroyNotify) destroy_windata);
	atk_object_set_role(gtk_widget_get_accessible(win), ATK_ROLE_ALERT);

	g_signal_connect(G_OBJECT(win), "configure-event", G_CALLBACK(on_configure_event), windata);

	main_vbox = gtk_vbox_new(FALSE, 0);
	g_signal_connect(G_OBJECT(main_vbox), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(main_vbox);
	gtk_container_add(GTK_CONTAINER(win), main_vbox);
	gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 12);

	windata->main_hbox = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(windata->main_hbox);
	gtk_box_pack_start(GTK_BOX(main_vbox), windata->main_hbox, FALSE, FALSE, 0);

	/* First row (icon, vbox, close) */
	windata->iconbox = gtk_alignment_new(0.5, 0, 0, 0);
	gtk_widget_show(windata->iconbox);
	gtk_alignment_set_padding(GTK_ALIGNMENT(windata->iconbox), 5, 0, 0, 0);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), windata->iconbox, FALSE, FALSE, 0);
	gtk_widget_set_size_request(windata->iconbox, BODY_X_OFFSET, -1);

	windata->icon = gtk_image_new();
	gtk_widget_show(windata->icon);
	gtk_container_add(GTK_CONTAINER(windata->iconbox), windata->icon);

	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), vbox, TRUE, TRUE, 0);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);

	/* Add the close button */
	alignment = gtk_alignment_new(0.5, 0, 0, 0);
	gtk_widget_show(alignment);
	gtk_box_pack_start(GTK_BOX(windata->main_hbox), alignment, FALSE, FALSE, 0);

	close_button = gtk_button_new();
	g_signal_connect(G_OBJECT(close_button), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(close_button);
	windata->close_button = close_button;
	gtk_container_add(GTK_CONTAINER(alignment), close_button);
	gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
	gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
	g_signal_connect_swapped(G_OBJECT(close_button), "clicked", G_CALLBACK(gtk_widget_destroy), win);

	rcstyle = gtk_rc_style_new();
	rcstyle->xthickness = rcstyle->ythickness = 0;
	gtk_widget_modify_style(close_button, rcstyle);
	g_object_unref(rcstyle);

	atkobj = gtk_widget_get_accessible(close_button);
	atk_action_set_description(ATK_ACTION(atkobj), 0, "Closes the notification.");
	atk_object_set_name(atkobj, "");
	atk_object_set_description(atkobj, "Closes the notification.");

	image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
	gtk_widget_show(image);
	gtk_container_add(GTK_CONTAINER(close_button), image);

	/* center vbox */
	windata->summary_label = gtk_label_new(NULL);
	g_signal_connect(G_OBJECT(windata->summary_label), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(windata->summary_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->summary_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);

	atkobj = gtk_widget_get_accessible(windata->summary_label);
	atk_object_set_description(atkobj, "Notification summary text.");

	windata->content_hbox = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(windata->content_hbox);
	gtk_box_pack_start(GTK_BOX(vbox), windata->content_hbox, FALSE, FALSE, 0);


	vbox = gtk_vbox_new(FALSE, 6);
	gtk_widget_show(vbox);
	gtk_box_pack_start(GTK_BOX(windata->content_hbox), vbox, TRUE, TRUE, 0);

	windata->body_label = gtk_label_new(NULL);
	g_signal_connect(G_OBJECT(windata->body_label), "style-set", G_CALLBACK(on_style_set), windata);
	gtk_widget_show(windata->body_label);
	gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
	gtk_misc_set_alignment(GTK_MISC(windata->body_label), 0, 0);
	gtk_label_set_line_wrap(GTK_LABEL(windata->body_label), TRUE);
	g_signal_connect_swapped(G_OBJECT(windata->body_label), "activate-link", G_CALLBACK(windata->url_clicked), win);

	atkobj = gtk_widget_get_accessible(windata->body_label);
	atk_object_set_description(atkobj, "Notification body text.");

	alignment = gtk_alignment_new(1, 0.5, 0, 0);
	gtk_widget_show(alignment);
	gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);

	windata->actions_box = gtk_hbox_new(FALSE, 6);
	gtk_widget_show(windata->actions_box);
	gtk_container_add(GTK_CONTAINER(alignment), windata->actions_box);

	return GTK_WINDOW(win);
}
Example #30
0
int 
main (int argc, char **argv)
{
  char *text;
  GtkWidget *window;
  GtkWidget *scrollwin;
  GtkWidget *vbox, *hbox;
  GtkWidget *frame;
  GtkWidget *checkbutton;

  gtk_init (&argc, &argv);
  
  if (argc != 2)
    {
      fprintf (stderr, "Usage: %s FILE\n", g_get_prgname ());
      exit(1);
    }

  /* Create the list of paragraphs from the supplied file
   */
  text = read_file (argv[1]);
  if (!text)
    exit(1);

  context = pango_win32_get_context ();

  paragraphs = split_paragraphs (text);

  pango_context_set_language (context, pango_language_from_string ("en_US"));
  pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);

  font_description = pango_font_description_new ();
  pango_font_description_set_family(font_description, "sans");
  pango_font_description_set_size(font_description, 16 * PANGO_SCALE);
#if 0 /* default init ok? */
  font_description.style = PANGO_STYLE_NORMAL;
  font_description.variant = PANGO_VARIANT_NORMAL;
  font_description.weight = 500;
  font_description.stretch = PANGO_STRETCH_NORMAL;
#endif

  pango_context_set_font_description (context, font_description);

  /* Create the user interface
   */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);

  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC (gtk_main_quit), NULL);

  vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  hbox = make_font_selector ();
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  
  scrollwin = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
				  GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  
  gtk_box_pack_start (GTK_BOX (vbox), scrollwin, TRUE, TRUE, 0);
  
  layout = gtk_layout_new (NULL, NULL);
  gtk_widget_set_events (layout, GDK_BUTTON_PRESS_MASK);
  gtk_widget_set_app_paintable (layout, TRUE);

  gtk_signal_connect (GTK_OBJECT (layout), "size_allocate",
		      GTK_SIGNAL_FUNC (size_allocate), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
		      GTK_SIGNAL_FUNC (expose), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "draw",
		      GTK_SIGNAL_FUNC (draw), paragraphs);
  gtk_signal_connect (GTK_OBJECT (layout), "button_press_event",
		      GTK_SIGNAL_FUNC (button_press), paragraphs);
#if GTK_CHECK_VERSION (1,3,2)
  gtk_widget_set_double_buffered (layout, FALSE);
#endif
  gtk_container_add (GTK_CONTAINER (scrollwin), layout);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

  message_label = gtk_label_new ("Current char:");
  gtk_misc_set_padding (GTK_MISC (message_label), 1, 1);
  gtk_misc_set_alignment (GTK_MISC (message_label), 0.0, 0.5);
  gtk_container_add (GTK_CONTAINER (frame), message_label);

  checkbutton = gtk_check_button_new_with_label ("Use RTL global direction");
  gtk_signal_connect (GTK_OBJECT (checkbutton), "toggled",
		      GTK_SIGNAL_FUNC (checkbutton_toggled), NULL);
  gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 0);

  gtk_widget_show_all (window);

  gtk_main ();
  
  return 0;
}