Advertisement
Guest User

get my facebook profile using gtk and webkit

a guest
Apr 7th, 2011
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.94 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2011 Jacob Israel Cervantes Luevano <jacobnix@gmail.com>
  3.  *
  4.  * This sample is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU Library General Public
  6.  * License as published by the Free Software Foundation; either
  7.  * version 2 of the License, or (at your option) any later version.
  8.  *
  9.  * This sample is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  * Library General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU Library General Public License
  15.  * along with this library; see the file COPYING.LIB.  If not, write to
  16.  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  * Boston, MA 02110-1301, USA.
  18.  */
  19.  
  20. #include <string.h>
  21. #include <gtk/gtk.h>
  22. #include <webkit/webkit.h>
  23.  
  24. void show_Usage()
  25. {
  26.    
  27.     g_printf("Copyright (C) 2011 Jacob Israel Cervantes Luevano <jacobnix@gmail.com>.\n");
  28.     g_printf("This is free software; see the source for copying conditions.\nThere is NO  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
  29.     g_printf("Super Simple Facebook Browser for GNOME Desktop\n");
  30.     g_printf("Usage: getfacebook --facebook-profile [your-real-profile]\n");
  31.  
  32. }
  33.  
  34. const gchar* myStrCat(const gchar *furl,const gchar *fprof)
  35. {
  36.   gchar *p,*q,*res;
  37.   int num_chars;
  38.    
  39.    for (num_chars = 0, p = furl; *p != '\0'; num_chars++, p++)
  40.       ;
  41.    for (p = fprof; *p != '\0'; num_chars++, p++);
  42.       ;  
  43.    res = (char *) malloc(num_chars + 1);  
  44.    for (p =res, q = furl; (*p = *q) != '\0'; p++, q++) ;
  45.    for (q = fprof; (*p = *q) != '\0'; p++, q++) ;
  46.    
  47.    return res;
  48.    free(res);
  49. }
  50.  
  51. int main(int argc,char *argv[])
  52. {
  53.  
  54.     GtkWidget *facebookWin;
  55.     GtkWidget *facebookWin_scrollw;
  56.     GtkWidget *facebookWin_webview;
  57.  
  58.     gtk_init(&argc,&argv);
  59.  
  60.     const gchar *fbookWinTitle = "my FaceBook";
  61.     const gchar *facebook_url = "http://www.facebook.com/";
  62.     const gchar *facebook_profile, *my_profile;
  63.  
  64.     facebook_profile = (strcmp(argv[1],"--facebook-profile") == 0) ? argv[2] : 0;
  65.  
  66.     if(facebook_profile == 0) {show_Usage();return 0;}
  67.  
  68.     my_profile = myStrCat(facebook_url,facebook_profile);
  69.        
  70.     facebookWin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  71.     facebookWin_scrollw = gtk_scrolled_window_new (NULL,NULL);
  72.     facebookWin_webview = webkit_web_view_new();
  73.  
  74.     gtk_window_set_title (GTK_WINDOW (facebookWin), fbookWinTitle);
  75.  
  76.     gtk_container_add (GTK_CONTAINER (facebookWin_scrollw), facebookWin_webview);
  77.     gtk_container_add (GTK_CONTAINER (facebookWin), facebookWin_scrollw);
  78.  
  79.     webkit_web_view_load_uri (WEBKIT_WEB_VIEW (facebookWin_webview), my_profile);
  80.    
  81.     g_signal_connect (facebookWin, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  82.  
  83.     gtk_window_set_default_size (GTK_WINDOW (facebookWin),800,600);
  84.  
  85.     gtk_widget_show_all (facebookWin);
  86.  
  87.     gtk_main ();
  88.  
  89.     return 0;
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement